I have an electronic application that I create using Webpack 2. I have a custom module ( mymodule) that I want to be a standalone package referenced by other packages. The problem is that when I use CommonsChunkPluginwith my main process, the electron is blocked when the application starts. I see that the electronic logo appears in the document, but the window never appears.
Please note that it should not be the module that I wrote, I can use lodashwith CommonsChunkPluginand get the same result.
Interestingly, if I use CommonsChunksPluginwith the visualization process in the same way, everything works fine.
I put together a simple electronic application that shows this problem.
Github repo gives more detailed information about the situation, but here are the important parts:
basic electron process:
const mymod = require('./mymodule')
app.on('ready', function() {
console.log(mymod.abc);
mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadURL(url.format({
pathname: require('./index.html')
}));
});
Webpack configuration for main:
entry: {
main: path.join(__dirname, './main.js'),
mymod: ['./mymodule']
},
output: {
path: __dirname + '/build/',
publicPath: __dirname + '/build/',
filename: '[name].bundle.js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('mymod')
]
In this state, the application will not work. If you go to the file webpack.main.jsand comment out the usage CommonsChunkPluginin these lines, it will start working:
entry: {
main: path.join(__dirname, './main.js'),
},
output: {
path: __dirname + '/build/',
publicPath: __dirname + '/build/',
filename: '[name].bundle.js'
},
plugins: [
]
Here is my environment information:
MacOS: 10.12.6
node: v6.11.0
npm: 3.10.10
electron: v1.6.12
wepback2: 3.5.5
So what is going on here? Is this a bug with electron, webpack or my code?