-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Bug Report
In some cases, we want to import from the source code instead of the compiled, which is perfectly implemented by the main
field:
// package.json
{
"main": "./src/index.ts"
}
While it seems not to work at the newly introduced exports
field
🔎 Search Terms
🕗 Version & Regression Information
- This is the behavior in every version (the latest stable and nightly versions) I tried
⏯ Playground Link
This is about the package.json behavior, and the playground seems can't reproduce it.
💻 Code
// the library's package.json
{
"exports": {
".": "./src/index.ts"
}
}
// trying to use this library
import { xxx } from 'my-lib'
🙁 Actual behavior
It would show a ts2037
error message:
Cannot find module 'my-lib' or its corresponding type declarations. ts(2307)
🙂 Expected behavior
Works correctly, just like the main
field's behavior.
vjpr, schallerala and amalitsky
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript