-
Notifications
You must be signed in to change notification settings - Fork 169
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
refactor: use Vite official API for building sw.js #20894
Conversation
40db9a5
to
0776317
Compare
1fb1442
to
574ba0c
Compare
574ba0c
to
f2882af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to produce the same output as before with only some variable rename changed and umd headers. Using umd is a bit odd but apparently it is what you need to use..
We can use 'es', but that prevents whitespace minification. However, this is probably not a big issue since |
be63677
to
86ade55
Compare
86ade55
to
cd1eb06
Compare
@@ -106,7 +106,7 @@ function injectManifestToSWPlugin(): rollup.Plugin { | |||
const { manifestEntries } = await getManifest({ | |||
globDirectory: buildOutputFolder, | |||
globPatterns: ['**/*'], | |||
globIgnores: ['**/*.br', 'pwa-icons/**'], | |||
globIgnores: ['**/*.br', 'pwa-icons/**', 'sw.js'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Added this line to prevent sw.js
from being included in the manifest when the production bundle is built after the development bundle. Previously, this didn't happen because sw.js
existed only virtually in dev mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If sw.js is now written to the file system, does it reintroduce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, just confirmed that it does. Thanks for noting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR with a fix: #20909
output: { | ||
exports: 'none', | ||
entryFileNames: 'sw.js', | ||
inlineDynamicImports: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: This option is untested, but that can be addressed separately since it's coming from the previous config.
sw: settings.clientServiceWorkerSource | ||
}, | ||
output: { | ||
exports: 'none', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: This option is untested, but that can be addressed separately since it's coming from the previous config.
I've happened to find a different approach that avoids umd and preserves minification. The PR uses it now. |
Quality Gate passedIssues Measures |
* fix: fix service worker build * fix PwaTestIT * exclude sw.js from manifest * generate service worker at closeBundle stage * clean up service worker build config * generate service worker at different stages depending on mode * do not use lib mode to allow for minification in es format * clean up plugin code * add inlineDynamicImports: true option * revert some changes to minimize diff * add exports option for backward compatibility --------- Co-authored-by: Teppo Kurki <[email protected]>
Hi @vursen and @tepi, when i performed cherry-pick to this commit to 24.5, i have encountered the following issue. Can you take a look and pick it manually? |
* fix: fix service worker build * fix PwaTestIT * exclude sw.js from manifest * generate service worker at closeBundle stage * clean up service worker build config * generate service worker at different stages depending on mode * do not use lib mode to allow for minification in es format * clean up plugin code * add inlineDynamicImports: true option * revert some changes to minimize diff * add exports option for backward compatibility --------- Co-authored-by: Sergey Vinogradov <[email protected]> Co-authored-by: Teppo Kurki <[email protected]>
* fix: fix service worker build * fix PwaTestIT * exclude sw.js from manifest * generate service worker at closeBundle stage * clean up service worker build config * generate service worker at different stages depending on mode * do not use lib mode to allow for minification in es format * clean up plugin code * add inlineDynamicImports: true option * revert some changes to minimize diff * add exports option for backward compatibility --------- Co-authored-by: Teppo Kurki <[email protected]>
* fix: fix service worker build * fix PwaTestIT * exclude sw.js from manifest * generate service worker at closeBundle stage * clean up service worker build config * generate service worker at different stages depending on mode * do not use lib mode to allow for minification in es format * clean up plugin code * add inlineDynamicImports: true option * revert some changes to minimize diff * add exports option for backward compatibility --------- Co-authored-by: Teppo Kurki <[email protected]>
#20916) * refactor: use Vite official API for building sw.js (#20894) * fix: fix service worker build * fix PwaTestIT * exclude sw.js from manifest * generate service worker at closeBundle stage * clean up service worker build config * generate service worker at different stages depending on mode * do not use lib mode to allow for minification in es format * clean up plugin code * add inlineDynamicImports: true option * revert some changes to minimize diff * add exports option for backward compatibility --------- Co-authored-by: Teppo Kurki <[email protected]> * Update vite.generated.ts --------- Co-authored-by: Sergey Vinogradov <[email protected]>
This ticket/PR has been released with Vaadin 24.7.0.alpha6 and is also targeting the upcoming stable 24.7.0 version. |
Description
Updates the service worker plugin to use the Vite official API for building
sw.js
.Fixes #20808
Type of change