diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-09-04 16:00:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 14:00:44 +0000 |
commit | c6d1b0a1ccf45b7819b1e6f1efe8687b240f495a (patch) | |
tree | 6be2c0c611e4aee950402a34aaedd1c9b6bcaac3 /tests/specs/workspaces/nested_deno_pkg_npm_conflict | |
parent | 13911eb8efb77bd14a80412072aecb664aa55fd5 (diff) |
fix(byonm): resolve npm deps of jsr deps (#25399)
This allows using npm deps of jsr deps without having to add them to the
root package.json.
Works by taking the package requirement and scanning the
`node_modules/.deno` directory for the best matching package, so it
relies on deno's node_modules structure.
Additionally to make the transition from package.json to deno.json
easier, Deno now:
1. Installs npm deps in a deno.json at the same time as installing npm
deps from a package.json.
2. Uses the alias in the import map for `node_modules/<alias>` for
better package.json compatiblity.
Diffstat (limited to 'tests/specs/workspaces/nested_deno_pkg_npm_conflict')
5 files changed, 43 insertions, 0 deletions
diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc new file mode 100644 index 000000000..1bad68fd4 --- /dev/null +++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tempDir": true, + "steps": [{ + "args": "install", + "output": "[WILDCARD]" + }, { + "args": "run --allow-read main.js", + "output": "4\n0.5.0\n" + }, { + "args": "run --allow-read member/main.js", + "output": "3\n1.0.0\n" + }] +} diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json new file mode 100644 index 000000000..f03a591e2 --- /dev/null +++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json @@ -0,0 +1,7 @@ +{ + "nodeModulesDir": "manual", + "workspace": ["./member"], + "imports": { + "@denotest/add": "npm:@denotest/add@0.5" + } +} diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js new file mode 100644 index 000000000..188da6f97 --- /dev/null +++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js @@ -0,0 +1,9 @@ +import { sum } from "@denotest/add"; + +console.log(sum(2, 2)); + +console.log( + JSON.parse(Deno.readTextFileSync( + new URL("node_modules/@denotest/add/package.json", import.meta.url), + )).version, +); diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json new file mode 100644 index 000000000..1d36d0aab --- /dev/null +++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "@denotest/add": "npm:@denotest/add@1" + } +} diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js new file mode 100644 index 000000000..0f64cf553 --- /dev/null +++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js @@ -0,0 +1,9 @@ +import { add } from "@denotest/add"; + +console.log(add(1, 2)); + +console.log( + JSON.parse(Deno.readTextFileSync( + new URL("node_modules/@denotest/add/package.json", import.meta.url), + )).version, +); |