Javascript 无法在带有webpack 4和babel 7的react应用程序中导入jsx模块

Javascript 无法在带有webpack 4和babel 7的react应用程序中导入jsx模块,javascript,reactjs,webpack,babeljs,Javascript,Reactjs,Webpack,Babeljs,在阅读了几乎所有与这个主题相关的答案后,我运气不佳,因此不得不提出一个新问题 问题陈述: 我有一个库模块,我想在我的react应用程序中导入,该应用程序具有类似于在另一个应用程序中工作的导出语法: export * from './button'; // this returns jsx component 现在,在我的应用程序中,我将其用作: import {button} from ./library; // this is the bundled module where button

在阅读了几乎所有与这个主题相关的答案后,我运气不佳,因此不得不提出一个新问题

问题陈述:

我有一个库模块,我想在我的react应用程序中导入,该应用程序具有类似于在另一个应用程序中工作的导出语法:

export * from './button'; // this returns jsx component
现在,在我的应用程序中,我将其用作:

import {button} from ./library; // this is the bundled module where button component exists. 
当我这样做时,此网页会给我一个错误:

(function (exports, require, module, __filename, __dirname) { export * from './button';
                                                              ^^^^^^
SyntaxError: Unexpected token export
如前所述,我使用Webpack 4和babel 7进行以下配置:

webpack.config.js

//这是出口

module.exports = {
    entry: {
        client: ['whatwg-fetch', './client/index.js', 'webpack-hot-middleware/client']
    },
    optimization: {
        minimizer: [new OptimizeCSSAssetsPlugin({})]
    },
    output: {
        path: path.resolve(__dirname, `dist/client/${pkg.version}`),
        filename: '[name].js',
        publicPath: `/myApp/${pkg.version}`
    },
    devtool: ifProduction('nosources-source-map', 'source-map'),
    resolve: {
        modules: [path.resolve('./client'), path.resolve('./node_modules')]
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.less$/,
                use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader']
            },
            {
                test: /\.(ttf|eot|svg|woff|woff2?)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: 'file-loader?name=fonts/[name].[ext]'
            },
            {
                test: /\.(png|jpg|ico|svg|eot|ttf)$/,
                loader: 'url-loader'
            }
        ]
    },
    mode,
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new MiniCssExtractPlugin(),
        new BundleAnalyzerPlugin({
            analyzerMode: 'static',
            openAnalyzer: false,
            reportFilename: '../report.html'
        })
    ]
};
babel.config.js

我不确定出了什么问题,任何帮助都将不胜感激


谢谢。

这不是有效的语法

export * from './button';
您需要列出您导出的内容

export {button} 


好吧,我不认为它会一直持续到那个里,问题是它告诉我们导出是一个无效的语法。
export {button} 
export default button