-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: can't use ESM with external node modules that export commonjs and moduel files #3800
Comments
Updating to Getting I've tried moving the config from const config = {
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
'#(.*)': '$1'
},
roots: [
'<rootDir>/ts'
],
testEnvironment: 'node',
testMatch: [
'**/ts/?(*.)+(spec|test|integrate|accept|system|unit).[jt]s?(x)'
],
transform: {
'^.+.tsx?$': ['ts-jest', { isolatedModules: true, useESM: true }]
},
transformIgnorePatterns: [
// Need to MANUALLY identify each ESM package, one by one
'node_modules/(?!(assertron|chalk|#ansi-styles)/)'
]
}
module.exports = config The infinite loop in CI is a concern. (e.g. https://github.com/unional/clibuilder/runs/8280815715?check_suite_focus=true) |
|
next tag is the same as 29 no? |
@rbnayax please use |
Have you tried removing |
I did it does not help |
I had the same issue with |
@goums this issue is not related to v28 or v29. This issue already happened to v28 because it's related to TypeScript APIs itself which |
@ahnpnl I'm working on a private repo, so I'm not able to share it unfortunately, but it looks like there are some esm incompatibility issues on ts-jest 29. Maybe you updated some dependency versions or configuration that introduce an incompatibility? just sharing some command line results, without touching anything in the code:
Other versions I'm using:
|
We only compile |
removing the so maybe need to update the docs here: |
Feel free to open a PR to adjust the doc:) |
One (maybe dumb) question, but couldn't / shouldn't the preset include the |
`types` corresponds to `main` only. `main/types` will be completely ignored by Node/TypeScript if `exports` is defined. Related to kulshekhar/ts-jest#3800
@rbnayax this issue will be fixed in the next release of |
Version
29.0.0
Steps to reproduce
yarn
yarn test
Expected behavior
test should pass
Actual behavior
Debug log
link
Additional context
when removing the reference to 3rd party node module, everything works as expected
Environment
The text was updated successfully, but these errors were encountered: