I have cross-browser extension (currently running it on Chrome and Firefox) build with typescript and compiled with webpack. I wanted to use code-splitting to reduce the size of the bundle. However when I enable code-splitting in the webpack config, extension is not working. In the background script there is a browserAction listener that will open the login page if there is no user. Or if user is logged in, popup will show up. However clicking the browser action icon do nothing. No error messages will show up in background script. No login window or popup will show up.
Here is to config part I'm having problem with. When I comment this part out and do not code-split everything is working fine.
module.exports = {
mode: 'development',
entry: {
login: path.join(__dirname, './src/js/login.ts'),
popup: path.join(__dirname, './src/js/popup.ts'),
options: path.join(__dirname, './src/js/options.ts'),
background: path.join(__dirname, './src/js/background.ts'),
},
output: {
path: path.join(__dirname, './dist'),
filename: 'js/[name].js'
},
// When I remove this part extension is working
optimization: {
splitChunks: {
name: 'vendor',
chunks: "initial"
}
},
module: {
...
Any idea why is this happening and how can I make it work? In the result vendor chunk, there are mainly node_modules dependencies (firebase, ramda etc.) used by several entry points of the extension.
Thank you for help.