【发布时间】:2019-11-01 00:32:22
【问题描述】:
我编写了一个包装 Highcharts 的 Angular 库以满足我的需求。
在dev模式下本地使用时运行良好,但prod模式的优化似乎打破了它。
问题来自需要添加一些功能的 Highcharts 模块,例如添加新的图表类型(即 TreeMap)。这些模块似乎没有在 prod 模式下加载,导致 Highcharts 错误 (https://www.highcharts.com/errors/17/)。
这是我的第一个 Angular 库,所以配置肯定是错误的,但我找不到问题所在。
我在这个 repo 中推送了该问题的最小重现:https://github.com/Korbraan/angular-library-opti-bug
首先使用ng build charts 构建库,然后尝试使用ng serve --prod 提供它。它坏了,但它适用于ng serve。
【问题讨论】:
-
我已经测试过了。在开发模式以及生产中存在相同的错误:
Cannot find module '../../../../dist/charts' -> import { TreeMapModule } from '../../../../dist/charts'; -
该库需要在应用服务前建好,我在帖子中添加命令。
标签: angular highcharts angular-library