0

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
  }
 }
Aj1
  • 953
  • 2
  • 15
  • 42
  • Well, may be you are right. But when i compile it in my local it works fine, but when type script files go through gulp traceur for bundling and minification I am getting the error. – Aj1 Oct 07 '15 at 01:49

1 Answers1

0

into the following js code where the js cannot find the keyword "require"

The js you shared does not contain require.

basarat
  • 261,912
  • 58
  • 460
  • 511