Jest cannot recognize bundled file
Mingx94 opened this issue · comments
// utils
import memoize from "proxy-memoize";
export const getOptions = memoize((x) => {
if (!x.Options) {
return [];
}
return x.Options.map((o) => ({
value: o.Value,
text: o.Text
}));
});
// utils.test.js
import { getOptions } from "./utils";
describe("package", () => {
it("will throw error", () => {
let options = getOptions({ Options: [{ Value: 1, Text: 2 }] });
expect(options).toEqual([{ value: 1, text: 2 }]);
});
});
Jest will show this error
TypeError: (0 , _proxyMemoize.default) is not a function
I'm searching the solution all day and found nothing.
Thanks for the workaround!
@dai-shi not sure if this helps but I've read that this issue can be caused by circular dependencies. It seems unlikely that there could possibly be circular deps between valtio and this but this came up when I was looking at this problem yesterday: kulshekhar/ts-jest#1873 (comment)
The issue is ES default export handling. But, circular dependencies might be somehow related. Thanks for the link.
So what is the solution?
We don't know how to fix it properly on our end.
A workaround is something like this.
Thanks. Will give it a try