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

Optional chaining issue #2024

Closed
anthify opened this issue Oct 12, 2017 · 7 comments
Closed

Optional chaining issue #2024

anthify opened this issue Oct 12, 2017 · 7 comments

Comments

@anthify
Copy link

anthify commented Oct 12, 2017

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.

@Hypnosphi
Copy link
Member

Hypnosphi commented Oct 13, 2017

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

There’s 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

@stale
Copy link

stale bot commented Nov 27, 2017

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!

@stale stale bot added the inactive label Nov 27, 2017
@stale
Copy link

stale bot commented Dec 13, 2017

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!

@asmyshlyaev177
Copy link

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

@shilman
Copy link
Member

shilman commented Feb 13, 2020

@Hypnosphi any thoughts on this in 2020? 😅

@Hypnosphi
Copy link
Member

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

@asmyshlyaev177
Copy link

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

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

5 participants