Skip to content
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

Explicit GenerateSW or InjectManifest webpack modes #1143

Merged
merged 7 commits into from
Dec 22, 2017

Conversation

jeffposnick
Copy link
Contributor

@jeffposnick jeffposnick commented Dec 21, 2017

R: @goldhand @prateekbh @gauntface

Fixes #1136

There's a lot of refactoring in this PR to move some of the internal methods in workbox-webpack-plugin around, and share logic between the two plugins.

As part of this PR it also made sense for me to change the global default value for globPatterns (defined in workbox-build) from ['**/*.{js,css,html}'] to []. We had introduced a number of overrides to that global default previously, and would have to introduce additional ones here, and it got to the point that defaulting everything to [] seemed cleaner. (Developers going through the workbox wizard onboarding flow won't be affected by this change, since they're explicitly asked which file extensions to precache.)

Assuming this PR is merged, I will put together a follow-up PR to reflect the changes that are needed to the relevant sections of the docs:

https://github.com/google/WebFundamentals/tree/master/src/content/en/tools/workbox/guides/_shared
https://github.com/google/WebFundamentals/blob/master/src/content/en/tools/workbox/modules/workbox-webpack-plugin.md

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-webpack-plugin/build/index.js 10.30 KB 742 B -93% 470 B 🎉

New Files

File Size GZipped
packages/workbox-webpack-plugin/build/generate-sw.js 5.32 KB 1.87 KB
packages/workbox-webpack-plugin/build/inject-manifest.js 7.11 KB 2.40 KB

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.15 KB 3.15 KB 0% 1.35 KB
packages/workbox-broadcast-cache-update/build/workbox-broadcast-cache-update.prod.js 1.06 KB 1.06 KB 0% 565 B
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/index.js 2.52 KB 2.52 KB 0% 1.06 KB
packages/workbox-cache-expiration/build/workbox-cache-expiration.prod.js 3.23 KB 3.23 KB 0% 1.20 KB
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 590 B 590 B 0% 343 B
packages/workbox-cli/build/app.js 4.57 KB 4.57 KB 0% 1.65 KB
packages/workbox-cli/build/bin.js 2.53 KB 2.53 KB 0% 1.07 KB
packages/workbox-core/build/workbox-core.prod.js 6.36 KB 6.36 KB 0% 2.52 KB
packages/workbox-google-analytics/build/workbox-google-analytics.prod.js 1.92 KB 1.92 KB 0% 999 B
packages/workbox-precaching/build/workbox-precaching.prod.js 5.05 KB 5.05 KB 0% 1.96 KB
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.65 KB 1.65 KB 0% 814 B
packages/workbox-routing/build/workbox-routing.prod.js 2.74 KB 2.74 KB 0% 1.24 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 3.23 KB 3.23 KB 0% 1.00 KB
packages/workbox-sw/build/workbox-sw.js 1.46 KB 1.46 KB 0% 794 B
packages/workbox-webpack-plugin/build/generate-sw.js 5.32 KB 1.87 KB
packages/workbox-webpack-plugin/build/index.js 10.30 KB 742 B -93% 470 B 🎉
packages/workbox-webpack-plugin/build/inject-manifest.js 7.11 KB 2.40 KB

Workbox Aggregate Size Plugin

☠️ WARNING ☠️

We are using 151% of our max size budget.

Total Size: 22.14KB
Percentage of Size Used: 151%

Gzipped: 8.85KB

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 85.787% when pulling 1aed68d on explicit-webpack-mode-toggling into d391a0c on v3.

@jeffposnick jeffposnick added the Breaking Change Denotes a "major" semver change. label Dec 21, 2017
@@ -17,10 +17,8 @@
module.exports = {
globFollow: true,
globIgnores: ['**/node_modules/**/*'],
globPatterns: ['**/*.{js,css,html}'],
globPatterns: [],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we keep this default and give the webpack plugin a different default?

I'm guesisng this makes the webpack plugin require no config and requires config in webpack build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's always going to be config needed in the workbox-build (I think that's what you're asking about), because we don't know what the globDirectory should be.

So yes, this change makes it so that you need to explicitly configure globPatterns as well as globDirectory when using workbox-build directly.

It sounds like you're not in favor of that, so I'll undo that part of this PR and continue overriding globPatterns to [] when needed, instead of the other way around.

Copy link

@gauntface gauntface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I would like workbox-build's defaults to have the default glob patterns and i think that's the case by the time i read the whole PR but not 100%, if so merge when ever you are comfortable.

* `readFile` is configured to use `compiler.inputFileSystem._readFile` during
* the run phase of the webpack compilation lifecycle by passing the function
* to the `setReadFile` function.
* A wrapper that calls readFileFn and returns a promise for the contents of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what readFileFn is it - I'm assuming it's a webpack provided function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jeffposnick
Copy link
Contributor Author

I've filed google/WebFundamentals#5567 as a reminder to update the module docs to reflect this new interface and config options.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 85.808% when pulling 5adce9a on explicit-webpack-mode-toggling into d391a0c on v3.

@jeffposnick jeffposnick merged commit 2b51480 into v3 Dec 22, 2017
@jeffposnick jeffposnick deleted the explicit-webpack-mode-toggling branch December 22, 2017 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Denotes a "major" semver change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants