From 5aecbbf93ba3c94d7c2a24526c6e0a9fe4268030 Mon Sep 17 00:00:00 2001 From: Brian Tedder Date: Mon, 4 Dec 2023 17:42:15 -0600 Subject: [PATCH 1/4] tsconfig extends from node_modules --- packages/utils/node-resolver-rs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/node-resolver-rs/src/lib.rs b/packages/utils/node-resolver-rs/src/lib.rs index 366f43836ff..2b43a0a39ac 100644 --- a/packages/utils/node-resolver-rs/src/lib.rs +++ b/packages/utils/node-resolver-rs/src/lib.rs @@ -1145,7 +1145,7 @@ impl<'a, Fs: FileSystem> ResolveRequest<'a, Fs> { entries: Fields::TSCONFIG, flags: Flags::NODE_CJS, cache: CacheCow::Borrowed(&self.resolver.cache), - include_node_modules: Cow::Borrowed(self.resolver.include_node_modules.as_ref()), + include_node_modules: Cow::Owned(IncludeNodeModules::default()), conditions: ExportsCondition::TYPES, module_dir_resolver: self.resolver.module_dir_resolver.clone(), }; From fbf0f38684e46c69a8b5ea432e73fe3f62cfe248 Mon Sep 17 00:00:00 2001 From: Brian Tedder Date: Tue, 5 Dec 2023 13:47:03 -0600 Subject: [PATCH 2/4] add unit test --- .../node_modules/@scope/tsconfig/tsconfig.json | 3 +++ .../fixture/tsconfig/extends-node-module/bar.ts | 0 .../fixture/tsconfig/extends-node-module/foo.ts | 0 .../tsconfig/extends-node-module/tsconfig.json | 8 ++++++++ packages/utils/node-resolver-rs/src/lib.rs | 16 ++++++++++++++++ 5 files changed, 27 insertions(+) create mode 100644 packages/utils/node-resolver-core/test/fixture/node_modules/@scope/tsconfig/tsconfig.json create mode 100644 packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/bar.ts create mode 100644 packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/foo.ts create mode 100644 packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json diff --git a/packages/utils/node-resolver-core/test/fixture/node_modules/@scope/tsconfig/tsconfig.json b/packages/utils/node-resolver-core/test/fixture/node_modules/@scope/tsconfig/tsconfig.json new file mode 100644 index 00000000000..0fab899d87e --- /dev/null +++ b/packages/utils/node-resolver-core/test/fixture/node_modules/@scope/tsconfig/tsconfig.json @@ -0,0 +1,3 @@ +{ + "compilerOptions": {} +} \ No newline at end of file diff --git a/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/bar.ts b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/bar.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/foo.ts b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/foo.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json new file mode 100644 index 00000000000..5c6b1ce04b2 --- /dev/null +++ b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@scope/tsconfig/tsconfig.json", + "compilerOptions": { + "paths": { + "bar": ["./foo.ts"] + } + } +} diff --git a/packages/utils/node-resolver-rs/src/lib.rs b/packages/utils/node-resolver-rs/src/lib.rs index 2b43a0a39ac..afbef2ef165 100644 --- a/packages/utils/node-resolver-rs/src/lib.rs +++ b/packages/utils/node-resolver-rs/src/lib.rs @@ -2381,6 +2381,22 @@ mod tests { .0, Resolution::Path(root().join("tsconfig/extends-extension/foo.js")) ); + + let mut extends_node_module_resolver = test_resolver(); + extends_node_module_resolver.include_node_modules = Cow::Owned(IncludeNodeModules::Bool(false)); + assert_eq!( + extends_node_module_resolver + .resolve( + "./bar", + &root().join("tsconfig/extends-node-module/index.js"), + SpecifierType::Esm + ) + .result + .unwrap() + .0, + Resolution::Path(root().join("tsconfig/extends-node-module/bar.ts")) + ); + assert_eq!( test_resolver() .resolve( From 50cdd1b1f48e0777545fb4c92f2faafcdd995a3f Mon Sep 17 00:00:00 2001 From: Brian Tedder Date: Tue, 5 Dec 2023 13:48:25 -0600 Subject: [PATCH 3/4] clean up test --- .../fixture/tsconfig/extends-node-module/tsconfig.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json index 5c6b1ce04b2..c468d27e00e 100644 --- a/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json +++ b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/tsconfig.json @@ -1,8 +1,3 @@ { - "extends": "@scope/tsconfig/tsconfig.json", - "compilerOptions": { - "paths": { - "bar": ["./foo.ts"] - } - } + "extends": "@scope/tsconfig/tsconfig.json" } From 8ce542cfd769ba3f42a454ebe7db9391c423c39b Mon Sep 17 00:00:00 2001 From: Brian Tedder Date: Tue, 5 Dec 2023 13:52:45 -0600 Subject: [PATCH 4/4] remove unneeded fixture --- .../test/fixture/tsconfig/extends-node-module/foo.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/foo.ts diff --git a/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/foo.ts b/packages/utils/node-resolver-core/test/fixture/tsconfig/extends-node-module/foo.ts deleted file mode 100644 index e69de29bb2d..00000000000