Skip to content

Commit

Permalink
fix(node): correct resolution of dynamic import of esm from cjs (#27071)
Browse files Browse the repository at this point in the history
Ensures a dynamic import in a CJS file will consider the referrer as an import for node resolution.

Also adds fixes (adds) support for `"resolution-mode"` in TypeScript.
  • Loading branch information
dsherret authored Nov 26, 2024
1 parent c443ac5 commit 115a306
Show file tree
Hide file tree
Showing 92 changed files with 868 additions and 1,673 deletions.
153 changes: 8 additions & 145 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa
deno_cache_dir.workspace = true
deno_config.workspace = true
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "0.160.0", features = ["rust", "comrak"] }
deno_graph = { version = "=0.85.1" }
deno_doc = { version = "=0.161.1", features = ["rust", "comrak"] }
deno_graph = { version = "=0.86.2" }
deno_lint = { version = "=0.68.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm.workspace = true
Expand Down
24 changes: 14 additions & 10 deletions cli/cache/module_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ fn serialize_media_type(media_type: MediaType) -> i64 {

#[cfg(test)]
mod test {
use deno_graph::JsDocImportInfo;
use deno_graph::PositionRange;
use deno_graph::SpecifierWithRange;

Expand All @@ -308,18 +309,21 @@ mod test {
);

let mut module_info = ModuleInfo::default();
module_info.jsdoc_imports.push(SpecifierWithRange {
range: PositionRange {
start: deno_graph::Position {
line: 0,
character: 3,
},
end: deno_graph::Position {
line: 1,
character: 2,
module_info.jsdoc_imports.push(JsDocImportInfo {
specifier: SpecifierWithRange {
range: PositionRange {
start: deno_graph::Position {
line: 0,
character: 3,
},
end: deno_graph::Position {
line: 1,
character: 2,
},
},
text: "test".to_string(),
},
text: "test".to_string(),
resolution_mode: None,
});
cache
.set_module_info(
Expand Down
Loading

0 comments on commit 115a306

Please sign in to comment.