'Jest + Typescript Unable to Import Library (tiny-secp256k1)

I am currently using the npm package tiny-secp256k1.

It provides non-default exports of many functions (with type declaration).

No matter how I try to import it, running my test suite. Jest throws:

    /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

I cannot tell if this issue is isolated to the library, or is caused by my configuration. I can import other libraries without complication.

jest.config.ts

export default {
    verbose: true,
    transform: {
        '^.+\\.(ts|tsx)?$': 'ts-jest',
    },
    testPathIgnorePatterns: ['__tests__/helpers'],
};

tsconfig.json

{
    "compilerOptions": {
        "target": "ES2020",
        "module": "commonjs",
        "outDir": "dist",
        "allowJs": false,
        "sourceMap": true,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true
    },
    "exclude": ["__tests__/"]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source