I'm writing a web component using StencilJS. One of the helper classes (ArrayHelper.ts
) which is imported by my component has these import at the top:
import transform from 'lodash/transform';
import isEmpty from 'lodash/isEmpty';
import isEqual from 'lodash/isEqual';
import isObject from 'lodash/isObject';
this all works fine when compiling and serving locally. However, when writing some unit tests and executing them using jest, jest can't resolve these imports properly:
TypeError: isObject_1.default is not a function at Function.Object.
<anonymous>.ArrayHelper.toArray (/mycomponent/ArrayHelper.ts:15:35)
When I change the imports in ArrayHelper.ts
to
import { isEmpty, isEqual, isObject, transform } from 'lodash';
then Jest will succesfully run the tests without problems but then the TS compilation by stencilJS doesn't work any more:
Missing Export: mycomponents/ArrayHelper.js:5:27
'isObject' is not exported by node_modules/lodash/lodash.js
Any ideas how to get these imports right for both situations?