问题
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