mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
🐎 Minimize dependencies loaded before the module-cache
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
var _ = require('underscore-plus')
|
||||
var crypto = require('crypto')
|
||||
var path = require('path')
|
||||
var defaultOptions = require('../static/babelrc.json')
|
||||
@@ -45,7 +44,10 @@ exports.compile = function(sourceCode, filePath) {
|
||||
babel = require('babel-core')
|
||||
}
|
||||
|
||||
var options = _.defaults({filename: filePath}, defaultOptions)
|
||||
var options = {filename: filePath}
|
||||
for (var key in defaultOptions) {
|
||||
options[key] = defaultOptions[key]
|
||||
}
|
||||
return babel.transform(sourceCode, options).code
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
var path = require('path')
|
||||
var CSON = require('season')
|
||||
var fs = require('fs-plus')
|
||||
var _ = require('underscore-plus')
|
||||
var CSON = null
|
||||
|
||||
var COMPILERS = {
|
||||
'.js': require('./babel'),
|
||||
@@ -13,7 +12,9 @@ var COMPILERS = {
|
||||
|
||||
var cacheDirectory = null
|
||||
|
||||
_.each(COMPILERS, function (compiler, extension) {
|
||||
Object.keys(COMPILERS).forEach(function (extension) {
|
||||
var compiler = COMPILERS[extension]
|
||||
|
||||
Object.defineProperty(require.extensions, extension, {
|
||||
enumerable: true,
|
||||
writable: false,
|
||||
@@ -34,7 +35,6 @@ exports.setAtomHomeDirectory = function (atomHome) {
|
||||
|
||||
exports.setCacheDirectory = function (directory) {
|
||||
cacheDirectory = directory
|
||||
CSON.setCacheDir(path.join(cacheDirectory, 'cson'));
|
||||
}
|
||||
|
||||
exports.getCacheDirectory = function () {
|
||||
@@ -46,6 +46,7 @@ exports.addPathToCache = function (filePath, atomHome) {
|
||||
var extension = path.extname(filePath)
|
||||
|
||||
if (extension === '.cson') {
|
||||
CSON = CSON || require('season')
|
||||
CSON.readFileSync(filePath)
|
||||
} else {
|
||||
var compiler = COMPILERS[extension]
|
||||
|
||||
@@ -78,6 +78,7 @@ var setupWindow = function(loadSettings) {
|
||||
});
|
||||
|
||||
setupVmCompatibility();
|
||||
setupCsonCache(compileCache.getCacheDirectory())
|
||||
|
||||
require(loadSettings.bootstrapScript);
|
||||
require('ipc').sendChannel('window-command', 'window:loaded');
|
||||
@@ -101,6 +102,10 @@ var setupAtomHome = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var setupCsonCache = function(cacheDir) {
|
||||
require('season').setCacheDir(path.join(cacheDir, 'cson'));
|
||||
}
|
||||
|
||||
var setupVmCompatibility = function() {
|
||||
var vm = require('vm');
|
||||
if (!vm.Script.createContext) {
|
||||
|
||||
Reference in New Issue
Block a user