-
Notifications
You must be signed in to change notification settings - Fork 42
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
fix(node): change resolution mode based on import construct #545
fix(node): change resolution mode based on import construct #545
Conversation
@@ -14,7 +14,7 @@ use deno_graph::source::LoadFuture; | |||
use deno_graph::source::LoadOptions; | |||
use deno_graph::source::Loader; | |||
use deno_graph::source::NullFileSystem; | |||
use deno_graph::source::ResolutionMode; | |||
use deno_graph::source::ResolutionKind; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed so that ResolutionMode
aligns with TypeScript's wording https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#stable-support-resolution-mode-in-import-types
tests/specs/graph/cjs/basic.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice in particular the changes in this file.
src/lib.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I outlined a bug with this PR in #80 (comment)
We'll have to come back and fix that later (I think it's too much to fix in this PR or deno_graph upgrade)
js/test.ts
Outdated
@@ -191,6 +191,7 @@ Deno.test({ | |||
{ | |||
"specifier": "./b.js", | |||
"code": { | |||
"mode": "import", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "mode" ok, or should it be "resolutionMode"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO resolutionMode
is clearer
js/test.ts
Outdated
@@ -191,6 +191,7 @@ Deno.test({ | |||
{ | |||
"specifier": "./b.js", | |||
"code": { | |||
"mode": "import", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO resolutionMode
is clearer
if !c.is_alphabetic() { | ||
return Err(monch::ParseError::Backtrace); | ||
} | ||
// good enough for now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;)
We now say if a specific import or export resolution should definitely use ESM or CJS along with supporting "resolution-mode" in TypeScript (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#stable-support-resolution-mode-in-import-types). This information is stored in the referrer range.
It's important to know this for importing npm packages (ex. dynamic imports in cjs should load using ESM and not CJS resolution).
For denoland/deno#27059
CLI PR: denoland/deno#27071