From 07777f14ed5166b1375226d9bc7837c5a9b8b206 Mon Sep 17 00:00:00 2001 From: nicholaslyang Date: Mon, 21 Oct 2024 12:03:53 -0400 Subject: [PATCH] Added test --- .../integration/fixtures/oxc_repro/.gitignore | 3 ++ .../integration/fixtures/oxc_repro/README.md | 30 +++++++++++++++++++ .../oxc_repro/apps/web/nm/@repo/index.js | 1 + .../apps/web/nm/@repo/typescript-config | 1 + .../integration/fixtures/oxc_repro/index.js | 1 + .../integration/fixtures/oxc_repro/main.mjs | 8 +++++ .../fixtures/oxc_repro/nm/index.js | 0 .../fixtures/oxc_repro/package.json | 14 +++++++++ .../tooling/typescript-config/index.js | 1 + .../integration/fixtures/oxc_repro/turbo.json | 1 + .../integration/tests/trace-double-symlink.t | 4 +++ 11 files changed, 64 insertions(+) create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/.gitignore create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/README.md create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/index.js create mode 120000 turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/typescript-config create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/index.js create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/main.mjs create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/nm/index.js create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/package.json create mode 120000 turborepo-tests/integration/fixtures/oxc_repro/tooling/typescript-config/index.js create mode 100644 turborepo-tests/integration/fixtures/oxc_repro/turbo.json create mode 100644 turborepo-tests/integration/tests/trace-double-symlink.t diff --git a/turborepo-tests/integration/fixtures/oxc_repro/.gitignore b/turborepo-tests/integration/fixtures/oxc_repro/.gitignore new file mode 100644 index 0000000000000..d18ba2ea50998 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/.gitignore @@ -0,0 +1,3 @@ +.idea +/node_modules +.turbo diff --git a/turborepo-tests/integration/fixtures/oxc_repro/README.md b/turborepo-tests/integration/fixtures/oxc_repro/README.md new file mode 100644 index 0000000000000..936acd27084d9 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/README.md @@ -0,0 +1,30 @@ +# oxc symlink bug reproduction + +The bug occurs when a symlink is nested inside a directory that is also symlinked. +This occurs with pnpm since it recreates a conventional node_modules structure using +a content addressed store and symlinks. + +Here's the setup: + +- `apps/web/nm/@repo/typescript-config` is a symlink pointing to `tooling/typescript-config` (imagine `typescript-config` is a workspace package and symlinked into `apps/web`'s node modules) +- `tooling/typescript-config/index.js` is a _relative_ symlink pointing to `../../nm/index.js` +- Therefore, `apps/web/nm/@repo/typescript-config/index.js` is resolved as: + +``` +apps/web/nm/@repo/typescript-config/index.js +-> tooling/typescript-config/index.js +-> tooling/typescript-config/../../nm/index.js +-> nm/index.js +``` + +However, when oxc resolves this, it does not do the first resolution, so we get: + +``` +apps/web/nm/@repo/typescript-config/index.js +-> apps/web/nm/@repo/typescript-config/../../nm/index.js +-> apps/web/nm/nm/index.js +``` + +You can validate this by running `node main.mjs`, which attempts to resolve +both `apps/web/nm/@repo/typescript-config/index.js` and `apps/web/nm/@repo/index.js`. +The first fails while the second succeeds. diff --git a/turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/index.js b/turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/index.js new file mode 100644 index 0000000000000..7d3ced0fbf6d8 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/index.js @@ -0,0 +1 @@ +export const foo = "10"; diff --git a/turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/typescript-config b/turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/typescript-config new file mode 120000 index 0000000000000..db36eabbc51ca --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/apps/web/nm/@repo/typescript-config @@ -0,0 +1 @@ +../../../../tooling/typescript-config \ No newline at end of file diff --git a/turborepo-tests/integration/fixtures/oxc_repro/index.js b/turborepo-tests/integration/fixtures/oxc_repro/index.js new file mode 100644 index 0000000000000..21ce0d9effd01 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/index.js @@ -0,0 +1 @@ +import foo from "./apps/web/nm/@repo/typescript-config/index.js"; diff --git a/turborepo-tests/integration/fixtures/oxc_repro/main.mjs b/turborepo-tests/integration/fixtures/oxc_repro/main.mjs new file mode 100644 index 0000000000000..3e74768fc5ab7 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/main.mjs @@ -0,0 +1,8 @@ +import resolve from "oxc-resolver"; + +console.log('resolving "./apps/web/nm/@repo/typescript-config/index.js"'); +console.log( + resolve.sync(".", "./apps/web/nm/@repo/typescript-config/index.js") +); +console.log('resolving "./apps/web/nm/@repo/index.js"'); +console.log(resolve.sync(".", "./apps/web/nm/@repo/index.js")); diff --git a/turborepo-tests/integration/fixtures/oxc_repro/nm/index.js b/turborepo-tests/integration/fixtures/oxc_repro/nm/index.js new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/turborepo-tests/integration/fixtures/oxc_repro/package.json b/turborepo-tests/integration/fixtures/oxc_repro/package.json new file mode 100644 index 0000000000000..92813c28f5196 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/package.json @@ -0,0 +1,14 @@ +{ + "name": "oxc-repro", + "version": "1.0.0", + "description": "", + "workspaces": ["c"], + "packageManager": "npm@10.5.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": {} +} diff --git a/turborepo-tests/integration/fixtures/oxc_repro/tooling/typescript-config/index.js b/turborepo-tests/integration/fixtures/oxc_repro/tooling/typescript-config/index.js new file mode 120000 index 0000000000000..5f339dec36552 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/tooling/typescript-config/index.js @@ -0,0 +1 @@ +../../nm/index.js \ No newline at end of file diff --git a/turborepo-tests/integration/fixtures/oxc_repro/turbo.json b/turborepo-tests/integration/fixtures/oxc_repro/turbo.json new file mode 100644 index 0000000000000..9e26dfeeb6e64 --- /dev/null +++ b/turborepo-tests/integration/fixtures/oxc_repro/turbo.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/turborepo-tests/integration/tests/trace-double-symlink.t b/turborepo-tests/integration/tests/trace-double-symlink.t new file mode 100644 index 0000000000000..c71a7e717d312 --- /dev/null +++ b/turborepo-tests/integration/tests/trace-double-symlink.t @@ -0,0 +1,4 @@ +Setup + $ . ${TESTDIR}/../../helpers/setup_integration_test.sh oxc_repro + + $ ${TURBO} query "query { file(path: \"./index.js\") { path dependencies { files { items { path } } errors { items { message import } } } } }"