-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
--module nodenext self-name references don't work with an outDir from clean build #46762
Comments
The package.json here is {
"name": "@localrepo/ts",
"type": "module",
"exports": {
".": "./dist/index.js"
},
"dependencies": {
"@types/node": "^16.11.7",
"typescript": "^4.6.0-dev.20211110"
}
} The self-name reference works but resolves to |
Hi, this is definitely a problem for enabling module self-reference as advertised in TypeScript 4.5, cf. this situation: #38675 (comment) Thanks for the fix and hopefully we'll get it soon! |
Don’t know if this was discussed but this almost feels like project reference to ourself with using source files instead of .d.ts files and mimicking that they are present for module resolution like we do through tsserver .. may be a solution could be to use that for own tsconfig ? |
Maybe as a workaround, but that's a bit far from first-class support for what is now a core node resolution feature. |
Thanks a lot @weswigham I can't wait to try it! |
Thanks for this @weswigham 🙌 ❤️ The fix/feature is out in |
From @benjie at #44501 (comment):
Hello, your beta announcements are asking for feedback on this feature. First of all - I'm super excited about this! Great work!
One thing I was really looking forward to in Node.js exports/ESM support was having example files that import from the library itself - this way we can just say
import { foo } from "my-module"
rather thanimport { foo } from ".." /* TODO: replace this with "my-module" */
- makes it much easier for users to copy/paste examples whilst keeping the examples co-located inside the package.Node.js supports this "self-referencing" behaviour; however TypeScript doesn't seem to understand how to import this in
module:"nodenext"
mode - acould not find a declaration file for module 'my-module'
error is raised.I've prepared a minimal reproduction here with
js
folder working using Node.js and analogousts
folder which is not working with TypeScript (won't compile):https://github.com/benjie/typescript-self-referencing-issue
TSConfig:
TypeScript version
4.6.0-dev.20211110
Maybe this relates to #46212?
Thanks for your hard work on TypeScript ❤️
Originally posted by @benjie in #44501 (comment)
The text was updated successfully, but these errors were encountered: