[X] I agree to follow the code of conduct that this project uses.
[X] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
6.0.4
Electron version
22.0.1
Operating system
macOS 13.4
Last known working Electron Forge version
No response
Expected behavior
adding sqlite3 should not break my renderer
Actual behavior
if we only remove accessing sqlite3 from electron.js, then the app works fine (sqlite3 is installed, but not being used).
but as soon as we start using (not install, but start) sqlite3, the renderer is throwing
Steps to reproduce
create a electron forge app with following files
// webpack.main.js
module.exports = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: "./electron/electron.js",
// Put your normal webpack config below here
module: {
rules: [
{
// We're specifying native_modules in the test because the asset
// relocator loader generates a "fake" .node file which is really
// a cjs file.
test: /native_modules\/.+\.node$/,
use: "node-loader",
},
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: "@vercel/webpack-asset-relocator-loader",
options: {
outputAssetBase: "native_modules",
},
},
},
],
},
externals: {
sqlite3: "commonjs sqlite3",
},
};
// electron.js
const { app, BrowserWindow } = require("electron");
const sqlite3 = require("sqlite3").verbose();
const path = require("path");
export let db;
const dbPath = path.resolve(__dirname, "app.db");
if (require("electron-squirrel-startup")) {
app.quit();
}
const isDev = require("electron-is-dev");
function createWindow() {
// Create the browser window.
let mainWindow = new BrowserWindow({
icon: "./src/images/logo.png",
title: "my App",
titleBarOverlay: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
nodeIntegrationInSubFrames: true,
},
});
mainWindow.webContents.setWindowOpenHandler(() => {
return {
action: "allow",
overrideBrowserWindowOptions: {
width: 1280,
height: 720,
webPreferences: { nodeIntegration: true, contextIsolation: false, nodeIntegrationInSubFrames: true },
},
};
});
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
db = new sqlite3.Database(dbPath, (err) => {
if (err) {
console.error(err.message);
}
console.log("Connected to the database.");
});
if (isDev) {
mainWindow.webContents.openDevTools({ mode: "detach" });
}
mainWindow.maximize();
mainWindow.on("closed", () => {
mainWindow = null;
});
}
app.whenReady().then(createWindow);
app.on("window-all-closed", () => {
db.close((err) => {
if (err) {
console.error(err.message);
}
console.log("Disconnected from the database.");
});
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
Pre-flight checklist
Electron Forge version
6.0.4
Electron version
22.0.1
Operating system
macOS 13.4
Last known working Electron Forge version
No response
Expected behavior
adding sqlite3 should not break my renderer
Actual behavior
if we only remove accessing sqlite3 from electron.js, then the app works fine (sqlite3 is installed, but not being used).
but as soon as we start using (not install, but start) sqlite3, the renderer is throwing
Steps to reproduce
create a electron forge app with following files
Additional information
No response