You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ./node_modules/.bin/tsc -v
Version 2.5.2
$ cat a.ts
/// <amd-module name="a"/>
export const a = 1;
$ cat b.ts
/// <amd-module name="b"/>
import {a} from './a';
console.log(a);
$ cat tsconfig.json
{
"compilerOptions": {
"module": "umd"
}
}
$ ./node_modules/.bin/tsc
$ cat a.js
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
exports.__esModule = true;
/// <amd-module name="a"/>
exports.a = 1;
});
$ cat b.js
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "a"], factory);
}
})(function (require, exports) {
"use strict";
exports.__esModule = true;
/// <amd-module name="b"/>
var a_1 = require("a");
console.log(a_1.a);
});
The AMD output embedded in these UMD modules doesn't work, because the modules are declared anonymous (define(["require", "exports"], factory);), but require'd by name (var a_1 = require("a");).
Changing the --module flag to amd makes the code work.
I'm aware that /// <amd-module/> directive is intended for --module=amd but since umd modules wrap an amd module, I think this ought to be supported.
Note: internally at Google, we use goog.module as a format that can be concatenated onto a webpage, since modules are named. This named umd proposal allows us to do the same thing for external users, part of http://g.co/ng/abc .
The text was updated successfully, but these errors were encountered:
Note, it's fine that the commonjs modules embedded in the umd modules are unnamed, we'll still load those from individual paths.
It's just for Require.js that we want to be able to concatenate the sources together.
The AMD output embedded in these UMD modules doesn't work, because the modules are declared anonymous (
define(["require", "exports"], factory);
), but require'd by name (var a_1 = require("a");
).Require.js gives error:
Uncaught Error: Mismatched anonymous define() module
Changing the
--module
flag toamd
makes the code work.I'm aware that
/// <amd-module/>
directive is intended for--module=amd
but since umd modules wrap an amd module, I think this ought to be supported.Note: internally at Google, we use
goog.module
as a format that can be concatenated onto a webpage, since modules are named. This named umd proposal allows us to do the same thing for external users, part of http://g.co/ng/abc .The text was updated successfully, but these errors were encountered: