mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Start on generating a startup snapshot script via electron-link
This commit is contained in:
@@ -35,6 +35,7 @@ const dumpSymbols = require('./lib/dump-symbols')
|
||||
const generateAPIDocs = require('./lib/generate-api-docs')
|
||||
const generateMetadata = require('./lib/generate-metadata')
|
||||
const generateModuleCache = require('./lib/generate-module-cache')
|
||||
const generateStartupSnapshot = require('./lib/generate-startup-snapshot')
|
||||
const installApplication = require('./lib/install-application')
|
||||
const packageApplication = require('./lib/package-application')
|
||||
const prebuildLessCache = require('./lib/prebuild-less-cache')
|
||||
@@ -57,6 +58,7 @@ transpilePegJsPaths()
|
||||
generateModuleCache()
|
||||
prebuildLessCache()
|
||||
generateMetadata()
|
||||
generateStartupSnapshot()
|
||||
generateAPIDocs()
|
||||
downloadChromedriver()
|
||||
dumpSymbols()
|
||||
|
||||
48
script/lib/generate-startup-snapshot.js
Normal file
48
script/lib/generate-startup-snapshot.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const electronLink = require('electron-link')
|
||||
const CONFIG = require('../config')
|
||||
|
||||
module.exports = function () {
|
||||
const snapshotScriptPath = path.join(CONFIG.buildOutputPath, 'startup.js')
|
||||
console.log(`Generating snapshot script at "${snapshotScriptPath}"`)
|
||||
const coreModules = new Set([
|
||||
'path', 'electron', 'module', 'fs', 'child_process', 'crypto', 'url',
|
||||
'atom', 'vm', 'events', 'os', 'assert', 'buffer', 'tty', 'net', 'constants',
|
||||
'http', 'https'
|
||||
])
|
||||
const snapshotScriptContent = electronLink({
|
||||
baseDirPath: CONFIG.intermediateAppPath,
|
||||
mainPath: path.join(CONFIG.intermediateAppPath, 'src', 'initialize-application-window.js'),
|
||||
shouldExcludeModule: (modulePath) => {
|
||||
const relativePath = path.relative(CONFIG.intermediateAppPath, modulePath)
|
||||
return (
|
||||
modulePath.endsWith('.node') || modulePath === 'buffer-offset-index' ||
|
||||
coreModules.has(modulePath) ||
|
||||
(relativePath.startsWith('src' + path.sep) && relativePath.endsWith('-element.js')) ||
|
||||
relativePath == path.join('exports', 'atom.js') ||
|
||||
relativePath == path.join('src', 'config-schema.js') ||
|
||||
relativePath == path.join('src', 'electron-shims.js') ||
|
||||
relativePath == path.join('src', 'module-cache.js') ||
|
||||
relativePath == path.join('src', 'safe-clipboard.js') ||
|
||||
relativePath == path.join('node_modules', 'atom-keymap', 'lib', 'command-event.js') ||
|
||||
relativePath == path.join('node_modules', 'babel-core', 'index.js') ||
|
||||
relativePath == path.join('node_modules', 'coffee-script', 'lib', 'coffee-script', 'register.js') ||
|
||||
relativePath == path.join('node_modules', 'cson-parser', 'node_modules', 'coffee-script', 'lib', 'coffee-script', 'register.js') ||
|
||||
relativePath == path.join('node_modules', 'fs-plus', 'lib', 'fs-plus.js') ||
|
||||
relativePath == path.join('node_modules', 'git-utils', 'lib', 'git.js') ||
|
||||
relativePath == path.join('node_modules', 'less', 'lib', 'less', 'fs.js') ||
|
||||
relativePath == path.join('node_modules', 'less', 'node_modules', 'graceful-fs', 'graceful-fs.js') ||
|
||||
relativePath == path.join('node_modules', 'marker-index', 'dist', 'native', 'marker-index.js') ||
|
||||
relativePath == path.join('node_modules', 'mime', 'mime.js') ||
|
||||
relativePath == path.join('node_modules', 'oniguruma', 'lib', 'oniguruma.js') ||
|
||||
relativePath == path.join('node_modules', 'pathwatcher', 'lib', 'main.js') ||
|
||||
relativePath == path.join('node_modules', 'request', 'request.js') ||
|
||||
relativePath == path.join('node_modules', 'resolve', 'index.js') ||
|
||||
relativePath == path.join('node_modules', 'resolve', 'lib', 'core.js') ||
|
||||
relativePath == path.join('node_modules', 'text-buffer', 'node_modules', 'pathwatcher', 'lib', 'main.js')
|
||||
)
|
||||
}
|
||||
})
|
||||
fs.writeFileSync(snapshotScriptPath, snapshotScriptContent)
|
||||
}
|
||||
Reference in New Issue
Block a user