Skip to content

Commit ccbb276

Browse files
author
Antonio Scandurra
committed
Bake source maps into the snapshot
1 parent 0c8e515 commit ccbb276

File tree

6 files changed

+9
-22
lines changed

6 files changed

+9
-22
lines changed

script/lib/generate-startup-snapshot.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function (packagedAppPath) {
5858
relativePath == path.join('..', 'node_modules', 'tmp', 'lib', 'tmp.js')
5959
)
6060
}
61-
}).then(({snapshotScript, sourceMap}) => {
61+
}).then((snapshotScript) => {
6262
fs.writeFileSync(snapshotScriptPath, snapshotScript)
6363
process.stdout.write('\n')
6464

@@ -72,23 +72,15 @@ module.exports = function (packagedAppPath) {
7272
[snapshotScriptPath, '--startup_blob', generatedStartupBlobPath]
7373
)
7474

75-
let startupBlobDestinationPath, startupBlobSourceMapDestinationPath
75+
let startupBlobDestinationPath
7676
if (process.platform === 'darwin') {
7777
startupBlobDestinationPath = `${packagedAppPath}/Contents/Frameworks/Electron Framework.framework/Resources/snapshot_blob.bin`
78-
startupBlobSourceMapDestinationPath = path.join(packagedAppPath, 'Contents', 'Resources', 'snapshot_sourcemap.json')
79-
} else if (process.platform === 'linux') {
80-
startupBlobDestinationPath = path.join(packagedAppPath, 'snapshot_blob.bin')
81-
startupBlobSourceMapDestinationPath = path.join(packagedAppPath, 'resources', 'snapshot_sourcemap.json')
8278
} else {
8379
startupBlobDestinationPath = path.join(packagedAppPath, 'snapshot_blob.bin')
84-
startupBlobSourceMapDestinationPath = path.join(packagedAppPath, 'resources', 'snapshot_sourcemap.json')
8580
}
8681

8782
console.log(`Moving generated startup blob into "${startupBlobDestinationPath}"`)
8883
fs.unlinkSync(startupBlobDestinationPath)
8984
fs.renameSync(generatedStartupBlobPath, startupBlobDestinationPath)
90-
91-
console.log(`Moving generated startup blob sourcemap into "${startupBlobSourceMapDestinationPath}"`)
92-
fs.writeFileSync(startupBlobSourceMapDestinationPath, sourceMap)
9385
})
9486
}

script/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"csslint": "1.0.2",
99
"donna": "1.0.13",
1010
"electron-chromedriver": "~1.3",
11-
"electron-link": "0.0.19",
11+
"electron-link": "0.0.20",
1212
"electron-mksnapshot": "~1.3",
1313
"electron-packager": "7.3.0",
1414
"electron-winstaller": "2.5.1",

src/compile-cache.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function writeCachedJavascript (relativeCachePath, code) {
115115
var INLINE_SOURCE_MAP_REGEXP = /\/\/[#@]\s*sourceMappingURL=([^'"\n]+)\s*$/mg
116116
let snapshotSourceMap = null
117117

118-
exports.install = function (nodeRequire) {
118+
exports.install = function (resourcesPath, nodeRequire) {
119119
sourceMapSupport.install({
120120
handleUncaughtExceptions: false,
121121

@@ -124,14 +124,9 @@ exports.install = function (nodeRequire) {
124124
// code from our cache directory.
125125
retrieveSourceMap: function (filePath) {
126126
if (filePath === '<embedded>') {
127-
if (snapshotSourceMap == null) {
128-
const snapshotSourceMapContent = fs.readFileSync(path.join(process.resourcesPath, 'snapshot_sourcemap.json'), 'utf8')
129-
snapshotSourceMap = JSON.parse(snapshotSourceMapContent)
130-
}
131-
132127
return {
133-
map: snapshotSourceMap,
134-
url: path.join(process.resourcesPath, 'app', 'static', 'index.js')
128+
map: snapshotResult.sourceMap,
129+
url: path.join(resourcesPath, 'app', 'static', 'index.js')
135130
}
136131
}
137132

src/main-process/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@ function handleStartupEventWithSquirrel () {
8383
function setupCompileCache () {
8484
const CompileCache = require('../compile-cache')
8585
CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME)
86-
CompileCache.install(require)
86+
CompileCache.install(process.resourcesPath, require)
8787
}

src/task.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Task
7676
7777
CompileCache = #{compileCacheRequire}
7878
CompileCache.setCacheDirectory('#{compileCachePath}');
79-
CompileCache.install(require)
79+
CompileCache.install("#{process.resourcesPath}", require)
8080
#{taskBootstrapRequire}
8181
"""
8282
bootstrap = bootstrap.replace(/\\/g, "\\\\")

static/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
function setupWindow () {
9191
const CompileCache = useSnapshot ? snapshotResult.customRequire('../src/compile-cache.js') : require('../src/compile-cache') // eslint-disable-line no-undef
9292
CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME)
93-
CompileCache.install(require)
93+
CompileCache.install(process.resourcesPath, require)
9494

9595
const ModuleCache = useSnapshot ? snapshotResult.customRequire('../src/module-cache.js') : require('../src/module-cache') // eslint-disable-line no-undef
9696
ModuleCache.register(getWindowLoadSettings())

0 commit comments

Comments
 (0)