Storybook: Failure parsing .babelrc with comments

Created on 11 Apr 2016  路  2Comments  路  Source: storybookjs/storybook

Comments can apparently be used in .babelrc files, as is done in react-redux-starter-kit, like so:

// foo bar biz baz
{
  "presets": ["es2015", "react", "stage-0"],
  "plugins": ["transform-runtime"]
}

Storybook parses .babelrc configuration somewhere and fails when it encounters //.
It's easy to work-around (remove the comments):

start-storybook -p 9001

=> Using custom .babelrc configurations.
=> Error parsing .babelrc file: Unexpected token /

However, Babel allows comments in its config, so Storybook should probably expect to encounter them, right?

bug

Most helpful comment

Just a note on this - since this shows up in Google - babel uses json5 rather than cjson.

json5 is a little more liberal and supports unquoted keys, single quotes, trailing commas, etc. So if you're using cjson you may still have issues with valid babelrc files.

All 2 comments

yes. We should use cjson parser I guess.

This is the place we should do it. See: https://github.com/kadirahq/react-storybook/blob/master/src/server/config.js#L18

I am open to PRs for this.

Just a note on this - since this shows up in Google - babel uses json5 rather than cjson.

json5 is a little more liberal and supports unquoted keys, single quotes, trailing commas, etc. So if you're using cjson you may still have issues with valid babelrc files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wahengchang picture wahengchang  路  3Comments

Jonovono picture Jonovono  路  3Comments

arunoda picture arunoda  路  3Comments

alexanbj picture alexanbj  路  3Comments

miljan-aleksic picture miljan-aleksic  路  3Comments