-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importActual
mangles file paths when importing sister packages in Lerna repos
#1864
Closed
6 tasks done
Comments
simon-abbott
changed the title
Aug 16, 2022
importActual
mangles file paths in Lerna reposimportActual
mangles file paths when importing sister packages in Lerna repos
This also raises the question of why vitest/packages/vite-node/src/externalize.ts Lines 83 to 84 in 57c2367
|
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Aug 17, 2022
Previously `toFilePath` would treat _any_ absolute path that doesn't start with the `root` (usually the current working directory) as a relative path, which resulted in some seriously mangled paths. Now we actually check if that resolved path exists before committing to it. This fixes vitest-dev#1864.
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Aug 17, 2022
Previously `getFsPath` would just replace the first occurrence of the root path with the empty string (`path.replace(this.root, '')`). This lead to incorrect behavior: ```js const path = '/some/path/to/a/package-somewhere/index.js' const root = '/some/path/to/a/package' const result = path.replace(root, '') // result _should_ be '/some/path/to/a/package-somewhere/index.js', but // instead it's '-somewhere/index.js' ``` This fixes a bug I found while trying to write a test case for vitest-dev#1864.
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Aug 17, 2022
Previously `toFilePath` would treat _any_ absolute path that doesn't start with the `root` (usually the current working directory) as a relative path, which resulted in some seriously mangled paths. Now we actually check if that resolved path exists before committing to it. This fixes vitest-dev#1864.
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Aug 17, 2022
Previously `getFsPath` would just replace the first occurrence of the root path with the empty string (`path.replace(this.root, '')`). This lead to incorrect behavior: ```js const path = '/some/path/to/a/package-somewhere/index.js' const root = '/some/path/to/a/package' const result = path.replace(root, '') // result _should_ be '/some/path/to/a/package-somewhere/index.js', but // instead it's '-somewhere/index.js' ``` This fixes a bug I found while trying to write a test case for vitest-dev#1864.
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Aug 23, 2022
Previously `toFilePath` would treat _any_ absolute path that doesn't start with the `root` (usually the current working directory) as a relative path, which resulted in some seriously mangled paths. Now we actually check if that resolved path exists before committing to it. This fixes vitest-dev#1864.
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Aug 23, 2022
Previously `getFsPath` would just replace the first occurrence of the root path with the empty string (`path.replace(this.root, '')`). This lead to incorrect behavior: ```js const path = '/some/path/to/a/package-somewhere/index.js' const root = '/some/path/to/a/package' const result = path.replace(root, '') // result _should_ be '/some/path/to/a/package-somewhere/index.js', but // instead it's '-somewhere/index.js' ``` This fixes a bug I found while trying to write a test case for vitest-dev#1864.
Any update on this? |
6 tasks
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Oct 28, 2022
Previously `toFilePath` would treat _any_ absolute path that doesn't start with the `root` (usually the current working directory) as a relative path, which resulted in some seriously mangled paths. Now we actually check if that resolved path exists before committing to it. This fixes vitest-dev#1864.
simon-abbott
added a commit
to simon-abbott/vitest
that referenced
this issue
Oct 28, 2022
Previously `toFilePath` would treat _any_ absolute path that doesn't start with the `root` (usually the current working directory) as a relative path, which resulted in some seriously mangled paths. Now we actually check if that resolved path exists before committing to it. This fixes vitest-dev#1864.
sheremet-va
pushed a commit
that referenced
this issue
Oct 31, 2022
Previously `toFilePath` would treat _any_ absolute path that doesn't start with the `root` (usually the current working directory) as a relative path, which resulted in some seriously mangled paths. Now we actually check if that resolved path exists before committing to it. This fixes #1864.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
Calling
importActual
results in vitest trying (and failing) to resolve an incredible mangled file path if the imported package is a sister package (not having the same root directory) and itsmain
file is in adist
folder.It seems the root cause of this issue is that
toFilePath
doesn't actually respect absolute paths, and instead tries to prefix them with the cwd. If this mangled path contains/dist/
, it is then fed toisValidNodeImport()
(src), which then tries to read from that path (which doesn't exist) and throws.Reproduction
https://github.com/simon-abbott/vitest-lerna-mre -- just run
npm i
andnpm run test
. Also try modifyingpackages/one
so thatindex.js
isn't indist/
and the error goes away.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: