Skip to content

Support Node Package Subpath Pattern Imports #44848

Closed

Description

Bug Report

Typescript ignores Package Subpath Imports breaking the linter when using a loader. These "aliases" are not optional when you have multiple entry points or executables at different levels.

Related to #33079
Making a new bug as the conversation there is about exports... but the import side is also important and has a seperate set of solutions.

🔎 Search Terms

Module alias, import patterns, pwd, es modules, node

🕗 Version & Regression Information

Please keep and fill in the line that best applies:

  • This is the behavior in every version I tried

⏯ Playground Link

Running node 16 with ts-node loader in a native ES Module package.

Coming soon from runkit. Integration issues like this are tricky. But I've got the tools to make it so.

💻 Code

// /package.json
  "imports": {
    "#src/*": "./src/*"
  },
import getMongoClient from '#src/models/mongodb.js'

🙁 Actual behavior

"Cannot find module '#src/models/mongodb.js' or its corresponding type declarations.ts(2307)"

🙂 Expected behavior

Should work like regular javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Domain: ES ModulesThe issue relates to import/export style module behaviorNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions