How to export imported object in ES6?

后端 未结 5 470
孤城傲影
孤城傲影 2020-12-07 06:55

The use case is simple: I just want to export an object with the name just as it was imported.

for example:

import React from \'react\';
export React         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 07:30

    For my use case, I explicitly need some sort of explicit import statement so that babel can transpile my es7 code to es5.

    The following results in an error You gave us a visitor for the node type "ForAwaitStatement" but it's not a valid type:

    require( 'babel-core/register' ); //transpiles es7 to es5
    export {default} from './module_name'
    

    My solution was to explicitly import the module by using require():

    require( 'babel-core/register' );
    export default require( './module_name' ).default;
    

提交回复
热议问题