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

isFramework in commonsChunkPlugin does not work properly on windows #3937

Closed
greglobinski opened this issue Feb 9, 2018 · 1 comment
Closed

Comments

@greglobinski
Copy link
Contributor

greglobinski commented Feb 9, 2018

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)
        })
    )
@greglobinski greglobinski changed the title isFramework in commonsChunkPlugin does not work propery on wndows isFramework in commonsChunkPlugin does not work properly on windows Feb 9, 2018
@m-allanson
Copy link
Contributor

@greglobinski This looks good! Would you be able to submit a PR with this change?

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

No branches or pull requests

2 participants