-
-
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
Support for .babelrc.js
#2582
Comments
another example: jest currently reimplements same logic: https://github.com/facebook/jest/blob/master/packages/babel-jest/src/index.js#L29 adding it as an export from babel-core makes sense |
What's your use case for reading the config file on your own? Why don't you leverage built-in mechanism in babel? |
We need to do some tweaks with config after parsing: |
What I have identified (correct me if im wrong) as your use cases:
From what I understand the latter could be achieved by simply providing an additional plugin here and let babel merge those (it will do this unless u specify Im not sure how to solve first without reimplementing |
I also see that you duplicate this logic quite a lot between all |
This sounds like a good solution to me. Would you try to open a PR implementing that?
Yeah, there's an ongoing work on extracting common parts (#2240), and any help is welcome |
The problem is that it's probably not worth it as there is a "default" config requirement too. I'd like to understand its use cases more first. Other than that, I'm willing to put up a PR fixing this one way or another. |
The use case for default config is simple: stories files are written in es6 and jsx by default, and they should work even for users that don't have their own Babel config (e.g. the ones who use Create React App) |
Looks like this merge will not be done by babel itself, but by What we want, is to be able to find babel configuration for the project in some specified folder. And then internally we can enhance it any way we need. But it's best if original config read logic comes from one of the main Looks like they have quite elaborate functionality in |
@eur00t you can try to replace the default babel-loader with your own (which can be version 8)
If you’re using addon-info, you may need to add |
It seems that By default if you specify .babelrc and use CLI with something like: babel src --out-dir lib --plugins some-plugin It will use both babelrc and extra plugin. I wouldnt expect this to be a standard behaviour for all ways of calling underlaying JS
I'd argue that it's better to rely on babel to "enhance" the config, unless there is a reason not to - i.e. if babel doesn't allow for something, but even then you should file an issue for us at babel, so we can discuss possibilities. We'd like to support all reasonable use cases in the core. Also the problem at the moment will be that we can create a new nice APIs for you to use for babel@7, but its semantics will differ from babel@6 and it might not be perfect to use babel@7 logic to get babel@6 configs - OTOH they might not differ that much.
Thanks for info. Will look into how CRA handles babel under the hood. |
@Hypnosphi yeap, that's one way of making it work. For now, I just have |
(Looks like the same is also in |
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 60 days. Thanks! |
Oh, I've wanted to contribute to this, but couldn't find time for it, also it might be good to delay implementation until babel@7 gets out, there is a high chance that it will have some nice API for config loading that we could utilize here |
Where can I read more about this? |
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! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
Hey just curious will this be handled in the Babel 7 upgrade? If not, is the recommendation that if your project uses |
AFAIK it was not handled. @Hypnosphi fix me if I am wrong.
As a workaround - yes. |
I'd say the best workaround was and still is to have a custom webpack.config.js with your own instance of babel-loader |
@Hypnosphi one of your original suggestions of putting a .babelrc in the .storybook directory and then having a seperate .babelrc.js for other purposes like testing/build works well for me. Is there plans to officially recommend this in the docs? |
I haven't heard about such plans |
Released as |
Issue details
Currently
@storybook/react
only looks for Babel configuration in.babelrc
file:https://github.com/storybooks/storybook/blob/d63bf65afa75f2f6f4c0f63b0fedb990a8ea98d0/app/react/src/server/babel_config.js#L48
In
@babel/core
they support more configuration sources (.babelrc.js
,.babelrc
,package.json
):https://github.com/babel/babel/blob/7d798952d2a305cf77d24d1707f723f0a162aadd/packages/babel-core/src/config/files/configuration.js#L29
Looks like the functionality of reading Babel configuration is common enough to be extracted into its own package. I guess it's not good enough just to reimplement the same logic in Storybook repo. Or we can just use Babel's internals – though it will be not easy to maintain down the road.
Any thoughts?
Steps to reproduce
.babelrc.js
file.@storybook/react
with something likestart-storybook -p 9001 -c .storybook
..babelrc.js
is ignoredExpected behaviour: Storybook reads Babel configuration from
.babelrc.js
file.Please specify which version of Storybook and optionally any affected addons that you're running
Affected platforms
babel-loader 7.1.2
babel-core ^7.0.0-0
@babel/core 7.0.0-beta.34
The text was updated successfully, but these errors were encountered: