0

这是我的角度模块编写的打字稿。

  /// <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};

它在本地运行良好。打包后编译成下面的js代码,其中js找不到关键字“require”。此外,我们正在使用 traceur 将我们的一些 ES6 模块转换为 ES5。这是编译和捆绑的 js 模块。

     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();
  });
       }
     };
 });

这里还有 tsconfig.Json

  {
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"sourceMap": true
  }
 }
4

1 回答 1

0

进入以下js代码,其中js找不到关键字“require”

您共享的js不包含require.

于 2015-10-06T23:48:29.787 回答