Skip to content

Programmatic API #889

@cspotcode

Description

@cspotcode

Does transcrypt have a programmatic API?

I'd like to do something like this for a live-reload server:

from transcrypt import compilationApi
def requestHandler(req):
    # Suppose browser has made request to download localhost:3000/code/myproject.module.js
    moduleName = req.path.replace("/code/", "").replace(".js", "") # I know this logic is wrong, just simple for example
    return Response.text(compilationApi.compile(moduleName)).contentType("application/javascript")

If the compiled .js for myproject.module contains any import statements, they'll trigger other HTTP requests from the browser which will trigger other calls to requestHandler to compile those modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions