Version
27.4.7
Steps to reproduce
- Clone https://github.com/Robin-Hoodie/tiny-secp256k1-repro
yarn install
yarn test:ts
Expected behavior
I expect jest to see the cjs modules pointed to in package.json for tiny-secp256k1
See https://github.com/bitcoinjs/tiny-secp256k1/blob/v2.2.0/package.json#L14-L30
exports["."].node.require in the package.json points to cjs (we ship both cjs AND mjs with mjs as the default (.js extension))
I would expect Jest to notice that "I am a node environment and need require not import, so I will load the cjs"
Actual behavior
Jest tries to load the mjs (.js) files and fails with SyntaxError: Cannot use import statement outside a module
Additional context
No response
Environment
System:
OS: macOS 11.6.1
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: 3.1.1 - ~/.nvm/versions/node/v14.18.1/bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Version
27.4.7
Steps to reproduce
yarn installyarn test:tsExpected behavior
I expect jest to see the cjs modules pointed to in
package.jsonfortiny-secp256k1See https://github.com/bitcoinjs/tiny-secp256k1/blob/v2.2.0/package.json#L14-L30
exports["."].node.requirein the package.json points to cjs (we ship both cjs AND mjs with mjs as the default (.js extension))I would expect Jest to notice that "I am a node environment and need require not import, so I will load the cjs"
Actual behavior
Jest tries to load the mjs (.js) files and fails with
SyntaxError: Cannot use import statement outside a moduleAdditional context
No response
Environment
System: OS: macOS 11.6.1 CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz Binaries: Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node Yarn: 3.1.1 - ~/.nvm/versions/node/v14.18.1/bin/yarn npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm