starlight
starlight copied to clipboard
Support dynamic imports
When trying to use a dynamic import
let module_var_promise = import("my_module.mjs").then((my_module) => {
return my_module.someVar;
});
I get an error SyntaxError: 'import', and 'export' cannot be used outside of module code
Is there a technical reason for not supporting dynamic imports outside module code or is it just an oversimplification of the error checking code?
never mind, it's simply that there is no dynamic module import method yet and starlight thinks i'm trying to do a static import..
I think it is worth to keep this issue open. To get dynamic import first I have to implement async functions (there's already some of functionality for async fns internally and generators are working now).
figured that out thanks to https://github.com/swc-project/swc/issues/140
i'm going to try to impl a Promise class so i can transpile async functions / await statements (and impl a import function)