Import single lodash functions for libraries with aot

亡梦爱人 提交于 2019-12-13 00:42:59

问题


I'm trying to use lodash with the syntax "import * as includes from 'lodash.includes';" so i don't need to install all lodash library and just the functions that I need. Everything works fine but aot. I build my library to use it in other project as a node_modules and when I do ng serve everything works fine but when doing ng serve --aot I got: "Module not found: Error: Can't resolve 'lodash.includes' in etc...". I could solve the problem by installing lodash in my library project and use it with the syntax "import * as _ from 'lodash';" but I'd like to have only the dependencies that I need not the whole lodash library. Any guess?


回答1:


If you don't want to include the entire Lodash library in your Angular project, then you need to use the lodash-es library as a dependency instead of the normal lodash library as a dependency. Just change it in your package.json file and then in each of your references within your project to point to that library instead.



来源:https://stackoverflow.com/questions/49297734/import-single-lodash-functions-for-libraries-with-aot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!