-
Notifications
You must be signed in to change notification settings - Fork 455
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
Support Node16/NodeNext
value for moduleResolution
#4198
Comments
getting this as well after updating to TS 5.2.2 |
I have the same issue. As a temporary workaround I've set module.exports = {
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{ tsconfig: { moduleResolution: "classic" } },
],
},
}; |
The code overrides ts-jest/src/legacy/compiler/ts-compiler.ts Lines 155 to 170 in 9f1439a
|
I'm running into this as well and it looks like it's been a month since the last comment. Is there a fix coming out anytime soon for this? |
This patch fixed this issue for our use-case of using --- ./node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js 2023-11-01 13:05:20.000000000 -0700
+++ ./node_modules/ts-jest/dist/legacy/compiler/ts-compiler.fixed.js 2023-11-01 13:09:38.000000000 -0700
@@ -132,7 +132,7 @@
allowSyntheticDefaultImports = true;
}
else {
- moduleKind = this._ts.ModuleKind.CommonJS;
+ moduleKind = this._compilerOptions.module || this._ts.ModuleKind.CommonJS;
}
this._compilerOptions = __assign(__assign({}, this._compilerOptions), { allowSyntheticDefaultImports: allowSyntheticDefaultImports, esModuleInterop: esModuleInterop, module: moduleKind });
if (this._languageService) {
It seems like |
I am experiencing this as well and @erunion 's patch is fixing this issue for me. |
|
There's a bug in ts-jest that makes jest hang if tsconfig.json has a certain combination of module and moduleResolution values. Fix this by providing a differend tsconfig for ts-node. See kulshekhar/ts-jest#4198 and kulshekhar/ts-jest#4207.
There's a bug in ts-jest that makes jest hang if tsconfig.json has a certain combination of module and moduleResolution values. Fix this by providing a differend tsconfig for ts-node. See kulshekhar/ts-jest#4198 and kulshekhar/ts-jest#4207.
I only encounter the issue if I do:
If I leave out the |
In addition to setting |
Does anyone have a workaround for when your jest config file and global setup files are in TS? It does work if my production tsconfig file sets "noEmitOnError" to false, but I don't really want to do that for production code. But with the ts-jest code seeming to invoke ts-node (from what I read) and using my default tsconfig, some of the above workarounds don't seem to work such as the transform or a custom tsconfig file. Also, is this project dead? There hasn't been a release for over 6 months. I'm trying to figure out if we need to start looking at other projects if this project is indeed no longer being maintained. |
There is currently a bug in ts-node where it completely ignores the `module` and `moduleResolution` options kulshekhar/ts-jest#4198
* feat: migrate to ESM * build: fixup `generate-types` script * build: update `ts-node` config to use ESM * build: disable `verbatimModuleSyntax` for `ts-node` There is currently a bug in ts-node where it completely ignores the `module` and `moduleResolution` options kulshekhar/ts-jest#4198 * test: use ESM export for jest
I came here because I wanted to speed up my I solved by it putting the following into my
I don't fully understand the practical difference between Running a trivial test went from 5 seconds to 1 ms. |
Confirmed that the work in v29 resolves this for us on a |
This fix i breaking our packages.
Can anyone please help me understand what i am doing wrong? I am having issues importing .json files with "import * as xxx from 'x/x/x.json'" |
@drweizak would you please create a reproduce problem with example apps https://github.com/kulshekhar/ts-jest/tree/main/examples It would be easier to investigate. Thank you. |
Thank you for your time! i found out the problem was related how i was importing my files. All is good now :) before: now: |
@drweizak is it related to https://www.typescriptlang.org/tsconfig/#allowSyntheticDefaultImports? We did change a bit the behavior there in ff4b302 |
Node16/NodeNext
value for moduleResolution
* feat: nx migrate and angular update * feat: turn off no-unused-expressions * fix: imports formatting in app.module.ts * feat: update mongodb-memory-server, ical-generator and reflect-metadata * fix: use NodeNext moduleResolution * fix(ci): Node version 22 * revert: upgrade mean-stream/nestx * feat: upgrade @mean-stream/nestx * fix: module NodeNext in tsconfig * feat: pnpm 9.12.0 * feat: NodeNext for tsconfig.spec.json * test: Revert ts-jest to 29.2.3 See: kulshekhar/ts-jest#4198 See: kulshekhar/ts-jest#4552 --------- Co-authored-by: Adrian Kunz <a.kunz@uni-kassel.de>
The issue that I'm encountering is that JSON modules, especially when imported dynamically, do not seem to be resolved the same way as tsc/node when using ts-jest. See https://github.com/kirkwaiblinger/typescript-default-json/ for some examples. It's been hard to figure out what behavior is even correct here, since it touches on
But the ts-jest and tsc/node behavior definitely do not match. Note that the behavior when using swc does more or less seem to match node's runtime behavior: https://github.com/kirkwaiblinger/typescript-default-json/tree/swc-variant |
I've encountered an issue similar to the one @kirkwaiblinger is describing, but not with importing a JSON module. The issue I'm having is actually related to importing the type
|
Version
29.1.1
Steps to reproduce
I have a monorepo setup with multiple apps and libraries. One of the apps (the largest, the only one with
isolatedModules: true
) fails after updating to TS 5.2 with the following error:error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'
.Currently using
@tsconfig/node18/tsconfig.json
for the monorepo base config, which contains the following:The
module
option is overridden byts-jest
:100
instead ofnode16
:dist/legacy/config/config-set.js
in_resolveTsConfig()
100
to1
:dist/legacy/compiler/ts-compiler.js
ingetCompiledOutput()
Expected behavior
I would expect that
module
is not changed.Actual behavior
module
is changed first to100
and later to1
(CommonJs)Debug log
extracted info above
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: