Webpack 仅从 ES6 类构建一堆空的 Weakmaps 和 Weaksets

问题描述

我写了一个小型的 javascript 库。 现在测试已经写好,我想发布它。

但是 webpack 只是没有以正确的方式构建它:

(() => {
    "use strict";
    require("regenerator-runtime/runtime"),require("lodash"),new WeakMap,new WeakSet,new WeakSet
})();

这就是我从 library code 中得到的。

这是我的webpack.config.js

const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');


module.exports = {
    mode: 'production',// plugins: [new webpack.Progressplugin()],// target: 'node',externals: [nodeExternals()],entry: './src/Whisk.js',output: {
        filename: 'whisk.min.js'
    },module: {
        rules: [{
            test: /\.(js)$/,exclude: /node_modules/,loader: 'babel-loader',options: {
                presets: [
                    ['@babel/preset-env']
                ],plugins: [
                    "@babel/plugin-proposal-class-properties","@babel/plugin-proposal-private-methods"
                ]
            }
        }]
    },}

当我用 jest 测试我的代码时,它与这个 babel 插件配合得很好。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)