Add recordsPath to Webpack so module IDs are consistent across builds #533
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was running into a weird problem with 1.0 sites using service workers where I'd deploy an upgrade to the site and when reloading the site, there'd be a Javascript error from inside the Webpack module loading code where it couldn't find a module. Debugging this, the module id wouldn't be in the list of modules Webpack loads.
Eventually @NekR, author of offline-plugin helped me debug the problem in this issue NekR/offline-plugin#128
Basically you need to enable an obscure option in Webpack called
recordsPath
which outputs a JSON file mapping between module IDs and module file paths. When this is enabled, Webpack will use this json file to ensure module ids are the same across builds. This is super important as with Gatsby 1.0 we want JS files to be able to be cached forever so need to ensure old js files keep the same module ids as in new builds.