System.js builder.buildStatic只输出文件名

时间:2016-03-23 05:48:49

标签: node.js gulp systemjs jspm

我刚刚将源文件简化为以下版本,当我在脚本标记中使用 System.import 时,它可以正常工作。

import angular from "angular";

angular.element(document).ready(function () {
    alert('Hello word');;
});

以下是我的config.js

System.config({
  baseURL: "/",
  defaultJSExtensions: true,
  transpiler: "typescript",
  paths: {
    "npm:": "jspm_packages/npm/"
  },

  map: {
    "angular": "npm:angular@1.5.2",
    "typescript": "npm:typescript@1.8.9"
  }
});

我有一个gulp任务来构建它:

gulp.task('bundle:js', ['clean:js'], function () {

    var builder = new Builder();
    builder.loadConfig('./config.js').then(function () {
        var destination = paths.coreJsDest;
        builder.buildStatic(paths.srcRoot + 'js/ng/homepage', destination, {
            minify: false,
            sourceMaps: false,
           runtime: false
        });
    });
});

但输出文件包含文件名而不是文件及其导入的JavaScript:

(["1"], ["1"], function($__System) {

})
(function(factory) {
  if (typeof define == 'function' && define.amd)
    define(["D:/Projects/etc-etc/assets/js/ng/homepage.js"], factory);
  else if (typeof module == 'object' && module.exports && typeof require == 'function')
    module.exports = factory(require("D:/Projects/etc-etc/js/ng/homepage.js"));
  else
    throw new Error("Module must be loaded as AMD or CommonJS");
});

1 个答案:

答案 0 :(得分:6)

Doh,我只需要将baseUrl从“/”改为“./”。