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

Fix babel config in package.json #1515

Merged
merged 1 commit into from
Jun 9, 2018

Conversation

sj26
Copy link
Contributor

@sj26 sj26 commented Jun 9, 2018

I figured out #927.

Babel seems to mutate config. More specifically, presets seem to append plugins every time babel is run. Because the asset caches asset.package, when using a package config like asset.package.babel, babel mutates the cached package config. Next time it needs the config it gets the same config, and mutates it again.

Instead, if loading config using a packageKey, clone the config before returning so mutations won't be persisted on the cached copy.

Babel seems to mutate the passed-in config, so if we pass in the
package.babel directly it will mutate the package config, then the next
time it compiles the same file it will have duplicate plugins, etc.

Instead, if loading config from a packageKey, clone the config before
returning so it can't be mutated.
@codecov-io
Copy link

Codecov Report

Merging #1515 into master will decrease coverage by 0.22%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1515      +/-   ##
==========================================
- Coverage   89.21%   88.99%   -0.23%     
==========================================
  Files          80       80              
  Lines        4403     4660     +257     
==========================================
+ Hits         3928     4147     +219     
- Misses        475      513      +38
Impacted Files Coverage Δ
src/Asset.js 99.19% <50%> (ø) ⬆️
src/utils/loadPlugins.js 64.28% <0%> (-26.2%) ⬇️
src/visitors/fs.js 78.1% <0%> (-14.6%) ⬇️
src/assets/PugAsset.js 88.57% <0%> (-11.43%) ⬇️
src/assets/JSONAsset.js 84.61% <0%> (-8.72%) ⬇️
src/utils/localRequire.js 94.11% <0%> (-5.89%) ⬇️
src/assets/LESSAsset.js 92.53% <0%> (-4.61%) ⬇️
src/utils/config.js 88.4% <0%> (-2.9%) ⬇️
src/assets/VueAsset.js 86.82% <0%> (-0.96%) ⬇️
src/assets/SASSAsset.js 78.75% <0%> (-0.8%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40fb76f...f90b979. Read the comment docs.

@DeMoorJasper DeMoorJasper merged commit eda41e1 into parcel-bundler:master Jun 9, 2018
@sj26
Copy link
Contributor Author

sj26 commented Jun 9, 2018

So quick! Thanks. 🙇🏻‍♂️

@sj26 sj26 deleted the fix-package-babel-config branch June 9, 2018 08:50
devongovett pushed a commit that referenced this pull request Oct 15, 2018
Babel seems to mutate the passed-in config, so if we pass in the
package.babel directly it will mutate the package config, then the next
time it compiles the same file it will have duplicate plugins, etc.

Instead, if loading config from a packageKey, clone the config before
returning so it can't be mutated.
devongovett pushed a commit that referenced this pull request Oct 15, 2018
Babel seems to mutate the passed-in config, so if we pass in the
package.babel directly it will mutate the package config, then the next
time it compiles the same file it will have duplicate plugins, etc.

Instead, if loading config from a packageKey, clone the config before
returning so it can't be mutated.
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

Successfully merging this pull request may close these issues.

3 participants