System.js builder.buildStatic 只输出文件名
System.js builder.buildStatic just outputs the filename
我刚刚将源文件简化到下面,当我在脚本标签中使用 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");
});
哦,我只是需要将 baseUrl 从“/”更改为“./”。
我刚刚将源文件简化到下面,当我在脚本标签中使用 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");
});
哦,我只是需要将 baseUrl 从“/”更改为“./”。