Merge pull request #17926 from atom/mb-minify

Minify the startup snapshot script with terser
This commit is contained in:
Max Brunsfeld
2018-08-27 10:14:04 -07:00
committed by GitHub
3 changed files with 37 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ const childProcess = require('child_process')
const fs = require('fs')
const path = require('path')
const electronLink = require('electron-link')
const terser = require('terser')
const CONFIG = require('../config')
module.exports = function (packagedAppPath) {
@@ -67,9 +68,17 @@ module.exports = function (packagedAppPath) {
)
}
}).then(({snapshotScript}) => {
fs.writeFileSync(snapshotScriptPath, snapshotScript)
process.stdout.write('\n')
process.stdout.write('Minifying startup script')
const minification = terser.minify(snapshotScript, {
keep_classnames: true,
compress: {keep_fargs: true, keep_infinity: true}
})
if (minification.error) throw minification.error
process.stdout.write('\n')
fs.writeFileSync(snapshotScriptPath, minification.code)
console.log('Verifying if snapshot can be executed via `mksnapshot`')
const verifySnapshotScriptPath = path.join(CONFIG.repositoryRootPath, 'script', 'verify-snapshot-script')
let nodeBundledInElectronPath

View File

@@ -9926,6 +9926,32 @@
}
}
},
"terser": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-3.8.1.tgz",
"integrity": "sha512-FRin3gKQ0vm0xPPLuxw1FqpVgv1b2pBpYCaFb5qe6A7sD749Fnq1VbDiX3CEFM0BV0fqDzFtBfgmxhxCdzKQIg==",
"requires": {
"commander": "~2.16.0",
"source-map": "~0.6.1",
"source-map-support": "~0.5.6"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"source-map-support": {
"version": "0.5.9",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz",
"integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==",
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
}
}
},
"text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",

View File

@@ -37,6 +37,7 @@
"stylelint-config-standard": "^18.1.0",
"sync-request": "3.0.1",
"tello": "1.0.7",
"terser": "^3.8.1",
"webdriverio": "2.4.5",
"yargs": "4.8.1"
}