-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
TS 5 Regression. tsconfig extends stop resolving references to node_modules #53314
Comments
This is most likely because |
I don't think we consider I think what we need is the layout of whatever |
The reason I said is because I hit this problem when upgrading to 5.0 and I fixed it by adding an entry to the |
Oh, very interesting! |
I think this is a bug, AFAIK |
Subpath exports are not specific to ESM. |
And considering this to be a bug and "fixing" it is also a breaking change. |
"breaking change" does not include undoing accidental changes back to the prior behavior. That's an unusable definition. |
I don't want to discuss the semantics of breaking changes. Of course I accept that fixing bug might be a desirable breaking change, that was my initial point. But maybe there's a middle ground where the lookup is done in the standard way (looking at the exports field) and then falling back to the directory structure as it did before. |
IDK if this is useful for the conversation and for debugging, but I had my "exports": {
// ...
"./*.json": "./lib/*.json"
// ...
} And I still get the "File not found" error when trying to import it from other packages, which indeed is a regression from my point of view, but also indicates that the fix isn't "just using exports," because the "*" syntax is valid, and also having to specify file by file in the exports field is kinda unrealistic. Hope I'm adding something useful to the conversation and this isn't just unwanted noise. |
I just upgraded to TS 5 and found the same issue with one of my own node packages ( repo, npm). With TS 5 I now get the error
Needless to say that I did not change any bit in the project where I'm using the node package. Just upgrading to TS 5 broke the import. I played a bit with other node module resolution settings, but nothing helped. What sticks out when looking in the bundled node package is that there's no index.js file in the root folder. All the code is in the Update: I solved the issue by setting the |
@mike-lischke This issue is about tsconfig's extends clause. Your issue is unrelated; please file a separate issue. |
Hi, sorry for not answering sooner. What @ilogico said seems reasonable as a workaround, adding the config file as an export entry in the package.json of the library. We don't have it there and maybe this is the way to enforce it to be "exportable". Thanks for the tip. However, the current TS 5.0.2 behaviour is a regression to what previous 4.x did. So here's the point, as I didn't see a 5.0 changelog announcing this as a breaking change (and the corresponding how-to fix), I assume this is a legit regression bug. Thanks to all who have contributed to the post. Sorry if I didn't add a fully reproducible environment, I though it was straighforward case. Anyway, here's the part of the package.json and the capture of the library structure
|
Yes, note the label on the issue. |
Even if it is intentional, is still "broken", because as I mentioned in my previous comment, the "*" exports don't work. So #50955 doesn't fully support the |
Yeah, it looks like the exports pattern trailer feature flag is just missing. |
We decided this was intentional, minus the wildcard issue, which I’ll put up a fix for shortly. If a package wants to make its tsconfig.json available for extending, and has an |
Hello. Apologies if this is a silly question, but is this fix for wildcard exports going to be part of Typescript 5.0.3? I checked the milestones page for 5.0.3 and 5.1.0 and it wasn't part of it. I also tested the fix with // package.json
{
"name": "@repo/config",
"exports": {
"./*.json": {
"require": "./typescript/*.json"
}
}
}
// tsconfig.json (elsewhere in the monorepo)
{
"extends": "@repo/config/typescript/tsconfig.browser.json",
}
// ❌ File '@repo/config/typescript/tsconfig.browser.json' not found. Essentially all I am asking is when is this going to be available in nightly or main versions of TS? Cheers! |
The fix is already available in nightly. I just had the bot open a PR to pull the fix back into 5.0, since I think we wanted that. If it's not working in nightly, then that's a problem. |
Apologies for the false alarm. After spending some more time to setup everything from scratch on a clean repository, I got the nightly version to work correctly with wildcards, so the fix is indeed working.
Just one quick question if you don't mind - if I understand correctly, this means that when the next version of Typescript releases (5.0.3), this fix will be included in it, and until then I can use nightly versions? Cheers! |
If we take it, 5.0.3. |
I am not entirely certain what to "take it" means, but nevertheless I appreciate the response and your help. Will just be keeping an eye on the release notes. Cheers again! 👍 |
See #53557. @DanielRosenwasser "If" was a little too loose; we definitely wanted this to be backported to 5.0, per design meeting discussion. We just have to merge the cherry-pick before release. |
TypeScript used to be able to resolve the extends field in `tsconfig.json` using the node require algorithm. Recent versions of TypeScript have a regression that means that if a module has an exports map, the extendable typescript config file has to be in that exports map so add it here. Refs: microsoft/TypeScript#53314
TypeScript used to be able to resolve the extends field in `tsconfig.json` using the node require algorithm. Recent versions of TypeScript have a regression that means that if a module has an exports map, the extendable typescript config file has to be in that exports map so add it here. Refs: microsoft/TypeScript#53314
Still experiencing the same issue. Was this fully resolved? |
Yes, we also noticed the regression in 5.3.2 (while it was working in 5.2.2). |
The original issue here is most definitely fixed. If you are having a problem in a recent release, please file a new issue. If you are using ts-node, maybe you are seeing #56492. |
It turned out to be exactly that, thank you for the pointer 🙏 |
yes facing the same issue |
Please open a new issue with repro steps if you're having a problem |
Bug Report
🔎 Search Terms
TS 5, tsconfig, extends, node modules
🕗 Version & Regression Information
5.0.2
In latest stable build, 4.9.5, tsconfig extends resolve correctly references to libraries on node modules. However, after trying out 5.0.2 it has stop working
⏯ Playground Link
No Playground, I quickly check and there is no support for tsconfig, package.json,...
💻 Code
No code, it's just configuration. Having a package.json declaring
and a tsconfig with:
"extends": "@mylibrary/commons/configs/tsconfig.backend.json",
🙁 Actual behavior
The command
tsc --build
finish with error:🙂 Expected behavior
The command
tsc --build
finish correctly.The text was updated successfully, but these errors were encountered: