Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 712
Praveen Kumar Avatar asked Aug 17 '18 04:08

Praveen Kumar


2 Answers

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

like image 107
LiebeCR Avatar answered Nov 17 '22 14:11

LiebeCR


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.

like image 34
yozosann Avatar answered Nov 17 '22 14:11

yozosann