mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Use inline source maps for coffeescript
This commit is contained in:
@@ -36,13 +36,10 @@ exports.compile = function (sourceCode, filePath) {
|
||||
var output = CoffeeScript.compile(sourceCode, {
|
||||
filename: filePath,
|
||||
sourceFiles: [filePath],
|
||||
sourceMap: true
|
||||
inlineMap: true
|
||||
})
|
||||
|
||||
var js = output.js
|
||||
js += '\n'
|
||||
js += '//# sourceMappingURL=data:application/json;base64,'
|
||||
js += new Buffer(output.v3SourceMap).toString('base64')
|
||||
js += '\n'
|
||||
return js
|
||||
// Strip sourceURL from output so there wouldn't be duplicate entries
|
||||
// in devtools.
|
||||
return output.replace(/\/\/# sourceURL=[^'"\n]+\s*$/, '')
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ function compileFileAtPath (compiler, filePath, extension) {
|
||||
cacheStats[extension].hits++
|
||||
} else {
|
||||
cacheStats[extension].misses++
|
||||
compiledCode = addSourceURL(compiler.compile(sourceCode, filePath), filePath)
|
||||
compiledCode = compiler.compile(sourceCode, filePath)
|
||||
writeCachedJavascript(cachePath, compiledCode)
|
||||
}
|
||||
return compiledCode
|
||||
@@ -97,13 +97,6 @@ function writeCachedJavascript (relativeCachePath, code) {
|
||||
fs.writeFileSync(cachePath, code, 'utf8')
|
||||
}
|
||||
|
||||
function addSourceURL (jsCode, filePath) {
|
||||
if (process.platform === 'win32') {
|
||||
filePath = '/' + path.resolve(filePath).replace(/\\/g, '/')
|
||||
}
|
||||
return jsCode + '\n' + '//# sourceURL=' + encodeURI(filePath) + '\n'
|
||||
}
|
||||
|
||||
var INLINE_SOURCE_MAP_REGEXP = /\/\/[#@]\s*sourceMappingURL=([^'"\n]+)\s*$/mg
|
||||
|
||||
require('source-map-support').install({
|
||||
|
||||
Reference in New Issue
Block a user