🐎 Minimize dependencies loaded before the module-cache

This commit is contained in:
Max Brunsfeld
2015-08-21 13:35:52 -07:00
parent 1f64676189
commit b533aff8f4
3 changed files with 14 additions and 6 deletions

View File

@@ -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
}

View File

@@ -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]