Docz: Unable to customize babel plugins with actions.setBabelPlugin

Created on 19 Sep 2019  路  5Comments  路  Source: doczjs/docz

Question

Unable to use any form of DocZ or Gatsby configuration to get an experimental syntax into my project (optionalChaining).

Description
I am trying to standup a new project and moving some existing components over to use DocZ. When I run yarn docz:dev I get the following error:

Syntax Error: SyntaxError: Support for the experimental syntax 'optionalChaining
' isn't currently enabled

What I've tried:

My package.json contains the the proper babel plugins used in other repos which correctly are bringing in the support for optionalChaining syntax.

I also have a .babelrc file in the root of my project which tries to bring in the optionalChaining plugin.

After running the yarn decz:dev command I get the same error, and searching through the entire built .docz folder I can't find any reference to @babel/plugin-proposal-optional-chaining other than in the gatsby-node.custom.js, I would expect it to get written into other places if it were applied correctly.

If you have any suggestions or ideas for me to try this other ways I'd love your feedback.

If nothing else, thank you for taking time out of your life to make this application and to answer questions and concerns.

bug fixed v2

Most helpful comment

Thanks @VigMed01 and @leggomuhgreggo for the repro.

The issue should be fixed in version 2.0.0-rc.43.

Could you try it out with the change @leggomuhgreggo suggested ?

All 5 comments

Hey @vigmed01

Thanks for reporting the issue.

Any chance you can provide a repo with a small repro of the problem so we can help debug/fix ?

Hi @rakannimer, here is a stripped down repo I just created to show the same issue. Thanks!
https://github.com/VigMed01/docz-issue-sample

FWIW I was able to recreate the issue.

From the demo repo

exports.onCreateBabelConfig = ({ actions }) => {
    actions.setBabelPlugin({
        name: `plugin-proposal-optional-chaining`,
    });
};

I tried changing the name to use the @babel/ prefix so:

exports.onCreateBabelConfig = ({ actions }) => {
  actions.setBabelPlugin({
    name: `@babel/plugin-proposal-optional-chaining`
  });
};

But no dice

Hope that's helpful

Thanks @VigMed01 and @leggomuhgreggo for the repro.

The issue should be fixed in version 2.0.0-rc.43.

Could you try it out with the change @leggomuhgreggo suggested ?

It works! Thank you very much for fixing! Thank you @leggomuhgreggo for confirming the issue.
Closing this with my comment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clock157 picture clock157  路  33Comments

maxguzenski picture maxguzenski  路  24Comments

molebox picture molebox  路  40Comments

mzedeler picture mzedeler  路  31Comments

PlayMa256 picture PlayMa256  路  24Comments