I have recently integrated the npm package tiny-secp256k1
into my project.
This package offers non-default exports of various functions, each with type declaration included.
Despite multiple attempts to import it and run my test suite using Jest, I keep encountering the following error:
/pathToProject/node_modules/tiny-secp256k1/lib/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { compare } from "uint8array-tools";
^^^^^^
SyntaxError: Cannot use import statement outside a module
It is unclear whether this issue stems from the library itself or if it is related to my project configuration. Other libraries can be imported without any issues.
Here is an excerpt from my jest.config.ts
:
export default {
verbose: true,
transform: {
'^.+\\.(ts|tsx)?$': 'ts-jest',
},
testPathIgnorePatterns: ['__tests__/helpers'],
};
And here is a snippet from my tsconfig.json
:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "dist",
"allowJs": false,
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"exclude": ["__tests__/"]
}