-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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/12745 babel config loading #15628
Conversation
Nx Cloud ReportCI ran the following commands for commit a5a58a6. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 from NxCloud. |
…hat it got from the file, if no file return null perform or operation in the common-preset, determines the default babel config object
If your project has a `.babelrc` file, we'll use that instead of the default config file. | ||
|
||
You can also place a `.storybook/.babelrc` file to use a special configuration for Storybook only. | ||
If your project has a `.storybook/.babelrc` file, we'll use that instead of the default config file. |
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.
According to the code https://github.com/storybookjs/storybook/blob/next/lib/core-common/src/utils/load-custom-babel-config.ts#L79 there are more filenames considered for loading in the .storybook
folder
- .babelrc
- .babelrc.json
- .babelrc.js
- babel.config.json
- babel.config.js
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.
Important to note as well that the recommended setting for Babel 7 is to use babel.config.json
, lots of people are renaming their configuration file so it would be nice indeed to see that extension in the docs
Ref: https://babeljs.io/docs/en/config-files#6x-vs-7x-babelrc-loading
@@ -48,10 +49,16 @@ function loadFromPath(babelConfigPath: string): TransformOptions { | |||
throw error.js; | |||
} | |||
|
|||
config = { ...config, babelrc: false }; | |||
if (config instanceof Function) { | |||
config = config(); |
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.
Calling the config function without an argument could be problematic. Babel calls the function with an api
object https://babeljs.io/docs/en/config-files#config-function-api
In my opinion it is ok to stub that api and make sure that calls to the methods don't fail. The env
method should be easy to reimplement.
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@ndelangen I believe we fixed this with the Closing this for now. Please let me know if there's more to be done here! |
Issue: #14425 #2758 #12745 #15502
What I did
How to test
.storybook/babel.config.ts
which exports a function (returning valid babel config)main.js
with valid babel config ( a function that takes config and returns changed config)main.js
overridingbabel.config.ts
; the default config is not used