fix(config): workaround failure creating temporary file (take 2)
If node_modules is not writable, loadConfigFromBundledFile fails to write its temp file and vite aborts with an exception.
This was previously fixed in #13269, but was reverted after several reports of failure to load config with relative imports (see #13631 and #13730).
Instead of replacing the current code, try to load from string only as a workaround, when the directory doesn't exist.
This should solve the case of unwritable node_modules when relative imports are not used without breaking anything that works.
Have you tried --configLoader runner or native? https://vite.dev/config/#configuring-vite I'm not sure we should add workaround for bundle mode.
If node_modules is not writable (when the temp directory cannot be created), loadConfigFromBundledFile writes the temp file to the same directory where the config file exists.
https://github.com/vitejs/vite/blob/b5f70dda08a4b87059f3e5f5e0de823270018a1a/packages/vite/src/node/config.ts#L2018-L2046
How does the error happen in your case?
How does the error happen in your case?
The project directory is also not writable.
Have you tried
--configLoader runnerornative? https://vite.dev/config/#configuring-vite I'm not sure we should add workaround for bundle mode.
Interesting, I'll try that. Is it possible to use them as fallback automatically in case writing of the temp file fails?
Or at least print a useful error message with instructions on failure?
Is this PR still needed? I'm not sure about the error message if it fails, I assume if node_modules is not writable there would be errors already about it? Anyways if there's a way to improve the error message, I think it can be tackled in a separate PR.