Here is my angular module written typescript.
/// <reference path="../../../../thirdparty/angular/angular.d.ts"/>
/// <reference path="./sharedData.ts"/>
import factory = require('./sharedData');
var sharedData: ng.IModule = angular.module('comp.modules.common.sharedData', []);
sharedData.factory('sharedData', function () {
return new factory.sharedData_factories.SharedData();
});
export {sharedData};
It works fine in local. After bundling it gets compiled into the following js code where the js cannot find the keyword "require". Also, we are using traceur to convert some of our ES6 modules to ES5. Here is the compiled and bundled js module.
System.register("modules/common/sharedData/sharedData.module", [], function($__export) {
"use strict";
var __moduleName = "modules/common/sharedData/sharedData.module";
var factory,
sharedData;
return {
setters: [],
execute: function() {
factory = require('./sharedData');
sharedData = angular.module('comp.modules.common.sharedData', []);
exports.sharedData = sharedData;
sharedData.factory('sharedData', function() {
return new factory.sharedData_factories.SharedData();
});
}
};
});
Also here is the tsconfig.Json
{
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"sourceMap": true
}
}