Skip to content

wrong babel cache using filepath as entry point #47

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

Open
Kikobeats opened this issue Apr 25, 2018 · 3 comments
Open

wrong babel cache using filepath as entry point #47

Kikobeats opened this issue Apr 25, 2018 · 3 comments
Labels
unverified Issue needs verification, minimal reproduction

Comments

@Kikobeats
Copy link

Hey folks, thanks for creating this library, I found it very useful.

I'm opening this issue because I found an edge case related to how babel-loader cache works.

babel-loader uses a prop called cachedIdentifier. This property determinate if it is necessary or not re-run babel-loader process.

https://github.com/babel/babel-loader/blob/b29516266912fbc50120155fee00efb1b0a19f59/src/index.js#L61

The point here is that it reads the content of the .babelrc. All is okay.

The edge case is related with this:

{
  "plugins": [
    ["transform-define", "./path/to/config/file.js"]
  ]
}

If you use babel-plugin-transform-define specifying a file path, and then you modify the content of the file, in the next babel-loader it will be determinate that a new run is not necessary, so it will be served the last result from the cache that it's different from your expected result!

Literally, I was thinking I was crazy until discovering this.

The fix could be easiest as determinate the new way to calculate cachedIdentifier. The problem is, because in my case I'm under Next.js, that's is not something easy to do because Next.js internal doesn't contemplate this modification.

Ideally, we should do that transparently adding a bit of code inside babel-plugin-transform-define to detect the edge case, but not sure if we can do that, need to investigate around babel-loader API inside a plugin.

My current workaround is remove the cache before init the process:

rm -rf node_modules/.cache/babel-loader && npm run dev

but obviously, this is a very bad solution and slow.

any idea? 🙂

@sorosora
Copy link

sorosora commented May 9, 2018

I am facing the same issue.

@stevezau
Copy link

I am facing the same issue also. Was going mad trying to work out what was going on!

@ryan-roemer
Copy link
Member

Can someone check if this is still an issue with babel-plugin-transform-define@2.0.0 and babel7? (We've removed the option to do a config file...)

@ryan-roemer ryan-roemer added the unverified Issue needs verification, minimal reproduction label Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified Issue needs verification, minimal reproduction
Projects
None yet
Development

No branches or pull requests

4 participants