diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-04-11 13:18:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 13:18:19 -0400 |
commit | df73db671beada623a937bf4aad28a486d397971 (patch) | |
tree | 5242df73dc27b762cd61f124c986751859e59ba9 /tests/specs/npm/local_dir_no_duplicate_resolution | |
parent | 061bcb53937548673fdaae0721a169018d322f7b (diff) |
fix(npm): local nodeModulesDir was sometimes resolving duplicates of same package (#23320)
Diffstat (limited to 'tests/specs/npm/local_dir_no_duplicate_resolution')
4 files changed, 31 insertions, 0 deletions
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 000000000..f7cc70f15 --- /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 000000000..ae2f9c1ae --- /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 000000000..c2141bd7e --- /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 000000000..efb95ec90 --- /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 <div>Test</div>; +} + +const html = renderToString(<Test />); |