-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
vite build fails to resolve real file in 4.3 #12931
Comments
I confirmed that this is fixed in nodejs v16.18 nodejs/node#44536 nodejs/node#44886 |
We could start using vite/packages/vite/src/node/utils.ts Line 561 in e7924d2
|
Maybe only using native when path is less than 255 characters on windows |
That could also work. But this would still for node <16.8, no? |
Yeah |
Importing from
// index.ts - javascript entry defined in index.html
import "./node_modules/@COMPANY_NAME/common-entry" |
I've encountered a similar issue to @o-alexandrov in dev mode on an Apple M1 mac. After upgrading from 4.2.x to 4.3.x the web worker files in my project are all returning a 404 response from the Vite server even though the transpiled path as viewed from the sources tab in browser devtools is correct. @bluwy @patak-dev Based on my experience and from what @o-alexandrov is reporting I suspect this issue may run deeper than just Windows dev environments. I have attempted to replicate this issue on Stackblitz but so far am unable to get it to behave the same as my local environment. Similar to @o-alexandrov, the only solution I have found to solve the issue is to downgrade Vite to 4.2.2. |
@andrewcourtice perhaps you can try patching this code to |
@bluwy That didn't work unfortunately. I'll have a look around Vite's code for importing worker files and see what's changed between 4.2.x and 4.3.x and see if anything stands out. The codebase I am on is a large monorepo using symlinked packages (via yarn workspaces). Maybe there is new behaviour with how Vite resolves packages in monorepos for worker files. |
4.3 changes a lot for how files are resolved in general, so there could be many causes. I think it would be best if we track this in a new issue (and better if you can repro it!) |
@bluwy I managed to reproduce the issue. It turns out that Vite wasn't resolving the file because it was expecting a file extension in the URL constructor despite Vite's default For example, in a symlinked package this doesn't work: const worker = new Worker(new URL('./worker', import.meta.url), {
type: 'module',
}); But this does: const worker = new Worker(new URL('./worker.ts', import.meta.url), {
type: 'module',
}); I'll open a new issue for this particular case. It still only seems to be affecting workers in symlinked packages. Thanks for your help :) |
Describe the bug
I am using vite with
react
and@mui/material
. When I runvite build
, it encounters error during build (no such file or directory) on resolvingC:\Users\sunghwan\source\repos\vite-project\node_modules\.pnpm\@mui+material@5.12.1_@emotion+react@11.10.6_@emotion+styled@11.10.6_@types+react@18.0.28_react-dom@18.2.0_react@18.2.0\node_modules\@mui\material\BottomNavigationAction\bottomNavigationActionClasses.js
.What I found is the file is actually exists, but
realpathSync.native
fails because the length is 265 that is overMAX_PATH
, 260.Reproduction
https://github.com/sunghwan2789/repro-vite-4-3-build-fail
Steps to reproduce
pnpm create vite pnpm add @mui/material @emotion/react @emotion/styled # use mui components pnpm build
System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: