Repository navigation
Conversation
|
sorry: wrong changelist selected in my IDE, fixing lint |
|
the problem this solves is basically that two plugins both use parallel hooks but these hooks depend on each other. Alternative suggestions (some of which already have been discussed in chat): 1) the plugins depending on each other find a way to signal each other via
|
|
This PR is about the sequential plugin hack, I just renamed it so it doesn't sound drastic ;) . I guess Rollup should add configurable hooks, points 2) and 3) and this PR have the same problem, we need to hack Rollup. Point 3) I think it is almost impossible to implement it in the current state |
Description
Add a new
preCloseBundlehook to allow run build plugins hooks between RollupwriteBundleandcloseBundlehooks.EDIT: we need it also in Vite 2 🙏 .
I changed also
scripts/patchCJS.tsmodule to allow build in Windows: I just changeprocess.exit()call withprocess.exit(0): sent another PR for this.Additional context
Trying to integrate with SvelteKit the
vite-plugin-pwaplugin, we have found a problem about a race condition using both plugins with Vite 3 (also with Vite 2, right now latest SvelteKit version will work only with Vite 3).SvelteKit uses the
writeBundleto call theprerenderprocess (SSG). In thecloseBundlehook, it calls theadapterlogic, the adapter gets theprerenderoutput and copy the content to theadapteroutput folder (it can do more things).vite-plugin-pwausescloseBundlehook in its build plugin to generate the service worker, it hasenforce: ' post', and so will be called by Vite/Rollup after SvelteKitcloseBundlehook.We need to invert the
closeBundlehook call, that's,vite-plugin-pwafirst and then SvelteKit`.We can reverse the order just changing the
vite-plugin-pwabuild plugin withenforce: 'pre', but then we have a race condition: since thecloseBundlehook will be called in parallel, both plugins need to be called in asequentialorder; why? because theadapterneeds to copy also the service worker generated by thevite-plugin-pwabuild plugin.Can we move the
vite-plugin-pwabuild plugin to thewriteBundlehook: the answer is no; thevite-plugin-pwawill need theprerenderoutput, and so we have the another race condition, since SvelteKit andvite-plugin-pwabuild plugin will run in parallel.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).