Commit a984e2d
chore: test node_modules symlinks in npm workspace with cyclic deps (#34759)
Adds a regression spec test for the npm-workspace symlink scenario
reported in #19726.
## Background
The issue reported that an npm workspace where member packages are
symlinked into `node_modules` (as `npm install` does) caused Rust to
panic during package.json module resolution. The reproduction
(verikono/deno-npm-symlinks) has three workspace packages where `pkg-a`
and `pkg-b` import each other (a cyclic dependency).
This was fixed somewhere along the way — the maintainer noted on the
issue that it already works in v2.1.2, and I confirmed it works on
current `main` across every resolution path I tried:
- import-map resolution to the local workspace sources
- pure `node_modules` + package.json `exports` resolution
(`nodeModulesDir: manual`)
- absolute symlinks pointing outside the project root
- cyclic deps via `deno run`, `deno test` (type-check + run), and `deno
info` (which correctly canonicalizes the symlink to the real path and
shows the cycle)
## This PR
Since there was no code left to fix, this adds a regression spec test at
`tests/specs/npm/workspace_symlink_cyclic/` so the scenario doesn't
regress. The test:
- sets up an npm workspace with `main-project`, `pkg-a`, `pkg-b` (with
`pkg-a` ⇄ `pkg-b` cyclic deps), mirroring the original reproduction
- recreates the `node_modules` symlinks `npm install` produces, via a
`setup.js` step using `Deno.symlinkSync` (no symlinks committed to git)
- runs `deno test`, which resolves the symlinked workspace packages
through `node_modules` and exercises the cyclic dependency
Gated to `unix` since creating directory symlinks on Windows requires
elevated privileges.
Closes #19726
Closes denoland/divybot#440
---------
Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>1 parent c4e2dcd commit a984e2d
12 files changed
Lines changed: 121 additions & 0 deletions
File tree
- tests/specs/npm/workspace_symlink_cyclic
- packages
- main-project
- src
- pkg-a
- src
- pkg-b
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments