未捕获的ReferenceError:未定义导出和require

Iam*_*ker 8 angularjs typescript ecmascript-6 gulp

我正在使用angularjs和typescript来创建一些应用程序,我遇到了这个我无法解决的错误

这是我的*.ts代码

export var NgApp = new application.Startup();

///<reference path="../../../../../typings/tsd.d.ts"/>
import {NgApp} from "../../bootstrap";



module views.components.home {
    export class HomeComponent {
        public constructor() {
        }

        public static factory():Function[] {
            return [
                () => new HomeComponent()
            ]
        }

    }

}

NgApp.registerComponents(views.components.home,() => this.app.controller);
Run Code Online (Sandbox Code Playgroud)

这是我的GULP任务

let tsResult = gulp.src('src/**/*.ts').pipe(ts({
    module: 'commonjs',
    sourceMap: true
}));

let taskTs = tsResult.js.pipe(gulp.dest('built/'));
Run Code Online (Sandbox Code Playgroud)

这是我的错误:未捕获的ReferenceError:未定义导出

问题是:如何在打字稿中使用像es6这样的导入?我错过了什么?

KSh*_*ger 12

我使用angular 1.6和webpack,当我将模块更改为"umd"时,它在我身边工作

UMD:通用模块定义这带来了支持两种风格(AMD和CommonJS)的"通用"模式的推动

参考:http://davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/

粘贴在这里是我更改后的tsconfig.json,我运行$ tsc

{
  "compilerOptions": {
    "target": "es5",
    "module": "umd",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "allowUnreachableCode": true
  },
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

然后我的"导出未定义"错误消失了.