Skip to content

chore: Support Vite 8#34

Merged
rschristian merged 1 commit intomasterfrom
chore/vite-8
Mar 15, 2026
Merged

chore: Support Vite 8#34
rschristian merged 1 commit intomasterfrom
chore/vite-8

Conversation

@rschristian
Copy link
Member

Closes #33

Bumped the deps locally & ran the suite, all pass (after a couple tweaks) except the source map errors test. For whatever reason, with Vite 8, line numbers are off by 1. Not a blocking issue though.

@rschristian rschristian merged commit 088216e into master Mar 15, 2026
1 check passed
@silvinor
Copy link

Thanks for quick turnaround on this -- but I worry for lines 179-180 & 186-187 build.rollupOptions was renamed to build.rolldownOptions in Vite 8. The plugin's configResolved hook reads and writes to config.build.rollupOptions directly, which will silently fail under Vite 8 (the manualChunks function won't be registered).

A possible fix is to read from whichever property exists:
const buildOpts = config.build.rolldownOptions ?? config.build.rollupOptions;

There is also a concern with Vite 5–7: semicolons present (Rollup output), but with Vite 8 non-native path: polyfill serialised via .toString() from TS source (no semicolons) .. so the s.replace( lines need a rethink.

@rschristian
Copy link
Member Author

rschristian commented Mar 15, 2026

The plugin's configResolved hook reads and writes to config.build.rollupOptions directly, which will silently fail under Vite 8 (the manualChunks function won't be registered).

Tests say otherwise actually, still works fine AFAICT. In fact, as you can see in the diff here, Vite 8 actually threw an error upon attempting to use my dummy build.rollupOptions.output.manualChunks setting in a test case.

There is also a concern with Vite 5–7: semicolons present (Rollup output), but with Vite 8 non-native path: polyfill serialised via .toString() from TS source (no semicolons) .. so the s.replace( lines need a rethink.

I have absolutely no idea what you're trying to say here.

@rschristian rschristian deleted the chore/vite-8 branch March 15, 2026 03:45
silvinor added a commit to silvinor/fork.preactjs.vite-prerender-plugin that referenced this pull request Mar 15, 2026
@silvinor
Copy link

On rollupOptions: Thanks for testing that: Good to see that Vite 8 still honours rollupOptions (?) and that rolldownOptions actually throws for manualChunks.

On the polyfill: Sorry, that was unclear. In plain terms: the plugin patches vite/modulepreload-polyfill by searching for a specific code string and inserting a window check before it. The exact string we were searching for changed between Vite versions. Older Vite/Rollup output included a semicolon at the end of the line, but Vite 8 doesn't. Rather than adding a third copy of the search string to handle the new format, we can replace all three variants with a single regex that matches regardless of semicolons or quote style.

Maybe seeing the changes in this draft will help? #35

@rschristian
Copy link
Member Author

Good to see that Vite 8 still honours rollupOptions

I can't imagine they'll break that any time soon, even if it's discouraged; the entire ecosystem relies on that pretty freaking heavily.

Rather than adding a third copy of the search string to handle the new format, we can replace all three variants with a single regex that matches regardless of semicolons or quote style.

All you're doing there is taking the 3 branches and merging them into a single check; it's not actually more flexible in any way and is just a heck of a lot slower to execute & debug when something inevitably changes.

@silvinor
Copy link

Ok - fair enough ... I'll close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite 8 support

2 participants