Я использую пакет @ shopify / polaris и, похоже, моя сборка завершается с ошибкой с сообщением об ошибке:
ERROR в vendor.file.bundle. js от Uglify Js Неожиданный токен: каламбур c «,» [./node_modules/@shopify/polaris/index.es.js:1043,0 ]
Когда Я проверил файл ./node_modules/@shopify/polaris/index.es.js в строке 1043, похоже, он жалуется на следующее:
console.warn(i18n.translate('Polaris.Icon.backdropWarning', {
color, // It seems to complain about this on line 1043.
colorsWithBackDrops: COLORS_WITH_BACKDROPS.join(', ')
}));
Я использую webpack 4. Ниже моя конфигурация:
const path = require('path');
const config = {
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, '/public/js'),
filename: 'file.bundle.js',
chunkFilename: 'vendor.file.bundle.js'
},
resolve: {
extensions: ['.js', '.json', '.ts', '.tsx', '.css', '.scss'],
},
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
{
test: /\.tsx?$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'initial',
enforce: true
}
}
}
},
{
mode: 'production',
plugins: [
new UglifyJsPlugin({
sourceMap: true
}),
new webpackProd.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new CompressionPlugin({
filename: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.ts$/,
threshold: 10240,
minRatio: 0.8
}),
new webpackProd.IgnorePlugin(/^\.\/locale$/, /moment$/),
]
}
};
module.exports = config;
![enter image description here](https://i.stack.imgur.com/yVuNo.png)