使用aot导入库的单个lodash函数

问题描述 投票:1回答:1

我正在尝试使用lodash语法“import * as includes from'lodash.includes';”所以我不需要安装所有lodash库,只需要安装我需要的功能。一切都很好但是很好。我构建我的库以在其他项目中使用它作为node_modules并且当我做服务时一切正常但是当做服务时 - 我得到了:“找不到模块:错误:无法解析'lodash.includes'in等等...”。我可以通过在我的库项目中安装lodash来解决问题,并使用语法“import * as _ from'lodash';”但我想只有我不需要整个lodash库的依赖项。有什么猜测?

angular lodash angular5 angular2-aot aot
1个回答
3
投票

如果您不想在Angular项目中包含整个Lodash库,那么您需要使用lodash-es库作为依赖项而不是普通的lodash库作为依赖项。只需在package.json文件中更改它,然后在项目中的每个引用中更改它以指向该库。

© www.soinside.com 2019 - 2024. All rights reserved.