Deno: Support dynamic import

Created on 16 Feb 2019  ·  12Comments  ·  Source: denoland/deno

I know this is already on the radar, but wanted to create a distinct issue.

(This is required for a test runner.)

Most helpful comment

This should happen in //core/ ... https://github.com/denoland/deno/pull/1919 needs to land first.

All 12 comments

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.

Environment

deno version

deno: 0.9.0
v8: 7.7.37
typescript: 3.5.1

on Ubuntu 18.04

Files

test-dynamic-import.js

import('./imported.js').then( module=> {
    console.log( module.default );
}, );

imported.js

export default 'successful';

Result:

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kitsonk picture kitsonk  ·  3Comments

watilde picture watilde  ·  3Comments

CruxCv picture CruxCv  ·  3Comments

metakeule picture metakeule  ·  3Comments

motss picture motss  ·  3Comments