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

Changes to .browserslistrc does not invalidate cache #690

Open
bmbarker90 opened this issue Sep 26, 2018 · 5 comments
Open

Changes to .browserslistrc does not invalidate cache #690

bmbarker90 opened this issue Sep 26, 2018 · 5 comments

Comments

@bmbarker90
Copy link

I'm submitting a bug report

There seems to have been an existing issue #587 related to changes in .babelrc. It looks like it was fixed for .babelrc, but with @babel/preset-env@7.0.0, changes to .browserslistrc can also affect what babel should be outputting.

Webpack Version:
4.20.2

Babel Core Version:
7.1.0

Babel Loader Version:
8.0.2

Please tell us about your environment:
OSX 10.13.6

Current behavior:
When using cacheDirectory: true, the cache does not get invalidated between changes to .browserslistrc contents. Disabling the cache works as expected and changes to .browserslistrc are reflected in the generated bundle.

Expected/desired behavior:
When using cacheDirectory: true, the cache should be invalidated between changes to the .browserslistrc file

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
    Configuration
{
  loader: 'babel-loader',
  options: { 
    cacheDirectory: true,
    presets: [
      [
        "@babel/preset-env",
        {
          useBuiltIns: "entry",
          modules: false,
        }
      ],
      "@babel/react", 
      "@babel/typescript",
    ],
    plugins: [
      "@babel/proposal-class-properties",
      "@babel/proposal-object-rest-spread",
      "react-hot-loader/babel",
    ],
  }
}
@loganfsmyth
Copy link
Member

loganfsmyth commented Sep 26, 2018

We could potentially special-case this in babel-loader, but really this is probably related to babel/babel#8497. Happy to leave this open as a tracking issue.

@bmbarker90
Copy link
Author

That sounds great! I wasn't aware of that effort, but seems like it definitely would be the better solution

weaverryan added a commit to symfony/webpack-encore that referenced this issue Mar 25, 2019
This PR was merged into the master branch.

Discussion
----------

Don't use babel-loader's cacheDirectory for production

Currently `cacheDirectory` is always set to `true` in `babel-loader`'s options.

This can be an issue because the cache identifier is only based on direct Babel options, but not on external configs such as `.browserslistrc` files or if a `browserslist` key was added to the `package.json` (see babel/babel-loader#690).

Disabling that cache entirely in Encore while waiting for a proper solution in `babel` or `babel-loader` would probably not be a good idea, but we could mitigate the problem by disabling it only for the prod environment.

Closes #514

Commits
-------

ae74298 Don't use babel-loader's cacheDirectory for production
silverwind added a commit to silverwind/gitea that referenced this issue Feb 1, 2020
this speeds up repeated webpack builds by around 20%. It will use the
default cache directory `node_modules/.cache/babel-loader`.

Also added cache invalidation to workaround babel/babel-loader#690
zeripath pushed a commit to go-gitea/gitea that referenced this issue Feb 1, 2020
this speeds up repeated webpack builds by around 20%. It will use the
default cache directory `node_modules/.cache/babel-loader`.

Also added cache invalidation to workaround babel/babel-loader#690
@meduzen-immoweb
Copy link

meduzen-immoweb commented Nov 25, 2021

FYI the PR related to the bug babel/babel#8497 mentioned by @loganfsmyth is having some activity these days: babel/babel#11741. 🤞

Edit: planned for babel 7.17.

@steverep
Copy link

Is this issue still valid?

@joshua-bn
Copy link

Is this still an issue with babel/babel#14065 ?

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

6 participants
@loganfsmyth @steverep @bmbarker90 @joshua-bn @meduzen-immoweb and others