-
Notifications
You must be signed in to change notification settings - Fork 816
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
Adds importScriptsViaChunks option to webpack plugin #2131
Conversation
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin3.49KB gzip'ed (23% of limit) |
The current order {
importScripts: ['./prechunk-script.js', 'chunk', './postchunk-script.js']
} |
I am not a fan of the overloaded nature of passing in
I guess I'm hoping that folks who really need a specific order will be able to use either |
If you're using |
@jeffposnick Edit: It seems I misunderstand, you mean I have to duplicate the webpack config to have a compilation of my |
(The comments of a closed PR isn't a great place to discuss this—can you open a new issue if you're still running into problems?) My suggestion was that instead of using In v5, |
@jeffposnick Thanks for the reply, I added |
R: @philipwalton
Fixes #1752
This new option in
workbox-webpack-plugin
'sGenerateSW
mode allows you to use the name of chunks from yourwebpack
compilation as the source forimportScripts()
. It also takes steps to exclude whatever's imported viaimportScripts()
from the precache manifest, since the service worker maintains its own cache of imported scripts.It's important that developers use this with versioned filenames (i.e. including a hash), since the current service worker implementations in browsers won't check for updates to imported scripts unless their URL changes.
In the course of writing tests for this, I also fixed some of the validation logic around calls to
importScripts
, making it so that we can check to make sure that the Workbox runtime is imported without having to hardcode the exact filename. This should lead to less test case churn resulting from small changes in the Workbox runtime code leading to new hashed filenames.