带有 TypeScript 转译器的 JSPM 捆绑包 [英] JSPM Bundle with TypeScript transpiler
问题描述
我对 System.js 和 JSPM 有了更多的了解,现在我想将我的 TypeScript 源代码捆绑到一个 JavaScript 包中.
I'm getting more into System.js and JSPM, where I've come to the point where I want to bundle my TypeScript source code into a JavaScript bundle.
现在我可以将生成的 JavaScript 代码与以下内容捆绑在一起:<代码>jspm 捆绑一些/源/路径 someDestFile.js
Now I can bundle my generated JavaScript code with something like:
jspm bundle some/source/path someDestFile.js
但随后我需要先将所有 TypeScript 预构建到 JavaScript 中,然后 然后 包,发现自己留下了所有已编译(和分离)的 JS 文件.这远非理想!
but then I need to pre-build all my TypeScript first into JavaScript and then bundle, finding myself left with all the compiled (and seperated) JS files. This is far from ideal!
我浏览了 jspm 文档 在这里,但没有找到解决方案.
I walked through the jspm docs here, but did not find a solution.
明确地说,我不想在我的浏览器中编译 TypeScript,而是想在我的浏览器中编译一个预先编译好的 JavaScript 包.
Just to be clear, I do not want to compile TypeScript in my browser, rather a precompiled bundle of solid JavaScript.
我该怎么做?
P.S.我使用了 TypeScript 转译器安装,见here
推荐答案
您可以使用 JSPM 构建器来完成.您可以将所有打字稿文件和 bundlesfx 捆绑到一个文件中,像这样配置 jspm.conf.js:
You can do it with JSPM builder. You can bundle all typescript files and bundlesfx to one single file, configurating jspm.conf.js like that:
System.config({
defaultJSExtensions: true,
transpiler: "typescript",
typescriptOptions: {
"module": "amd",
"experimentalDecorators": true
},
...
packages: {
"app": {
"main": "index",
"defaultExtension": "ts",
"meta": {
"*.ts": {
"loader": "ts"
}
}
}
});
然后运行:
jspm bundle-sfx src/index dist/app.js
您可以在此处查看完整的工作示例:https://github.com/b091/ts-skeleton/
You can see full workign example in here: https://github.com/b091/ts-skeleton/
这篇关于带有 TypeScript 转译器的 JSPM 捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!