This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'
Asked Answered
S

2

7

This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'

I am getting the above error while trying to move the entire application from react v15.6to v16.2, by using the migration tool from facebook like jscodeshift.

Seraphine answered 17/8, 2018 at 4:44 Comment(3)
It is a known issue github.com/facebook/jscodeshift/issues/252Gosling
amazing what you can find by simply using a search engine on the exact title of the question!Reasoned
Possible duplicate of Babel's TypeScript parsing is not consistentSeraphine
C
2

Add @babel/plugin-proposal-export-default-from (https://git.io/vb4yH) to the 'plugins' section of your Babel config to enable transformation.

Caparison answered 10/9, 2018 at 19:48 Comment(0)
A
2

I solved this problem.

const parser = require('./src/parser');
const jscodeshift = require('jscodeshift').withParser(parser);

./src/parser:

'use strict';

const babylon = require('babylon');

// These are the options that were the default of the Babel5 parse function
// see https://github.com/babel/babel/blob/5.x/packages/babel/src/api/node.js#L81

const options = {
  sourceType: 'module',
  allowHashBang: true,
  ecmaVersion: Infinity,
  allowImportExportEverywhere: true,
  allowReturnOutsideFunction: true,
  plugins: [
    'estree',
    'jsx',
    'asyncGenerators',
    'classProperties',
    'doExpressions',
    'exportExtensions',
    'functionBind',
    'functionSent',
    'objectRestSpread',
    'dynamicImport',
    'nullishCoalescingOperator',
    'optionalChaining',
    'exportDefaultFrom'
  ],
};

/**
 * Wrapper to set default options
 */
exports.parse = function parse (code) {
  return babylon.parse(code, options);
};

Please add the 'exportDefaultFrom' into plugins.

Alecalecia answered 13/11, 2018 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.