-
Notifications
You must be signed in to change notification settings - Fork 459
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]: global-setup and esm do not work when importing relatively #4127
Comments
Worked for me adding In real world |
Or without any changes in (Indeed buggy. That should throw an error.) |
that is not possible, then typescript complains that the extension is missing in esm |
This is not something |
@mrazauskas But it wont compile with {
"extends": "./tsconfig.json",
"compilerOptions": {
"allowImportingTsExtensions": false,
"noEmit": false
},
"include": ["src/**/*"],
"exclude": ["tests/**/*"]
}
It still doesnt compile with the tsconfig.build.json because i have imported everything like EDIT: I found https://www.npmjs.com/package/babel-plugin-add-import-extension which could be integrated into ts-jest as a starting point. |
I don't have references handy but for server-side TS code I think the consensus is now to add .js extensions to relative imports. It's a hassle and I'm not sure the tooling is totally there yet. I filed #4013 to document this approach but I haven't had time to put together a PR -- I just got back to working on related projects this week. |
Try with
I think "consensus" is not the right word here. Sure, let's import non-existent files - that makes perfect sense... |
Anyway, I'm experiencing a similar issue, not sure if related but here goes:
It just started happening, and it doesn't provide a trace or anything. So far I've narrowed down to: if I comment out a certain function call in the function exported by Of course, I tried digging through |
Version
29.1.0
Steps to reproduce
yarn install
)yarn jest
Expected behavior
i expect the import to work like in commonjs
Actual behavior
error about not being able to import the given file
Debug log
Additional context
already tried to use
ts-jest-resolver
as a resolver and also tried using presetts-jest/presets/default-esm
and setting the options manually, also tried various options from ESM SupportEnvironment
System: OS: Linux 6.3 Manjaro Linux CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor Binaries: Node: 19.9.0 - /tmp/yarn--1683548400265-0.7148494764630906/node Yarn: 1.22.19 - /tmp/yarn--1683548400265-0.7148494764630906/yarn npm: 5.1.0 - /mnt/projects/nodejs/ts-jest_test/node_modules/.bin/npm npmPackages: jest: ^29.5.0 => 29.5.0
The text was updated successfully, but these errors were encountered: