为什么SystemJS无法找到模块和打字?

时间:2016-10-07 18:30:38

标签: angular typescript gulp bundling-and-minification systemjs

我尝试将Angular 2应用与SystemJS Builder 0.15.31捆绑在一起。我无法理解为什么SystemJS无法找到Angular模块或打字。

systemjs.config.js

System.config({
    transpiler: "ts", // this is plugin-typescript 5.2.6
    typescriptOptions: { typeCheck: true, tsconfig: true },
    map: { app:'dev', '@angular':'node_modules/@angular' },
    packages: {
        app: {
            main: './main.ts',
            defaultExtension: 'ts' ,
            meta: { '*.ts': {'loader':'ts'} }
        },
        '@angular/core':  {main: './bundles/core.umd.js', defaultExtension:'js'},
        ...
        "ts":             { main: "./lib/plugin.js"},
        "typescript": { // this is typescript 2.0.3
            main: "./lib/typescript.js",
            meta: {"./lib/typescript.js": {"exports": "ts"} }
        }
    }
});

tsonfig.json

"compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "outDir": "./dist",
    "baseUrl": "."
},

systemjs-builder gulp task

gulp.task('bundle', function() {
    var builder = new SystemBuilder();
    builder.loadConfig('./systemjs.config.js').then(function(){
            return builder.buildStatic('app', 'dist/bundle.js');
        });
});

当我执行gulp任务时,抛出此错误:

  

无法找到模块' @ angular / core'

路径node_modules/@angular/bundles/core.umd.js已正确解析(如果我更改了文件名,则会出现file not found错误。

SystemJS 0.19.39plugin-typescript 5.2.6

0 个答案:

没有答案