use module id if available for umd global name - fixes #1166
This commit is contained in:
parent
c2776e63ae
commit
6b76f26ed8
@ -60,12 +60,17 @@ export default class UMDFormatter extends AMDFormatter {
|
||||
var moduleName = this.getModuleName();
|
||||
if (moduleName) defineArgs.unshift(t.literal(moduleName));
|
||||
|
||||
//
|
||||
var globalArg = this.file.opts.basename;
|
||||
if (moduleName) globalArg = moduleName;
|
||||
globalArg = t.identifier(t.toIdentifier(globalArg));
|
||||
|
||||
var runner = util.template("umd-runner-body", {
|
||||
AMD_ARGUMENTS: defineArgs,
|
||||
COMMON_TEST: commonTests,
|
||||
COMMON_ARGUMENTS: commonArgs,
|
||||
BROWSER_ARGUMENTS: browserArgs,
|
||||
GLOBAL_ARG: t.identifier(t.toIdentifier(this.file.opts.basename))
|
||||
GLOBAL_ARG: globalArg
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
@ -0,0 +1 @@
|
||||
foobar();
|
||||
@ -0,0 +1,17 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("MyLib", ["exports"], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(exports);
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports);
|
||||
global.MyLib = mod.exports;
|
||||
}
|
||||
})(this, function (exports) {
|
||||
"use strict";
|
||||
|
||||
foobar();
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"moduleId": "MyLib"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user