【发布时间】:2020-09-08 11:34:43
【问题描述】:
我正在处理Arrow 项目,我正处于使用Webpack 创建Bundle 文件的阶段。
我将modules 分组到一个文件夹中。对于每个文件夹,我都有index.js 导出所有模块。
另外,我有全局 index.js 可以像这样导入所有 index.js:
import * as Has from "./scripts/array/has"
import * as Math from "./scripts/array/math"
import * as Arrow from "./scripts/array"
export { Has, Math, Arrow }
现在,我想从这个全局 index.js 创建我的包。
我的Webpack 配置如下:
const path = require("path")
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
module.exports = {
mode: "development",
entry: {
arrow: "./src/1.x.x/index",
},
plugins: [
new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),
],
devtool: 'inline-source-map',
devServer: {
contentBase: './build',
},
output: {
filename: "[name]-alpha.js",
path: path.resolve(__dirname, 'build'),
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
}
问题是当我尝试从 build 导入我的函数时,这些函数没有出现在 Autocomplete 中,并且我收到了这些函数是 @987654332 的错误@!
我只有___esModule:
import { __esModule } from "./arrow-alpha"
我想让开发者使用和导入像example这样的函数
import {omit} from "arrow" // arrow is the bundled file
const frameworks = ["react", "vue", "ember", "angular"];
const withoutAngular = omit(frameworks,"angular");
console.log(withoutAngular); // ["react", "vue", "ember"]
我在此步骤中阻止了几天,但我无法弄清楚问题所在。
【问题讨论】:
标签: javascript webpack