How to install plugin-export-default-from to Babel in react project
Asked Answered
H

2

6

I have been getting the following error constantly throughout this process

SyntaxError: /Users/user1/npmprojects/experiments/test-reactstrap0/src/components/index.js: Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled (15:8):

  13 | export * from './ListItems';
  14 | 
> 15 | export FormField from './FormField';

First I install the plugin: yarn add @babel/plugin-proposal-export-default-from --save-dev

I have also tried installing yarn add babel-preset-stage-1 --save-dev

I have tried adding a .babelrc file with the contents

{
  "plugins": [
    "@babel/plugin-proposal-export-default-from"
  ]
}

I have tried adding the following to my package.json

"babel": {
    "presets": [
    "es2015",
    "stage-1",
    "react"
  ],
  "plugins": [
    "@babel/plugin-proposal-export-default-from"
  ]
}
Hallvard answered 28/3, 2019 at 15:37 Comment(0)
S
0

There is an open issue in Babel about it: https://github.com/babel/babel/issues/7293

Looks like you'd additionally need to install @babel/plugin-proposal-export-namespace-from plugin, but not 100% sure, better read through the issue discussion and try the proposed workarounds.

Sweetener answered 28/3, 2019 at 21:47 Comment(0)
A
0

You can put the configuration in your babelrc.js file:

module.exports = {
  plugins: [
    "@babel/plugin-proposal-export-default-from"
  ]
}

Tools such as babel or babel-loader for Webpack will pick up the configuration from here.

Good Luck...

Appear answered 26/1, 2020 at 9:58 Comment(2)
doesn't seem to work. Have you tested this?Offen
Hi @Sisir, yes it worked back then when I used this in one of my projects.Appear

© 2022 - 2024 — McMap. All rights reserved.