We are developing a project that uses commonjs. When node-fetch
is updated to v3.x, jest complains that:
import fetch, { RequestInfo, RequestInit, Response } from 'node-fetch';
SyntaxError: Cannot use import statement outside a module
npm run build
succeeds.
If I use node --experimental-vm-modules node_modules/.bin/jest
instead of jest
, I get:
Must use import to load ES Module
I did some reading, it appears that we need to migrate our project to be an ESM as well. But it does not appear to be easy.
So the question is: when a dependency becomes pure ESM, how do we handle that in our code?
FYI, our project is: https://gitlab.com/tezgraph/tezgraph