mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Round three of modularize exports=node support.
Former-commit-id: ac21e547a6717ddf362e06c031657c9fb18b8c85
This commit is contained in:
11
build.js
11
build.js
@@ -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 = '';
|
var prelude = '';
|
||||||
if (_.contains(identifiers, 'support')) {
|
if (_.contains(identifiers, 'support')) {
|
||||||
prelude += ' lodash.support = support;\n';
|
prelude += ' lodash.support = support;\n';
|
||||||
@@ -4187,6 +4187,12 @@
|
|||||||
// remove debug sourceURL use in `_.template`
|
// remove debug sourceURL use in `_.template`
|
||||||
.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, '');
|
.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');
|
source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +define[\s\S]+?else /, '$1');
|
||||||
}
|
}
|
||||||
if (!isNode || isModularize) {
|
if (!isNode || isModularize) {
|
||||||
|
source = removeVar(source, 'freeGlobal');
|
||||||
source = source.replace(/(?: *\/\/.*\n)*( *)if *\(freeModule[\s\S]+?else *{([\s\S]+?\n)\1}\n+/, '$1$2');
|
source = source.replace(/(?: *\/\/.*\n)*( *)if *\(freeModule[\s\S]+?else *{([\s\S]+?\n)\1}\n+/, '$1$2');
|
||||||
}
|
}
|
||||||
if (!isCommonJS || isModularize) {
|
if (!isCommonJS || isModularize) {
|
||||||
@@ -4391,7 +4398,7 @@
|
|||||||
var isShallow = isExcluded('runInContext'),
|
var isShallow = isExcluded('runInContext'),
|
||||||
useMap = {},
|
useMap = {},
|
||||||
snippet = removeStrings(removeComments(source)),
|
snippet = removeStrings(removeComments(source)),
|
||||||
varNames = getVars(snippet, isShallow);
|
varNames = _.difference(getVars(snippet, isShallow), includeProps);
|
||||||
|
|
||||||
while (varNames.length) {
|
while (varNames.length) {
|
||||||
varNames = _.sortBy(varNames, function(varName) {
|
varNames = _.sortBy(varNames, function(varName) {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
var _ = window._ || (window._ = (
|
var _ = window._ || (window._ = (
|
||||||
_ = load(filePath) || window._,
|
_ = load(filePath) || window._,
|
||||||
_ = _._ || _,
|
_ = _._ || _,
|
||||||
_.runInContext(window)
|
(_.runInContext ? _.runInContext(window) : _)
|
||||||
));
|
));
|
||||||
|
|
||||||
/** Used to pass falsey values to methods */
|
/** Used to pass falsey values to methods */
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** Used to indicate testing a modularized build */
|
/** Used to indicate testing a modularized build */
|
||||||
var isModularize = /modularize/.test(ui.urlParams.build);
|
var isModularize = /modularize/.test([ui.buildPath, ui.urlParams.build]);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user