Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dynamic import #1789

Closed
hayd opened this issue Feb 16, 2019 · 12 comments
Closed

Support dynamic import #1789

hayd opened this issue Feb 16, 2019 · 12 comments
Milestone

Comments

@hayd
Copy link
Contributor

hayd commented Feb 16, 2019

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

(This is required for a test runner.)

@aymonYU
Copy link

aymonYU commented Mar 4, 2019

I also need this feature!!!

@kitsonk
Copy link
Contributor

kitsonk commented Mar 14, 2019

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.

@ry
Copy link
Member

ry commented Mar 14, 2019

This should happen in //core/ ... #1919 needs to land first.

@ry ry added this to the v0.4 milestone Apr 8, 2019
@ry
Copy link
Member

ry commented Apr 8, 2019

I want to complete async module loading before attempting this (which is essentially the same as this progress bar issue: #1320)

@somombo
Copy link

somombo commented Apr 17, 2019

update: async module loading has landed #2084

@ry ry changed the title Support import() Support dynamic import Jun 3, 2019
@ry ry mentioned this issue Jun 5, 2019
ry added a commit to ry/deno that referenced this issue Jun 5, 2019
This patch makes it so that RecursiveLoad doesn't own the Isolate, so
Worker::execute_mod_async does not consume itself.

Previously Worker implemented Loader, but now ThreadSafeState does.

This is necessary preparation work for dynamic import (denoland#1789) and import
maps (denoland#1921)
ry added a commit that referenced this issue Jun 5, 2019
This patch makes it so that RecursiveLoad doesn't own the Isolate, so
Worker::execute_mod_async does not consume itself.

Previously Worker implemented Loader, but now ThreadSafeState does.

This is necessary preparation work for dynamic import (#1789) and import
maps (#1921)
@Fenzland
Copy link
Contributor

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)

@kitsonk
Copy link
Contributor

kitsonk commented Jun 17, 2019

This has not been delivered yet. That is why the issue is still open. It is still being worked on.

@ry ry mentioned this issue Jun 17, 2019
ry pushed a commit to piscisaureus/deno that referenced this issue Jul 11, 2019
This is in preperation for dynamic import (denoland#1789), which is more easily
implemented when errors are dynamic.
ry pushed a commit that referenced this issue Jul 11, 2019
This is in preperation for dynamic import (#1789), which is more easily
implemented when errors are dynamic.
@ry ry mentioned this issue Jul 14, 2019
@ry
Copy link
Member

ry commented Aug 1, 2019

Almost there... #2678 was landed which adds better error handling in libdeno's dynmaic import binding. We now just need to rebase #2516 ...

@bartlomieju
Copy link
Member

Done with #2516 :)

CC @ry

@ry ry closed this as completed Aug 28, 2019
@nvlled
Copy link

nvlled commented Jul 9, 2020

Is there an option to disable caching the imported file? Maybe something like import('file.ts', {cache: false})

@kitsonk
Copy link
Contributor

kitsonk commented Jul 9, 2020

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.

@nvlled
Copy link

nvlled commented Jul 10, 2020

Looks like there's already one here #5548
And there's a workaround here #5548 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants