I'm getting compilation errors caused by the tree-shaking of lodash.
Follow these steps:
- Update your tsconfig.json to have
allowSyntheticDefaultImports: true
property in compilerOptions. This property allows users to import CommonJS modules as default imports.- If you have compilation error like
TypeError: find_1.default is not a function
when running tests you might need to addesModuleInterop: true
to your compilerOptions. Or you can try Solution #2 from this article.
- If you have compilation error like
- After updates in tsconfig.json change imports of lodash to such way in all files:
import forEach from “lodash/forEach”;