|
@@ -5,7 +5,7 @@ var through = require('through2');
|
|
* The parameters for this function has grown during development.
|
|
* The parameters for this function has grown during development.
|
|
* Eventually, this function will need to be reorganized.
|
|
* Eventually, this function will need to be reorganized.
|
|
*/
|
|
*/
|
|
-module.exports = function (varName, subModule, extendsRoot, requireOnly) {
|
|
|
|
|
|
+module.exports = function (varName, subModule, extendsRoot, externalUsingBabylon) {
|
|
return through.obj(function (file, enc, cb) {
|
|
return through.obj(function (file, enc, cb) {
|
|
|
|
|
|
var optionalRequire = `var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
|
|
var optionalRequire = `var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
|
|
@@ -24,15 +24,15 @@ globalObject["${base}"] = f;` : '';
|
|
}*/
|
|
}*/
|
|
|
|
|
|
return `\n\n(function universalModuleDefinition(root, factory) {
|
|
return `\n\n(function universalModuleDefinition(root, factory) {
|
|
|
|
+ var f = factory();
|
|
if (root && root["${base}"]) {
|
|
if (root && root["${base}"]) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- var f = factory();
|
|
|
|
${sadGlobalPolution}
|
|
${sadGlobalPolution}
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
module.exports = f;
|
|
module.exports = f;
|
|
else if(typeof define === 'function' && define.amd)
|
|
else if(typeof define === 'function' && define.amd)
|
|
- define([], factory);
|
|
|
|
|
|
+ define(["${varName}"], factory);
|
|
else if(typeof exports === 'object')
|
|
else if(typeof exports === 'object')
|
|
exports["${varName}"] = f;
|
|
exports["${varName}"] = f;
|
|
else {
|
|
else {
|
|
@@ -76,8 +76,9 @@ globalObject["${base}"] = f;` : '';
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- if (requireOnly) {
|
|
|
|
- file.contents = new Buffer(optionalRequire.concat(String(file.contents)));
|
|
|
|
|
|
+ if (externalUsingBabylon) {
|
|
|
|
+ //file.contents = new Buffer(optionalRequire.concat(String(file.contents)));
|
|
|
|
+ file.contents = new Buffer(optionalRequire.concat(new Buffer(String(file.contents).concat(moduleExportAddition(varName)))));
|
|
} else {
|
|
} else {
|
|
let pretext = subModule ? optionalRequire : '';
|
|
let pretext = subModule ? optionalRequire : '';
|
|
file.contents = new Buffer(pretext.concat(decorateAddition).concat(new Buffer(extendsAddition.concat(String(file.contents)).concat(moduleExportAddition(varName)))));
|
|
file.contents = new Buffer(pretext.concat(decorateAddition).concat(new Buffer(extendsAddition.concat(String(file.contents)).concat(moduleExportAddition(varName)))));
|