Transcrypt
Transcrypt copied to clipboard
Programmatic API
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.