Does this library work with dynamic imports?
ashmind opened this issue · 10 comments
E.g. something like this
import('./levels/1');
produces
./js/test.ts:1 Uncaught (in promise) TypeError: Failed to resolve module specifier './levels/1'
at ./js/test.ts:1
While import x from './levels/1'
works as expected.
Dynamic imports are not supported by the lib currently. I consider adding them in future, though.
I added a basic support for dynamic imports in the beta repo, you can use it with this url:
import {loadModule} from 'https://klesun-misc.github.io/ts-browser-beta/src/ts-browser.js';
Did not test it much, so any feedback, failing cornercases are very very welcome.
@klesun Thanks!
Seems like await import(...)
generates awaitwindow["ts-browser-import-dynamic"](...)
-- missing space after await
.
oh, lol, thanks, sorry, will fix in few minutes
Fixed that - klesun-misc@090f69e
Thanks! I think there is another issue, with relative path resolution.
I am calling import from /ts/app.ts
and importing ./levels/${levelNumber}
which is relative to /ts/app.ts
. In my understanding, it should import from /ts/levels/1.ts
, but it seems to be /levels/1.ts
(ignoring the current file path).
yeah, thanks, good point, on it
Fixed that - klesun-misc@d056633
Awesome, it works now! Thanks a lot!
Added few performance fixes, merged into main repo. Seems to work ok.