[英]transpile services module angular 2
I have a common
module in an angular 2
application. 我在
angular 2
应用程序中有一个common
模块。 This is how the project is structured: 项目的结构如下:
main
--app
/common
--config
//.ts configs for modules
--services
//angular services
--models
--store
//ngrx store
/component1
/component2
app.module.ts
main.ts
--js
//systemjs dependencies
Gruntfile.js
package.json
tconfig.json
The project is configured to transpile to bundle.js and works as expected. 该项目配置为可转换为bundle.js并按预期工作。 However, now I want to bundle out the contents of
common
folder and package it in isolation. 但是,现在我想将
common
文件夹的内容打包并单独打包。 Such that, I can just load its dependency using system js
, and then include it is app.module.ts
to use in components. 这样,我可以仅使用
system js
加载其依赖项,然后将其app.module.ts
包含在组件中。
I need help in getting started, is it some gruntfile/tsconfig
changes that I need to make? 我需要入门方面的帮助,是否需要进行一些
gruntfile/tsconfig
更改? Or would I have to create a separate package.json/index.ts
to transpile .ts
dependencies? 还是我必须创建一个单独的
package.json/index.ts
来转换.ts
依赖项?
The feature I believe you are looking for is the Bundle Arithmetic feature of the systemjs-builder. 我相信您正在寻找的功能是systemjs-builder的Bundle Arithmetic功能。 It is built into SystemJS and works very well.
它内置于SystemJS中,并且运行良好。
However, it will mean using SystemJS to bundle your app instead of a grunt. 但是,这将意味着使用SystemJS捆绑您的应用程序而不是笨拙的东西。
This has many advantages and actually simplifies many scenarios, like your specific use case, but it may take you a little while to get everything set up. 这具有许多优点,并且实际上简化了许多方案,例如您的特定用例,但可能需要一些时间才能完成所有设置。
TypeScript does not support splitting bundles at this time. TypeScript目前不支持拆分包。
Splitting your app into multiple npm packages is not necessary and will introduce significant complexity into development process if your application is small. 无需将您的应用程序拆分为多个npm软件包,如果您的应用程序很小,则将在开发过程中引入极大的复杂性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.