用于SystemJS映射的Webpack解决方案 [英] Webpack solution for SystemJS mapping

查看:101
本文介绍了用于SystemJS映射的Webpack解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AngularCLI的发布放弃了SystemJS,转而使用WebPack.

The release of AngularCLI abandon SystemJS in favor of WebPack.

但是,那里的Angular EJ2库中SyncFusion还不支持WebPack.他们指示使用SystemJS进行映射

However SyncFusion hasn't supported WebPack yet in there EJ2 library for Angular. They instruct to use SystemJS to map

"@syncfusion/ej2-grids": "node_modules/@syncfusion/ej2-grids/dist/ej2-grids.umd.min.js",
"@syncfusion/ej2-ng-grids": "node_modules/@syncfusion/ej2-ng-grids/dist/ej2-ng-grids.umd.min.js",

在本教程中 http://ej2.syncfusion.com/angular/documentation/grid/getting-started.html#configuring-system-js

在等待SyncFusion支持它时,如何解决这种依赖关系并使其与WebPack兼容?

How can I work around this dependency and make it compatible with WebPack while waiting for SyncFusion to support it?

推荐答案

在Webpack中使用 resolve.alias :

Same thing is done in Webpack with resolve.alias:

...
resolve: {
  alias: {
    "@syncfusion/ej2-grids$": "@syncfusion/ej2-grids/dist/ej2-grids.umd.min.js",
    ...
}

之所以在SystemJS中使用映射,是因为可以传输单个预构建的UMD文件,而不是传输和构建单独的文件.对于Webpack,这不是问题.虽然UMD模块可以稍微加快处理速度,但使用软件包中未捆绑的ES6模块(如果有)可以使用树状抖动,并可以减少应用程序占用空间.

The reason why mappings are used in SystemJS is that a single prebuilt UMD file can be transferred instead of transfering and building separate files. This is not an issue for Webpack. While UMD module can speed up the process a bit, using unbundled ES6 modules from a package (if available) allows to use tree shaking and may reduce application footprint.

这篇关于用于SystemJS映射的Webpack解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆