-
-
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 2.7.0-beta.4 regression when building for SSR targeting Cloudflare Workers #5812
Comments
Hello @nrgnrg. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
@nrgnrg could you help us by providing a link to a minimal repro? It would make it easier for other collaborators and maintainers to check this issue |
hey @patak-js, repro here: https://stackblitz.com/edit/vitejs-vite-zexect?file=vite-plugin.ts If you go to If you then delete the dist folder and roll back vite to 2.7.0-beta.3, run another build, |
@patak-js I haven't seen this issue before but I think the problem is related to the minification. Apart form that, @nrgnrg you'll want to provide |
Caused by this line:
The reference to |
I don't see a cache that could cause issues if the plugin is reused though. Ping @aleclarson, you may have some ideas here |
Ah yes #5714 should fix it, only if the I think the question now is whether we want to skip I've asked @frandiox about this in discord and confirmed that workers are always written in ESM, so an extra skip check isn't needed. But from the issue, Cloudflare Workers seem to not support ESM? |
@bluwy Workers by default are written in the The is now beta support for module syntax but this hasn't been suitable for SSR because the |
Ah yes, I missed the It's more subtle than I expected. Here, the nested It can override the entire config (instead of merging) because Rollup has this logic https://github.com/rollup/rollup/blob/ca86df280288656c66a948e122c36ccee7e06aca/src/rollup/rollup.ts#L212 that would read The override caused the harm because the new config doesn't have a Without the override, Vite uses vite/packages/vite/src/node/build.ts Line 483 in cf03ecf
|
So the fix in Vite is also quite straightforward: warn or throw here when it detects an vite/packages/vite/src/node/build.ts Line 480 in cf03ecf
The API design makes sense in Rollup because it separates Vite doesn't need such a design. |
I forgot to send my comment before making the PR 😅 Thanks for the explanation @nrgnrg. I think the best way forward now is to check |
Great further investigation @sodatea. Looks like there are two issues here that causes the problem, I agree that having |
…#5930) * chore: deprecate `rollupOptions.output.output` to avoid subtle errors As explained in #5812 (comment) * chore: format with prettier
So the fix is to set Setting If |
|
Describe the bug
I'm using Vite to build an SSR app targeting Cloudflare Workers.
Below is my config for the build of the server entry:
The intention is to output a single file that runs in a CF Worker and this works in Vite 2.6.x up until 2.7.0-beta.4 where it breaks.
In 2.7.0-beta.4 the build completes fine and it still outputs 1 file as it should but at the end of the generated code it includes
export default os();
.This will not run in a Cloudflare Worker as the output is expected to be 1 file and it does not support esm, this causes a
SyntaxError: Unexpected token 'export'
error in the worker.Reproduction
n/a
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: