We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
To reproduce, save the following as foo.ts and run deno run -A foo.ts
foo.ts
deno run -A foo.ts
await Deno.writeTextFile("bar.ts", "export const bar = 'bar'"); const {bar} = await import("./bar.ts"); console.log(bar);
This results in
error: Uncaught (in promise) TypeError: Module not found "file:///.../bar.ts".
Running it a second time works as expected.
A workaround is to make the import not statically analysable:
await import("" + "./bar.ts");
But this causes you to lose type info for bar.ts. You can cast it, but it gets a bit tedious:
bar.ts
const {bar} = await import("" + "./bar.ts") as typeof import("./bar.ts");
especially when using JSDoc:
const {bar} = /** @type {import("./bar.js")} */ (await import("" + "./bar.js"));
The text was updated successfully, but these errors were encountered:
This behaviour is intended, we actually discussed it in #17697 (comment) :-)
Sorry, something went wrong.
Ah I see 😅 I guess I was a bit too focused on not having it load on startup there. I wasn't aware this was part of the same issue.
Update rollup.wbn.js
1623ecb
"" + "/path" and "/path" + "": Deno-specific workaround to avoid module not found error: -https://www.reddit.com/r/Deno/comments/18unb03/comment/kfsszsw/ -denoland/deno#20945 -denoland/deno#17697 (comment)
So Deno is not designed to comply with ECMAScript, which specifies the meaning and effect of a dynamic import?
No branches or pull requests
To reproduce, save the following as
foo.ts
and rundeno run -A foo.ts
This results in
Running it a second time works as expected.
A workaround is to make the import not statically analysable:
But this causes you to lose type info for
bar.ts
. You can cast it, but it gets a bit tedious:especially when using JSDoc:
The text was updated successfully, but these errors were encountered: