diff --git a/cli/npm/managed/mod.rs b/cli/npm/managed/mod.rs index 829750c0a9..1479643e72 100644 --- a/cli/npm/managed/mod.rs +++ b/cli/npm/managed/mod.rs @@ -522,6 +522,8 @@ impl NpmResolver for ManagedCliNpmResolver { let path = self .fs_resolver .resolve_package_folder_from_package(name, referrer, mode)?; + let path = + canonicalize_path_maybe_not_exists_with_fs(&path, self.fs.as_ref())?; log::debug!("Resolved {} from {} to {}", name, referrer, path.display()); Ok(path) } diff --git a/tests/specs/README.md b/tests/specs/README.md index d04adbb62e..a23fa1ce6f 100644 --- a/tests/specs/README.md +++ b/tests/specs/README.md @@ -87,6 +87,7 @@ Within the file, you can use the following for matching: - `[WILDCARD]` - match any text at the wildcard - `[WILDLINE]` - match any text on the current line +- `[WILDCHAR]` - match the next character - `[WILDCHARS(5)]` - match any of the next 5 characters - `[UNORDERED_START]` followed by many lines then `[UNORDERED_END]` will match the lines in any order (useful for non-deterministic output) diff --git a/tests/specs/npm/local_dir_no_duplicate_resolution/__test__.jsonc b/tests/specs/npm/local_dir_no_duplicate_resolution/__test__.jsonc new file mode 100644 index 0000000000..f7cc70f155 --- /dev/null +++ b/tests/specs/npm/local_dir_no_duplicate_resolution/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "run -A --log-level=debug main.tsx", + "output": "main.out" +} diff --git a/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json b/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json new file mode 100644 index 0000000000..ae2f9c1ae8 --- /dev/null +++ b/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json @@ -0,0 +1,11 @@ +{ + "nodeModulesDir": true, + "imports": { + "preact": "npm:preact", + "preact-render-to-string": "npm:preact-render-to-string" + }, + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "preact" + } +} diff --git a/tests/specs/npm/local_dir_no_duplicate_resolution/main.out b/tests/specs/npm/local_dir_no_duplicate_resolution/main.out new file mode 100644 index 0000000000..c2141bd7e9 --- /dev/null +++ b/tests/specs/npm/local_dir_no_duplicate_resolution/main.out @@ -0,0 +1,5 @@ +[WILDCARD]Resolved preact from file:///[WILDLINE]/preact@10.19.6/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs to [WILDLINE]node_modules[WILDCHAR].deno[WILDCHAR]preact@10.19.6[WILDCHAR]node_modules[WILDCHAR]preact +DEBUG RS - [WILDLINE] - Resolved preact from file:///[WILDLINE]/preact@10.19.6/node_modules/preact/hooks/dist/hooks.mjs to [WILDLINE]node_modules[WILDCHAR].deno[WILDCHAR]preact@10.19.6[WILDCHAR]node_modules[WILDCHAR]preact +[# ensure that preact is resolving to .deno/preact@10.19.6/node_modules/preact and not .deno/preact-render-to-string@6.4.0/node_modules/preact] +DEBUG RS - [WILDLINE] - Resolved preact from file:///[WILDLINE]/preact-render-to-string@6.4.0/node_modules/preact-render-to-string/dist/index.mjs to [WILDLINE]node_modules[WILDCHAR].deno[WILDCHAR]preact@10.19.6[WILDCHAR]node_modules[WILDCHAR]preact +[WILDCARD] diff --git a/tests/specs/npm/local_dir_no_duplicate_resolution/main.tsx b/tests/specs/npm/local_dir_no_duplicate_resolution/main.tsx new file mode 100644 index 0000000000..efb95ec901 --- /dev/null +++ b/tests/specs/npm/local_dir_no_duplicate_resolution/main.tsx @@ -0,0 +1,10 @@ +// this previously was ending up with two preacts and would crash +import { useMemo } from "preact/hooks"; +import renderToString from "preact-render-to-string"; + +function Test() { + useMemo(() => "test", []); + return