【发布时间】:2018-09-17 06:36:57
【问题描述】:
我们的设置:
- 角 5.2.x
- 离子 4.4.x.
- Webpack 3.6.x
我们有一个这样的应用结构:
app
|__features
| |__Feature1
| | |__Feature1Service.ts
| | |__Feature1Dto.ts
| | |__index.ts
| |
| |__Feature2
| |__Feature2Service.ts
| |__Feature2Dto.ts
| |__index.ts
|
|__core
|__SomeCoreStuff.ts
|__index.ts
在索引文件中,我们导出当前功能之外所需的所有内容,如下所示:
import { Feature1Service } from './Feature1Service';
import { Feature1Dto } from './Feature1Dto';
export const fromFeature1 = { Feature1Service, Feature1Dto };
然后用法看起来像这样,例如在功能 2 中:
import { fromFeature1 } from '../Feature1';
//use Feature1Service but not Feature1Dto
fromFeature1.Feature1Service;
在这种情况下,仅使用const fromFeature1 上的一个属性。
我们的问题是 webpack 的 treeshaking 是否会剥离未使用的导出(在本例中为 Feature1Dto)。如果不是,这会炸毁我们部署的 js 包吗?
【问题讨论】:
标签: angular typescript ionic-framework webpack