I've found a lot of stuff about "Unexpected character '@'" happening with webpack, but none of it related specifically to, or helpful with, getting that error for the externals webpack option. I've used this before, both with and without @-signs, without any trouble, so I don't know why webpack is getting cranky now.
const TerserPlugin = require('terser-webpack-plugin');
module.exports = () => {
return {
mode: 'production',
target: 'node',
entry: './build.ts',
output: {
path: __dirname,
filename: `build.js`
},
node: {
__dirname: false,
__filename: false,
},
resolve: {
extensions: ['.ts', '.js'],
mainFields: ['es2015', 'module', 'main', 'browser']
},
module: {
rules: [
{
test: /\.ts$/i,
loader: 'ts-loader',
options: { configFile: 'tsconfig-build.json' },
exclude: [/\/node_modules\//]
}
]
},
externals: ['chalk', '@tubular/util'],
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
mangle: false,
output: { max_line_len: 511 }
}
})],
},
};
};
The @ is a necessary part of the package name that I want to exclude, and I've exclude such packages before, so this is both mysterious and annoying.
Anyone have any idea what's wrong here?