Я пытаюсь отреагировать на проект с помощью этого webpack.config.js:
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
mode: "production",
entry: "./app/src/plugin.js",
output: {
filename: "build/static/js/bundle-project.min.js",
libraryTarget: "commonjs"
},
node: {
fs: "empty"
},
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.svg$/,
loader: "svg-inline-loader"
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: "url-loader?limit=100000"
},
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: "babel-loader",
options: {
presets: ["@babel/preset-react", "@babel/preset-env"],
plugins: [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-modules-commonjs"
]
}
}
]
},
plugins: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6
}
})
],
resolve: {
alias: {
utils: path.resolve("./src/utils"),
"user-abilities": path.resolve("./src/user-abilities"),
shared: path.resolve("./src/shared"),
components: path.resolve("./src/components"),
store: path.resolve("./src/store")
}
},
externals: {
react: "commonjs react"
}
};
тогда я делаю npm, публикую и импортирую пакет в другой проект
используя
импорт Main из @ my-repo-package
Я получаю эту ошибку при попытке отрисовки пакета в другом проекте:
![enter image description here](https://i.stack.imgur.com/jn8va.png)