Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Oct 21, 2024
1 parent 5695cdc commit 07777f1
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions turborepo-tests/integration/fixtures/oxc_repro/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
/node_modules
.turbo
30 changes: 30 additions & 0 deletions turborepo-tests/integration/fixtures/oxc_repro/README.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = "10";
1 change: 1 addition & 0 deletions turborepo-tests/integration/fixtures/oxc_repro/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import foo from "./apps/web/nm/@repo/typescript-config/index.js";
8 changes: 8 additions & 0 deletions turborepo-tests/integration/fixtures/oxc_repro/main.mjs
Original file line number Diff line number Diff line change
@@ -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"));
Empty file.
14 changes: 14 additions & 0 deletions turborepo-tests/integration/fixtures/oxc_repro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "oxc-repro",
"version": "1.0.0",
"description": "",
"workspaces": ["c"],
"packageManager": "[email protected]",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {}
}
1 change: 1 addition & 0 deletions turborepo-tests/integration/fixtures/oxc_repro/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions turborepo-tests/integration/tests/trace-double-symlink.t
Original file line number Diff line number Diff line change
@@ -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 } } } } }"

0 comments on commit 07777f1

Please sign in to comment.