-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[4.4.0] "Invalid URL" error with dynamic imports in plugins. #13730
Comments
Why was the URL invalid? Did you manage to dump it out? Maybe a length limit? Also, there is no reproduction here. |
The revert in 4.4.1 fixed the issue, thank you. |
@cpojer can you by chance provide a minimal reproduction, like is required for all vite issues? I'd be interested in actually fixing the issue. |
Here you go, this is the most minimal version possible: https://github.com/cpojer/vite-4.0.0-bug |
Describe the bug
I have a custom fork of vite-plugin-react. I load the source files directly, and the package is of type: "module" and I'm running my Vite server using
ts-node
andswc
together (Example of how I run TS ESM modules with node). Inside of it the original code of the plugin runs:This line calls import, and after updating to 4.4.0 it resulted in an "Invalid URL" error from deep inside of node's ESM loader hooks. All imports are resolved absolute paths starting with
file:///
, but the dynamic import call in the plugin passesreact-refresh/babel
all the way through to an ESM loader hook, where it crashes. I added some code to hackily manually resolve it pre-import call, which makes it work:The original code for the plugin is here: https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/src/index.ts#L308 – I only made one minor change to this plugin.
After triaging this issue with @patak-dev on Discord, he pointed me to #13269 which changed loading config files via base64 encoded in-memory JS over temporary files. I patched my build of Vite in
node_modules
to manually revert this change (and my hacky change above), and can confirm that reverting it makes the build work again:Reproduction
athenacrisis.com
Steps to reproduce
No response
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: