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
Fixed useBuiltIns and modules validation when using 'false' as option #11373
Fixed useBuiltIns and modules validation when using 'false' as option #11373
Conversation
@JMarkoski thanks for the PR, and congrats on your first contribution 🙏! can we add a test for this here? |
…Option' when input is 'false'
@existentialism Thanks, I'm very happy to contribute! I've added the missing tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@JMarkoski great job! |
Is this considered a breaking change? I notice that for our application, we now have a bunch of broken builds because we aren't setting this property explicitly. Even more troublesome is that for dependencies that we need to transpile, we also run into this issue because their local babel-config files take precedence over the application specific configurations. In our builds we now see the following errors:
Our babel config looks as follows: module.exports = {
presets: [['@babel/preset-env', { modules: true }], '@babel/preset-react']
}; |
Per https://babeljs.io/docs/en/babel-preset-env#modules, preset-env never accepts Besides, the only behaviour change introduced in this PR is throwing on Should you have more questions, please submit a new issue. Thanks. |
Also, just to add, you say that you don't set the option explicitly, but in the configuration you set it to |
Eee sorry, that was a mistype, from me trying to debug the issue. Our actual config is: module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react']
}; Previously we were on @babel/preset-env@7.8.7 -- when we upgraded to @babel/preset-env@7.9.5 we started seeing the error above. |
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react']
}; In the config above,
Can you share their local babel config files? Or better can you construct a reproduction repo? This can greatly help investigate the issues. |
Their local file looks as follows: {
"presets": ["es2015", "react", "stage-2"],
"compact": false,
"env": {
"test": {
"plugins": ["transform-runtime"],
"sourceMaps": "both"
}
}
} I can try to construct a reproducible repo. Curious is the assumption of "auto" a new behavior, or has it always been this way? |
It's also interesting to note, that if I comment out the line check in
|
I can confirm that the issue doesn't happen in our source code, and that the error only happens because one of our dependencies is relying on a previous version of the babel libraries (as you can see from the above config). Is it possible that this change causes an unexpected issue for our (admittedly odd) use-case? Unfortunately, we don't have access to change their code to use a newer version of babel. |
I can confirm that Apart from that, I don't know what might be the issue, can you construct a reproduction repo to investigate further? |
I've tried to build a minimally reproducible version but it's tough since many of the packages (including dev dependencies) are private. However, in my debugging to see what "value" is causing the problem, I updated the error statement to include some extra information. It looks like it's throwing, but that the value it's getting is correct? It seems to be "false", of type string, which should be allowed? Invariant Violation: [BABEL] /Users/bcripps/indeed/mosaic-provider-base-nodejs/node_modules/@indeed/frontend-components-react/components/Modal/index.js: Invalid Option:
ArgValue: false
TypeOf Arg: string
The 'modules' option must be one of
- 'false' to indicate no module processing
- a specific module type: 'commonjs', 'amd', 'umd', 'systemjs' - 'auto' (default) which will automatically select 'false' if the current
process is known to support ES module syntax, or "commonjs" otherwise |
Then this is the expected behavior. This PR fixes exactly this issue, where you specify |
Ah interesting! When I add this console.log('typeof moduleOpt ' + typeof modulesOpt) I see typeof moduleOpt string
typeof moduleOpt string
typeof moduleOpt string
typeof moduleOpt string
typeof moduleOpt string
typeof moduleOpt string
typeof moduleOpt string
typeof moduleOpt string but none of our configs specify this parameter at all? Do you know what might be converting it to "false"? |
I found it! We have some (🤦) internal build code that's injecting a string value :/ Thank you so much for your help in debugging this! |
Great! You are welcome, I am very glad if I helped. |
Fixes the case when 'false' as string is provided for
useBuiltIns
ormodules
option by not converting the supplied option to string when it's 'false', and comparing it directly.