如何将Babel设置为从Y`语法使用ES2015`export *作为X?

我只想使用以下语法:

export * as Utils from './utils';

但是Babel表示无法解析此行:

Module parse failed: Unexpected token (4:9)
File was processed with these loaders:
 * ../node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.

好像transform-export-extensions应该可以做我想要的,但不是。


我使用最新的babel 7和webpack 4

我的.babelrc

{
    "presets": [
        "@babel/preset-react","@babel/preset-env"
    ],"plugins": [
        "transform-export-extensions",]
}

在webpack配置中,我有:

...
    module: {
        rules: [
            {
                test: /\.js$/,use: {
                    loader: 'babel-loader'
                },exclude: /node_modules/
            },...
kkaren 回答:如何将Babel设置为从Y`语法使用ES2015`export *作为X?

我最后只是

import * as Utils from './utils';
export {Utils};
本文链接:https://www.f2er.com/3073645.html

大家都在问