Round three of modularize exports=node support.

Former-commit-id: ac21e547a6717ddf362e06c031657c9fb18b8c85
This commit is contained in:
John-David Dalton
2013-08-20 22:31:04 -07:00
parent 84759de36f
commit 3297c3a2e2
2 changed files with 11 additions and 4 deletions

View File

@@ -1021,7 +1021,7 @@
});
}
source = source.replace(/^ *return lodash;$/m, function(match) {
source = source.replace(/^ *(return +|module\.exports\s*=\s*)lodash;$/m, function(match) {
var prelude = '';
if (_.contains(identifiers, 'support')) {
prelude += ' lodash.support = support;\n';
@@ -4187,6 +4187,12 @@
// remove debug sourceURL use in `_.template`
.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, '');
});
// remove `freeGlobal` and replace `context` with `global`
if (isNode) {
source = source.replace(/\bcontext(?=\.)/g, 'global');
}
source = removeRunInContext(source);
}
}
@@ -4197,6 +4203,7 @@
source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +define[\s\S]+?else /, '$1');
}
if (!isNode || isModularize) {
source = removeVar(source, 'freeGlobal');
source = source.replace(/(?: *\/\/.*\n)*( *)if *\(freeModule[\s\S]+?else *{([\s\S]+?\n)\1}\n+/, '$1$2');
}
if (!isCommonJS || isModularize) {
@@ -4391,7 +4398,7 @@
var isShallow = isExcluded('runInContext'),
useMap = {},
snippet = removeStrings(removeComments(source)),
varNames = getVars(snippet, isShallow);
varNames = _.difference(getVars(snippet, isShallow), includeProps);
while (varNames.length) {
varNames = _.sortBy(varNames, function(varName) {

View File

@@ -60,7 +60,7 @@
var _ = window._ || (window._ = (
_ = load(filePath) || window._,
_ = _._ || _,
_.runInContext(window)
(_.runInContext ? _.runInContext(window) : _)
));
/** Used to pass falsey values to methods */
@@ -101,7 +101,7 @@
});
/** Used to indicate testing a modularized build */
var isModularize = /modularize/.test(ui.urlParams.build);
var isModularize = /modularize/.test([ui.buildPath, ui.urlParams.build]);
/*--------------------------------------------------------------------------*/