Storybook: Optional chaining issue

Created on 12 Oct 2017  路  7Comments  路  Source: storybookjs/storybook

Hey,

I added a .babelrc to the .storybook directory, installed babel-plugin-transform-optional-chaining, and added this to the .babelrc.

{
  "presets": ["env", "stage-0", "react"],
  "plugins": [
    ["transform-runtime", {
      "polyfill": false,
      "regenerator": true
    }],
    "transform-optional-chaining"
  ]
}

The above config is just lifted from the one in the storybook repo. I played around and experimented with a few different solutions but I couldn't get it to work. On each load it would see the use of obj?.prop?.otherProp and throw Module build failed: SyntaxError: Unexpected token.

package.json

  "dependencies": {
    "@storybook/react": "^3.2.12",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "styled-components": "^2.2.1"
  },
  "devDependencies": {
    "babel-plugin-transform-optional-chaining": "^7.0.0-alpha.13.1",
    "eslint": "^4.8.0",
    "eslint-config-prettier": "^2.6.0",
    "eslint-plugin-prettier": "^2.3.1",
    "eslint-plugin-react": "^7.4.0",
    "prettier": "^1.7.4"
  }

I'm hoping it's something simple I'm missing as it would be a very useful feature for my current project. Thanks.

compatibility with other tools needs reproduction question / support

Most helpful comment

@Hypnosphi any thoughts on this in 2020? 馃槄

All 7 comments

This transform uses syntax which is only parseable by babel version 7. It鈥檚 still in beta, so we use version 6 for now.

There鈥檚 a chance you can work it around by using webpack config full control mode with your own babel-loader. Please tell us if you have any success with that

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!

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!

It is still actual, i wanna enable this via babel, but can't get it work with storybook

@Hypnosphi any thoughts on this in 2020? 馃槄

@asmyshlyaev177
Can you please create a GitHub repo with minimal reproduction of your issue?

@Hypnosphi we use custom webpack config, as i see plugin didn't added to final webpack config.

Was this page helpful?
0 / 5 - 0 ratings