mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Defer coffee-script require, prevent it from reassigning prepareStackTrace
This commit is contained in:
@@ -2,12 +2,7 @@
|
||||
|
||||
var crypto = require('crypto')
|
||||
var path = require('path')
|
||||
|
||||
// The coffee-script compiler is required eagerly because:
|
||||
// 1. It is always used.
|
||||
// 2. It reassigns Error.prepareStackTrace, so we need to make sure that
|
||||
// the 'source-map-support' module is installed *after* it is loaded.
|
||||
var CoffeeScript = require('coffee-script')
|
||||
var CoffeeScript = null
|
||||
|
||||
exports.shouldCompile = function() {
|
||||
return true
|
||||
@@ -24,6 +19,10 @@ exports.getCachePath = function(sourceCode) {
|
||||
}
|
||||
|
||||
exports.compile = function(sourceCode, filePath) {
|
||||
if (!CoffeeScript) {
|
||||
CoffeeScript = require('coffee-script')
|
||||
}
|
||||
|
||||
var output = CoffeeScript.compile(sourceCode, {
|
||||
filename: filePath,
|
||||
sourceFiles: [filePath],
|
||||
|
||||
@@ -130,3 +130,12 @@ require('source-map-support').install({
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// This prevents coffee-script from reassigning `Error.prepareStackTrace` when
|
||||
// it is loaded.
|
||||
Object.defineProperty(Error, 'prepareStackTrace', {
|
||||
value: Error.prepareStackTrace,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: false
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user