-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Description
gatsby build creates different bundles on my localhost (windows) and different on server (Netlify).
Environment
Gatsby version: 1.9.169
Node.js version: 8.7.0
Operating System: win 7
Actual result
As described here #746 (comment)
Gatsby in webpack.config.js uses function as a parameter for minChunk option of commonsChunkPlugin. Inside the function is a tester isFramework.
The RegExp pattern in the tester does not test positively on Windows dev environment (different path separator), so gatsby build generates different bundles on my localhost (windows) and different on server. On localhost the packages of vendorModuleList are not moved to the commons bundle as they should (doesn't matter how often they occur in chunks).
current state of the function
const isFramework = some(
vendorModuleList.map(vendor => {
const regex = new RegExp(`/node_modules/${vendor}/.*`, `i`)
return regex.test(module.resource)
})
)
a small change in the RegExp pattern fixes the problem:
const isFramework = some(
vendorModuleList.map(vendor => {
const regex = new RegExp(`[\\\\/]node_modules[\\\\/]${vendor}[\\\\/].*`, `i`)
return regex.test(module.resource)
})
)