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

Add recordsPath to Webpack so module IDs are consistent across builds #533

Merged
merged 4 commits into from
Nov 1, 2016

Conversation

KyleAMathews
Copy link
Contributor

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.

e.g. you could use this extension API to show the user that an update is
available and they should update.
This is especially important on teams + when using CI. The directory
.webpack-records should be checked into your source control.
@KyleAMathews KyleAMathews merged commit f25522d into 1.0 Nov 1, 2016
KyleAMathews added a commit that referenced this pull request Nov 1, 2016
Removed this as previously was worried that this was part of why
redeploying with service workers was causing troubles. But as it turned
out, that was caused by not using recordPath (see #533) so this should
be safe to reenable.
@0x80 0x80 deleted the add-recordsPath branch April 19, 2017 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant