sw-precache-webpack-plugin: 0.10.0 regression in create-react-app integration

BEFORE YOU SUBMIT please read the following:

  • I’m submitting a bug report

webpack version: 2.x

sw-precache-webpack-plugin version: 0.10.0

Please tell us about your environment: OSX 10.x

We’ve been working on a create-react-app integration, tracked inhttps://github.com/facebookincubator/create-react-app/pull/1728

https://github.com/facebookincubator/create-react-app/pull/1728#issuecomment-301998584 describes a regression when using v0.10.0+ of this plugin, in which the Webpack build process is run twice.

Looking at the change between v0.9.1 and v0.10.0, I guess the issue might have been triggered by something around here: https://github.com/goldhand/sw-precache-webpack-plugin/compare/v0.9.1...v0.10.0?ws=0#diff-1fdf421c05c1140f6d71444ea2b27638R68

But I don’t know enough about Webpack to say for sure.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (16 by maintainers)

Most upvoted comments

@goldhand I’m actually working on a pretty big pr for you… I think that if we are the cause of this issue… then my approach should fix that.

My pr will bring:

  • complete support of the webpack compiler instance’s inputFileSystem & outputFileSystem :

    • all the way down to the swPrecache.generate() level.
    • this includes all third party modules which require('fs')
    • It does this by processing the swPrecache.generate() in a node vm. This allows me to override and mock the require of the fs module.
    • This means it’ll support webpack-dev-server + hot module reloading!! 🎉
  • I’ve changed the processing strategy for this plugin to one very similar to how html-webpack-plugin solves this:

    1. ln SWPrecachePlugin.prototype.apply I listen for the compiler.plugin('make') event.This is after webpack has already walked through your code and acquired all resource paths. But, before the compilation has begun. This allows us to run in parallel with the parent compilation.
    2. In the handler for this event i create a child compiler.
    3. in parallel to the main compilation by tapping into the parent/main compilation’s make lifecycle event: This means faster overall compilation!
    4. on emit i then record all asset output to the compilation.
  • Deprecated minify option

    • Since output assets are now properly recorded to the active webpack compilation.assets/chunks, the output will be minified by any included minification plugin to your webpack config.
    • For example: new webpack.optimize.UglifyJsPlugin()
    • This will still work, to avoid a breaking change. However, I’ve installed a warning to report when you’re using the minify option. Then maybe next minor or major release removes this option entirely.
  • Split a bit of logic into plugins of their own, which then get applied from the main plugin’s apply()

  • added a bunch of tests

charlie-sheen-winning-gif

Re: create-react-app, the PR landed using v0.9.1. So it’s not blocking anything, and thanks again for everyone’s hard work in maintaining this plugin. It should be getting a significant uptick in usage soon 😄