electron javascript sqlite webpack

Webpack sequelize, sqlite3 error cannot find module sqlite3

I try to use sequelize and sqlite3 with electron and I have problems when using it with webpack.
To test the projects provided in my description do npm install before

Example 1 : I tried two projects one without webpack and it works well : The sqlite3 load correctly and write the data in the database. 

npm start will launch node_modules/.bin/electron . 

It launches the index.html that uses the index.js file:

Project 1 Structure

Example 2: I use webpack to compile the project because I use ES6 syntax (in the provided example the syntax is not ES6, it just to reuse the same file as in the example 1).

npm start will compile the index.js entry point and output a bundle.js file that is used by the index.html for the electron app.

Project 2 Structure

When I launch the second example, the index.html that load the bundle.js file compiled with webpack I have the error below:


To see the ERRRRR issss,

Unlike in the link provided which is not about using webpack with electron. The link is my Example 1 project for me everything works perfectly on the first try without doing anything more. But I tried every solution provided for my webpack example 2 but nothing works.

I do not understand why, in the basic example when just include the index.js file directly in the html it works well, but when processed by webpack and the included in the same html it doesn’t work ? Am i missing something here ?

Everything works if not compiled with webpack ? WebPack let me write ES6 and split all things into one bundle but if i manually rewrite all files and use only one file it will work… So from my point of view, here it is more a webpack behave/config problem.