Skip to content

Instantly share code, notes, and snippets.

@inukshuk
Last active September 26, 2023 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inukshuk/7374963a8bc966d5da72a38da3402d70 to your computer and use it in GitHub Desktop.
Save inukshuk/7374963a8bc966d5da72a38da3402d70 to your computer and use it in GitHub Desktop.
Repro for electron#39701

Repro for electron/electron#39701

To Test:

  1. gh gist clone https://gist.github.com/inukshuk/7374963a8bc966d5da72a38da3402d70
  2. cd 7374963a8bc966d5da72a38da3402d70
  3. npm install
  4. npm run build
  5. npm start

For comparison with older Electron:

  1. npm install electron@v25
  2. npm start
import process from 'node:process';
// A comment
export function sayHello(path) {
console.log(`hello from ${path} in electron ${process.versions.electron}`)
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World!</title>
</head>
<body>
<h1>💖 Hello World!</h1>
<p>Welcome to your Electron application.</p>
</body>
</html>
import { app, BrowserWindow } from 'electron';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const ROOT = dirname(fileURLToPath(import.meta.url));
const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
preload: join(ROOT, 'preload.js'),
},
});
// and load the index.html of the app.
mainWindow.loadFile(join(ROOT, '../index.html'));
// Open the DevTools.
mainWindow.webContents.openDevTools();
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
{
"name": "sourcemap",
"productName": "sourcemap",
"private": true,
"version": "1.0.0",
"description": "Repro for electron#39701",
"main": "lib/index.js",
"scripts": {
"build": "rollup --config",
"start": "electron --app ."
},
"keywords": [],
"author": {
"name": "Sylvester Keil",
"email": "sylvester@keil.or.at"
},
"license": "MIT",
"devDependencies": {
"electron": "^26.2.2",
"rollup": "^3.29.3"
}
}
import { sayHello } from './hello.js';
import { fileURLToPath } from 'node:url';
// Here is a comment
sayHello(fileURLToPath(import.meta.url));
export default {
input: [
'index.js',
'preload.js'
],
output: {
'dir': 'lib',
'format': 'cjs',
'generatedCode': 'es2015',
'sourcemap': true
},
external: [
'electron',
'node:path',
'node:process',
'node:url'
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment