Javascript 使用网页包生成

Javascript 使用网页包生成,javascript,webpack,Javascript,Webpack,我目前正在编写我的小型库,并使用webpack作为模块绑定器。我想要我的捆绑文件,并从中导入我的捆绑代码 My webpack.config.js: const path = require('path'); module.exports = (env = {}) => { const inProduction = env.production; const loaders = ['babel-loader']; if(!inProduction) loaders.push('eslin

我目前正在编写我的小型库,并使用
webpack
作为模块绑定器。我想要我的捆绑文件,并从中导入我的捆绑代码

My webpack.config.js:

const path = require('path');
module.exports = (env = {}) => {
const inProduction = env.production;
const loaders = ['babel-loader'];

if(!inProduction) loaders.push('eslint-loader');

return {
    entry: ['babel-polyfill', './index.js'],
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'build.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: loaders
            },

        ],
    },
    node : {
        fs : "empty",
        child_process : "empty",
        process : true
    },
    watch : true
}
};
我的
index.js

'use strict';

 import dotenv from 'dotenv';
 import QueueFacade from './src/PriorityQueueFacade';


 dotenv.config({ silent: true });

 export default QueueFacade;
我现在的目标是能够像
const q=require('build.js')
那样要求它,然后创建一个新实例,作为
const queue=new q(params)
。因此,它就像我们使用的任何其他库一样

问题是,在运行
webpack build
并尝试运行上面的代码之后,我得到了错误
q不是一个函数


我如何调整或导入/导出以构建一个工作产品构建?

您知道如何使用任何语言的
new
关键字workds,以及应该在哪些语言上使用new吗?小提示:classes@PlayMa256是的,我知道。我从其他模块导入一个ES6类。