I transpile my TypeScript using "-m umd" because my project includes server, client and shared code. However, client side code doesn't work in browser. The browser doesn't even display any error and the breakpoint I located didn't hit, so I had to remove js-ts mapping. Then, I was able to debug it and I found the problem.
Following is the code that UMD generates:
(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", "./model"], factory);
}
})(function (require, exports) {
//my code
});
It doesn't work because both 'module' and 'define' are undefined. Therefore my code is not executed and there isn't even any exception.
What's wrong? How could I make it work?