fix: smarter handling of user's babel plugins & presets#613
Open
justjake wants to merge 7 commits intocallstack:masterfrom
Open
fix: smarter handling of user's babel plugins & presets#613justjake wants to merge 7 commits intocallstack:masterfrom
justjake wants to merge 7 commits intocallstack:masterfrom
Conversation
Author
|
I believe the test failure is spurious; it seems to be timing-related and I can't reproduce it locally. |
Author
|
I published this branch as https://www.npmjs.com/package/@jitl/linaria for testing purposes. |
Contributor
|
Thanks for tackling this one @justjake . I'm surprised the only reply yet has been from a bot because I've been stuck on this #612 too. Sourcing your build library, I got a different error: console outputHere's my Babel presets config: [
'@babel/preset-env',
{
modules: false,
loose: true,
useBuiltIns: 'usage',
corejs: 3,
},
],
'@babel/preset-typescript',
'@babel/preset-react',
'@jitl/linaria/babel', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Users should have as much control as possible about the plugins in Linaria's babel pipeline.
Current issues:
shakeralways specifies thepreset-envpreset, which can lead to babel duplicate plugin issues if the user also specifiedpreset-env.Summary
Instead of blindly unshifting PluginItem specifiers to babel's
pluginsandpresetsarrays, instead check for the presence of the plugin, and if present, merge existing user-specified plugin options and the options that Linaria requires..Options are merged like
{ ...userPluginOptions, ...linariaPluginOptions }, to always prefer the linaria options in case of conflict.Test plan
I created a reproduction for #612, seen here: https://github.com/justjake/linaria-babel-options-issue-repro
linariaat from this branch. Runyarn buildinlinariaaction = extractor-> build now succeeds!action = shaker-> build now succeeds!I should also test the new version of Linaria with example integrations in the community, such as the nextjs-linaria example.
This is somewhere between a bug-fix and a new feature. The change has the potential to break existing configs in subtle ways, if user options start being respected. So, maybe consider for inclusion in 2.0.0?