I'm migrating from rollup to webpack.
I'm building js bundles for browser from some main typescript entry files. The bundles are self-contained and don't require additional dependency loading from them (dependencies are loaded using html script tags).
Rollup did simple bundles, no code overhead (concatenate-like).
With webpack, I'm seeing a log of junk code and I get errors in browser:
Uncaught ReferenceError: require is not defined.
Adding the following code seems to solve the errors, but I still see required( method calls in junk code:
optimization: {
runtimeChunk: 'single'
}
My configuration:
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: {
home: './src/Home.ts',
...
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'build/public'),
},
externals: [nodeExternals()],
optimization: {
runtimeChunk: 'single'
}
};
Why is there so much code overhead, what's the purpose? Can I remove it somehow?