GithubHelp home page GithubHelp logo

Comments (19)

Couto avatar Couto commented on July 16, 2024

There's a slightly different version on the develop branch. Do you want to give it a go and tell me if it still happens? (I mean using the cacheIdentifier)

from babel-loader.

Couto avatar Couto commented on July 16, 2024

I'm closing this due inactivity.
It's possible to use the cacheIdentifier as a cache buster, by saving any string in there.

Anything else just give it a shout and I'll re-open the issue.

from babel-loader.

taion avatar taion commented on July 16, 2024

This came up for us on react-bootstrap/react-bootstrap#840 - it'd be great if cacheIdentifier could use more than just the versions, and also look at the Babel configuration as well, in the case of e.g. changes to .babelrc.

from babel-loader.

Couto avatar Couto commented on July 16, 2024

If you want to change the cacheIdentifier everytime the .babelrc changes... why don't you just JSON.stringify() the contents of .babelrc into the loader options? It should accept any string you want.

Either that or I might not be understanding the problem correctly.

from babel-loader.

taion avatar taion commented on July 16, 2024

I could certainly do that, but I think it would be nice if babel-loader took care of this automatically.

The reason I think that's the case is because we saw an issue where we added "runtime" to "optionals" in .babelrc, but we wouldn't see the webpack output change, because the cache wasn't invalidated.

I believe this kind of condition where a user changes .babelrc and then expects to see the webpack output change despite using cacheDirectory is common enough that it should be generally supported.

from babel-loader.

Couto avatar Couto commented on July 16, 2024

I can easily agree that the user would expect the cache to be invalidated, however I'm not sure if it's the loader's responsibility to actually gather info from .babelrc, but I can at least try....

Anyway, I'll try to work on this tomorrow morning, since it's quite late in here.
Meanwhile I'm open to PRs

from babel-loader.

taion avatar taion commented on July 16, 2024

Sadly it's going to be a bit messy, because I think you'd have to use https://github.com/babel/babel/blob/master/src/babel/transformation/file/options/resolve-rc.js , which is likely to make @sebmck unhappy.

But I don't know if there's a better option.

from babel-loader.

sebmck avatar sebmck commented on July 16, 2024

If you hotlink to my internal APIs then I will cry

from babel-loader.

Couto avatar Couto commented on July 16, 2024

@sebmck you and me... specially because babel moves really fast which would mean constant updates on my part. Might try to duplicate the resolve rc functionality into the loader.

but anyway... so far it's just me talking, I will try to mess around to see what I can do.

from babel-loader.

Couto avatar Couto commented on July 16, 2024

Ok... sorry for taking so long, I'm having a hard time to find some free time.

A proof of concept can be found on the feature/resolve-rc... it's hardly tested, but it seems to work on my examples. I was wondering if you're up to test it on your project, and I'm open for opinions.

The option to use .babelrc as cacheIdentifier is opt-in, so you'll have to specify that you want to include it like so:

loaders: [{
  test: /\.js$/,
  loader: 'babel',
  exclude: /node_modules/,
  query: {
    babelrc: true,
    cacheDirectory: true,
  }
}]

from babel-loader.

taion avatar taion commented on July 16, 2024

This is really cool, thanks. What's the benefit of making this opt-in rather than opt-out? It seems like one would usually strongly prefer to have this feature, no?

BTW, might make sense to use https://www.npmjs.com/package/json-stable-stringify instead of the standard JSON.stringify to ensure that hashes don't change spuriously.

from babel-loader.

Couto avatar Couto commented on July 16, 2024

The reason why it's opt-in is mostly to avoid a new unexpected behaviour for the ones already using the cache feature.

Still... this is a work in progress. I'm happy for any input :)

On June 18, 2015 5:45:34 PM GMT+01:00, Jimmy Jia [email protected] wrote:

This is really cool, thanks. What's the benefit of making this opt-in
rather than opt-out? It seems like one would usually strongly prefer to
have this feature, no?

BTW, might make sense to use
https://www.npmjs.com/package/json-stable-stringify instead of the
standard JSON.stringify to ensure that hashes don't change
spuriously.


Reply to this email directly or view it on GitHub:
#62 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

from babel-loader.

taion avatar taion commented on July 16, 2024

I really like this, BTW. I think I'd pretty much use it everywhere.

from babel-loader.

taion avatar taion commented on July 16, 2024

I like this feature a lot and would switch to using it in all cases where I'm currently using cache directory, as it will allow me to get rid of fragile logic for bypassing the cache only for particular builds. Are there any concerns preventing it from being merged?

from babel-loader.

Couto avatar Couto commented on July 16, 2024

I've just merged this feature.
The .babelrc is included automatically, no opt-in required.
You can find this on npm with the version 5.2.0

from babel-loader.

taion avatar taion commented on July 16, 2024

Awesome. Thanks!

from babel-loader.

Couto avatar Couto commented on July 16, 2024

I'm closing this, since it has been merged.
If you find any errors/bugs please reopen :)

from babel-loader.

SimenB avatar SimenB commented on July 16, 2024

I haven't tested it, but does this work if the .babelrc-config is in package.json? https://babeljs.io/docs/usage/babelrc/#use-via-package-json

from babel-loader.

Couto avatar Couto commented on July 16, 2024

At the moment it doesn't, however a PR should not be too hard :)

from babel-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.