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

Cache is not invalidated after babelrc is created #1359

Closed
Codesleuth opened this issue May 13, 2018 · 6 comments · Fixed by #5256
Closed

Cache is not invalidated after babelrc is created #1359

Codesleuth opened this issue May 13, 2018 · 6 comments · Fixed by #5256

Comments

@Codesleuth
Copy link

Codesleuth commented May 13, 2018

🐛 bug report

Build cache is not updated when .babelrc file is created. Specifically for my use-case, transform-react-jsx.pragma setting is not respected.

🎛 Configuration (.babelrc, package.json, cli command)

File to add after the initial build

{
  "plugins": [
    ["transform-react-jsx", { "pragma": "m" }]
  ]
}

🤔 Expected Behavior

When restarting parcel, specified pragma for JSX files should be used.

😯 Current Behavior

The first build will produce a cache which uses the default React pragma setting; after creating the .babelrc file, the next build will emit the same error.

Uncaught ReferenceError: React is not defined

💁 Possible Solution

Invalidate the cache after .babelrc is added to the project.

🔦 Context

I was beginning a new project where I installed parcel and set up an initial JSX component with mithril. As always, I forget to create a .babelrc file, and realise this when the first build displays this error. After adding the file and re-launching parcel, I expected the build to be fixed.

See the demo project for full context.

💻 Code Sample

Steps and demo assets available here: https://github.com/Codesleuth/parcel-babelrc-rebuild-bug

🌍 Your Environment

Software Version(s)
Parcel 1.8.1
Node 8.11.1
npm/Yarn 5.8.0
Operating System Ubuntu 16.04 LTS
@Codesleuth Codesleuth changed the title Redefining JSX pragma removed Cache is not invalidated after babelrc is changed May 13, 2018
@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 13, 2018

The cache invalidating currently only triggers on file update not file creation. (file refers to .babelrc config)

I'm a bit confused after reading your issue, did it happen on creation or update?
As the issue states both

@Codesleuth Codesleuth changed the title Cache is not invalidated after babelrc is changed Cache is not invalidated after babelrc is created May 13, 2018
@Codesleuth
Copy link
Author

Codesleuth commented May 13, 2018

That explains it then, it was on creation. You can see in the steps of the demo project that the file doesn't exist on first build, is created and rebuilt, and there's no cache change.

I've updated the title and report, sorry for the confusion there.

@nicolaisueper
Copy link
Contributor

I assume the cache should be invalidated too when the "babel": {} property was added to the project's package.json?

@DeMoorJasper
Copy link
Member

package.json changes should invalidate every file, as every asset has a getPackage property

@nicolaisueper
Copy link
Contributor

@DeMoorJasper I'd love to tackle this. Can you give me a hint where to start?

I thought about subscribing to every file which gets created inside the project root and check if the filename equals to .babelrc

@devongovett
Copy link
Member

devongovett commented Oct 12, 2020

Waiting on this babel PR to be released and then we should be able to implement this: babel/babel#11906.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants