简体   繁体   English

运输服务模块angular 2

[英]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.

相关问题 Angular,服务和模块依赖性混淆 - Angular, services, and module dependency confusion 无法动态转换ES模块System.config({transpile:'transpile-module'}) - Unable to dynamically transpile ES module System.config({ transpile: 'transpile-module'}) Babel Transpile systemjs模块会跳过特定模块吗? - Babel transpile systemjs module skip specific modules? 简单的转译和 node_module 导入 - Simple transpile & node_module imports 如何转换ES模块附带的node_module依赖关系? - How to transpile node_module dependencies coming as ES module? Angular JS错误:[$ injector:nomod]模块'portfolioMockupApp.services'不可用 - Angular JS Error: [$injector:nomod] Module 'portfolioMockupApp.services' is not available 如何分别在angular.js中编写控制器,服务,路由和模块? - How to write seperatly the controller, services, routes and module in angular.js? 在AngularJS模块中包装javascript类并注入角度服务的正确方法 - Correct way of wrapping javascript class in AngularJS module and inject angular services angular js:是否需要将所有控制器和工厂/服务加载到模块文件中 - angular js : Is it necessary to load all the controllers and factories / services in module file Angular JS-是否有在同一模块中一起使用服务和工厂的用例 - Angular JS - Is there any usecase for using services and factories together in same module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM