-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for Vite 5 and fix dev server assets #13
Conversation
Thanks Ewan, I'll test this locally ASAP |
Works well with Vite 4, #12 looks resolved. After switching to Vite 5, I began seeing this error, and code would no longer automatically reload: This was solved by making the following modification to the html file generated by Vite: <head>
<meta charset="utf-8">
- <script type="module" src="http://localhost:5173/@vite/client"></script>
+ <script type="module" src="http://localhost:5173/bundles/<bundle-name>/@vite/client"></script>
<script type="module" src="http://localhost:5173/bundles/<bundle-name>/src/graphics/index.js"></script>
</head> My best guess is that this was caused by this PR: vitejs/vite#5657 |
@inkfarer I've just made it so the vite client is loaded properly in vite 5. Seems to be working on both vite 4 & 5, but if you're able to review in a nodecg bundle that'd be ideal |
Vite 4.5.2 and 5.1.5 seem to both work properly now on my end 👍 |
@EwanLyon if you could also confirm the same as Inkfarer I'll merge - thanks for your contribution! |
Looks good to me |
Sorry for necroing an already merged PR but, can you make a npm release with these changes or is vite 5 support still a WIP? Workaround until a release: EDIT: Nevermind, the master branch is not ready yet. ❯ pnpm vite
✘ [ERROR] Failed to resolve entry for package "vite-plugin-nodecg". The package may have incorrect main/module/exports specified in its package.json. [plugin externalize-deps]
node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1225:27:
1225 │ let result = await callback({
╵ ^
at packageEntryFailure (file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:47164:15)
at resolvePackageEntry (file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:47161:3)
at tryNodeResolve (file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:46977:16)
at resolveByViteResolver (file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:66878:20)
at file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:66911:28
at requestCallbacks.on-resolve (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1225:28)
at handleRequest (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:647:17)
at handleIncomingPacket (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:672:7)
at Socket.readFromStdout (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:600:7)
at Socket.emit (node:events:518:28)
This error came from the "onResolve" callback registered here:
node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1150:20:
1150 │ let promise = setup({
╵ ^
at setup (file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:66899:18)
at handlePlugins (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1150:21)
at buildOrContextImpl (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:873:5)
at Object.buildOrContext (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:699:5)
at /media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:2023:15
at new Promise (<anonymous>)
at Object.build (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:2022:25)
at build (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1873:51)
at bundleConfigFile (file:///media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/vite@5.3.3_@types+node@20.14.10/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:66854:24)
The plugin "externalize-deps" was triggered by this import
vite.config.js:3:25:
3 │ import NodeCGPlugin from "vite-plugin-nodecg";
╵ ~~~~~~~~~~~~~~~~~~~~
failed to load config from /media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/vite.config.js
error when starting dev server:
Error: Build failed with 1 error:
node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1225:27: ERROR: [plugin: externalize-deps] Failed to resolve entry for package "vite-plugin-nodecg". The package may have incorrect main/module/exports specified in its package.json.
at failureErrorWithLog (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1472:15)
at /media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:945:25
at runOnEndCallbacks (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1315:45)
at buildResponseToResult (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:943:7)
at /media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:970:16
at responseCallbacks.<computed> (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:622:9)
at handleIncomingPacket (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:677:12)
at Socket.readFromStdout (/media/Almacen/Archivos/Proyectos/nodecg/bundles/sveltekit-test/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:600:7)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12) |
Apologies @RiQuY for the delay, please try v2.1.0 on npm |
This adds support for Vite 5. The only relevant breaking change is that build manifests have been moved slightly. We can still support Vite 4 by setting the manifest location manually which is also supported by Vite 4. I also updated the other package versions.
I also fixed #12 by setting the server origin when we get the protocol and port.