Skip to content

Commit 1438301

Browse files
committed
Build Atom with Parcel
1 parent e8296e4 commit 1438301

File tree

6 files changed

+9390
-2269
lines changed

6 files changed

+9390
-2269
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ spec/fixtures/evil-files/
1919
!spec/fixtures/packages/package-with-incompatible-native-module-loaded-conditionally/node_modules/
2020
out/
2121
/electron/
22+
.parcel-cache

package.json

+72
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,78 @@
271271
"preinstall": "node -e 'process.exit(0)'",
272272
"test": "node script/test"
273273
},
274+
"engines": {
275+
"electron": "9.4.4"
276+
},
277+
"main-target": "./out/app/src/main-process/main.bundle.js",
278+
"start-target": "./out/app/src/main-process/start.bundle.js",
279+
"application-target": "./out/app/src/main-process/atom-application.bundle.js",
280+
"initialize-target": "./out/app/src/initialize-application-window.bundle.js",
281+
"targets": {
282+
"main-target": {
283+
"source": "./out/app/src/main-process/main.js",
284+
"context": "electron-main",
285+
"includeNodeModules": {
286+
"electron": false,
287+
"y18n": false
288+
}
289+
},
290+
"start-target": {
291+
"source": "./out/app/src/main-process/start.js",
292+
"context": "electron-main",
293+
"includeNodeModules": {
294+
"electron": false,
295+
"nslog": false,
296+
"y18n": false
297+
}
298+
},
299+
"application-target": {
300+
"source": "./out/app/src/main-process/atom-application.js",
301+
"context": "electron-renderer",
302+
"includeNodeModules": {
303+
"electron": false,
304+
"atom": false,
305+
"pathwatcher": false,
306+
"@atom/nsfw": false,
307+
"@atom/watcher": false,
308+
"fs-admin": false,
309+
"git-utils": false,
310+
"oniguruma": false,
311+
"superstring": false
312+
}
313+
},
314+
"initialize-target": {
315+
"source": "./out/app/src/initialize-application-window.js",
316+
"context": "electron-renderer",
317+
"includeNodeModules": {
318+
"electron": false,
319+
"atom": false,
320+
"pathwatcher": false,
321+
"@atom/nsfw": false,
322+
"@atom/watcher": false,
323+
"fs-admin": false,
324+
"git-utils": false,
325+
"oniguruma": false,
326+
"superstring": false,
327+
"keybinding-resolver": false,
328+
"keytar": false,
329+
"loophole": false,
330+
"pegjs": false,
331+
"@atom/fuzzy-native": false,
332+
"scrollbar-style": false,
333+
"spellchecker": false,
334+
"ctags": false,
335+
"keyboard-layout": false,
336+
"open-on-github": false,
337+
"typescript": false,
338+
"coffee-script": false,
339+
"babel-core": false
340+
}
341+
}
342+
},
343+
"alias": {
344+
"react-dom": "react-dom/cjs/react-dom.production.min.js"
345+
},
274346
"standard-engine": "./script/node_modules/standard",
275347
"standard": {
276348
"env": {

script/lib/generate-startup-snapshot.js

+40
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,46 @@ const terser = require('terser');
66
const CONFIG = require('../config');
77

88
module.exports = function(packagedAppPath) {
9+
console.log('Bundling with Parcel');
10+
const parcel = childProcess.spawnSync(
11+
process.execPath,
12+
[
13+
path.join(
14+
CONFIG.repositoryRootPath,
15+
'script',
16+
'node_modules',
17+
'parcel',
18+
'lib',
19+
'bin.js'
20+
),
21+
'build',
22+
CONFIG.repositoryRootPath,
23+
'--detailed-report'
24+
],
25+
{ stdio: ['inherit', 'inherit', 'pipe'] }
26+
);
27+
if (parcel.stderr) {
28+
console.error(parcel.stderr);
29+
}
30+
// replace bundles with the source
31+
[
32+
path.join(CONFIG.intermediateAppPath, 'src/main-process/main.bundle.js'),
33+
path.join(CONFIG.intermediateAppPath, 'src/main-process/start.bundle.js'),
34+
path.join(
35+
CONFIG.intermediateAppPath,
36+
'src/main-process/atom-application.bundle.js'
37+
),
38+
path.join(
39+
CONFIG.intermediateAppPath,
40+
'src/initialize-application-window.bundle.js'
41+
)
42+
].map(bundleFile => {
43+
const sourceFile = bundleFile.replace('.bundle.js', '.js');
44+
fs.unlinkSync(sourceFile);
45+
fs.renameSync(bundleFile, sourceFile);
46+
fs.renameSync(bundleFile + '.map', sourceFile + '.map');
47+
});
48+
949
const snapshotScriptPath = path.join(CONFIG.buildOutputPath, 'startup.js');
1050
const coreModules = new Set([
1151
'electron',

0 commit comments

Comments
 (0)