I know this is already on the radar, but wanted to create a distinct issue.
(This is required for a test runner.)
I also need this feature!!!
Just to be clear, this was implemented but during the re-write to use ESM natively, it had to be dropped to be re-implemented later. It is currently sitting in @ry's backlog.
This should happen in //core/ ... https://github.com/denoland/deno/pull/1919 needs to land first.
I want to complete async module loading before attempting this (which is essentially the same as this progress bar issue: https://github.com/denoland/deno/issues/1320)
update: async module loading has landed https://github.com/denoland/deno/pull/2084
That's great happy that you are working for this key feature. but it's not work until 0.9.0. Here is what's happened on my computer, maybe help.
deno version
deno: 0.9.0
v8: 7.7.37
typescript: 3.5.1
on Ubuntu 18.04
test-dynamic-import.js
import('./imported.js').then( module=> {
console.log( module.default );
}, );
imported.js
export default 'successful';
deno run test-dynamic-import.js
thread 'tokio-runtime-worker-0' panicked at 'dyn_import callback not set', ../../core/isolate.rs:238:7
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
fatal runtime error: failed to initiate panic, error 5
bash: “deno run test-dynamic-import.js” terminated by signal SIGABRT (Abort)
This has not been delivered yet. That is why the issue is still open. It is still being worked on.
Almost there... https://github.com/denoland/deno/pull/2678 was landed which adds better error handling in libdeno's dynmaic import binding. We now just need to rebase #2516 ...
Done with #2516 :)
CC @ry
Is there an option to disable caching the imported file? Maybe something like import('file.ts', {cache: false})
That would be a seperate request.
Also, import() might look like a function, but it isn't, it is actually low level syntax and cannot be augmented.
Looks like there's already one here https://github.com/denoland/deno/issues/5548
And there's a workaround here https://github.com/denoland/deno/issues/5548#issuecomment-643647953
Most helpful comment
This should happen in //core/ ... https://github.com/denoland/deno/pull/1919 needs to land first.