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

Fails when loading custom .babelrc from a scoped dependency #1095

Closed
NameFILIP opened this issue May 22, 2017 · 6 comments
Closed

Fails when loading custom .babelrc from a scoped dependency #1095

NameFILIP opened this issue May 22, 2017 · 6 comments

Comments

@NameFILIP
Copy link

My my-project/.babelrc contains:

{
  "extends": "@my-scope/tasks/.babelrc",
  ...
}

When I run yarn storybook, I receive a message:

ERROR in ./.storybook/config.js
Module build failed: Error: [BABEL] /Users/myusername/Dev/my-project/.storybook/config.js: Couldn't resolve extends clause of /Users/myusername/Dev/my-project/@my-scope/tasks/.babelrc in base
    at Logger.error (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/file/logger.js:41:11)
    at ConfigChainBuilder.mergeConfig (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:186:32)
    at buildConfigChain (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:64:11)
    at OptionManager.init (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:354:58)
    at File.initOptions (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/file/index.js:212:65)
    at new File (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (/Users/myusername/Dev/my-project/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/Users/myusername/Dev/my-project/node_modules/babel-loader/lib/index.js:46:20)
    at Object.module.exports (/Users/myusername/Dev/my-project/node_modules/babel-loader/lib/index.js:163:20)
 @ multi preview

As you can see, it's looking for the .babelrc in my-project/@my-scope/tasks/.babelrc while it should be looking it in the node_modules: my-project/node_modules/@my-scope/tasks/.babelrc

@NameFILIP
Copy link
Author

A workaround for this is to change the extends property to:

{
  "extends": "./node_modules/@my-scope/tasks/.babelrc",
  ...
}

but it would be nice to fix the issue.

@ndelangen
Copy link
Member

I'm super glad you found a work-around that works for you.

We're gonna fix this, thanks for reporting!

@zeroasterisk
Copy link

I too am having this problem in a Meteor project.

I've been renaming the .bablerc file when starting storybook, which is a terrible plan.

In a meteor application, there is no .babelrc file... it's handled inside meteor... but it now respects the .babelrc file, and storybook's file is "messing up" meteor.

@ndelangen
Copy link
Member

@zeroasterisk Sorry this isn't super high on our roadmap, I think it could be quite complicated to solve, but of course anyone is open to try. So if you want, a PR is welcome!

I can think of a method to fix your problem I think: Place your storybook next to (outside of) your meteor src-folder?

@ndelangen ndelangen removed this from the v3.1.4 milestone Jul 26, 2017
@danielduan
Copy link
Member

danielduan commented Aug 27, 2017

you can also try using require.resolve('babel-plugin-name') in the .babelrc as well.

In general, the project root .babelrc file should not be respected because of the issue mentioned here. https://github.com/storybooks/storybook/blob/master/app/react/src/server/config/babel.js#L3

Please reopen if this is still a problem.

@likethemammal
Copy link

I came here cus the .babelrc react-static creates uses extends and causes this issue with storybook. For other ppl that land here for the same reason, the workaround from @NameFILIP worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants