From 186b52731c6bb326c4d32905c5e732d082e83465 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 19 Nov 2024 09:57:12 -0500 Subject: fix(node): handle resolving ".//" in npm packages (#26920) The issue was this package had an import like: `".//index.js"` and we resolved that as specified, but node normalizes it to `"./index.js"` so we have to copy node. --- tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/index.js | 2 ++ tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/other.js | 3 +++ .../registry/npm/@denotest/specifier-two-slashes/1.0.0/package.json | 6 ++++++ tests/specs/npm/specifier_two_slashes/__test__.jsonc | 4 ++++ tests/specs/npm/specifier_two_slashes/main.ts | 3 +++ 5 files changed, 18 insertions(+) create mode 100644 tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/index.js create mode 100644 tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/other.js create mode 100644 tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/package.json create mode 100644 tests/specs/npm/specifier_two_slashes/__test__.jsonc create mode 100644 tests/specs/npm/specifier_two_slashes/main.ts (limited to 'tests') diff --git a/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/index.js b/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/index.js new file mode 100644 index 000000000..aca5ca1b8 --- /dev/null +++ b/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/index.js @@ -0,0 +1,2 @@ +// node.js will resolve this as ./other.js +export * from ".//other.js"; \ No newline at end of file diff --git a/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/other.js b/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/other.js new file mode 100644 index 000000000..7d658310b --- /dev/null +++ b/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/other.js @@ -0,0 +1,3 @@ +export function add(a, b) { + return a + b; +} diff --git a/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/package.json b/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/package.json new file mode 100644 index 000000000..55e46b2fd --- /dev/null +++ b/tests/registry/npm/@denotest/specifier-two-slashes/1.0.0/package.json @@ -0,0 +1,6 @@ +{ + "name": "@denotest/specifier-two-slashes", + "version": "1.0.0", + "type": "module", + "main": "index.js" +} \ No newline at end of file diff --git a/tests/specs/npm/specifier_two_slashes/__test__.jsonc b/tests/specs/npm/specifier_two_slashes/__test__.jsonc new file mode 100644 index 000000000..bddbdbc1c --- /dev/null +++ b/tests/specs/npm/specifier_two_slashes/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet main.ts", + "output": "3\n" +} diff --git a/tests/specs/npm/specifier_two_slashes/main.ts b/tests/specs/npm/specifier_two_slashes/main.ts new file mode 100644 index 000000000..ef1adceb5 --- /dev/null +++ b/tests/specs/npm/specifier_two_slashes/main.ts @@ -0,0 +1,3 @@ +import { add } from "npm:@denotest/specifier-two-slashes"; + +console.log(add(1, 2)); -- cgit v1.2.3