Skip to content

AutoImportProvider doesn't use package.json "exports" when moduleResolution=BundlerΒ #52188

Closed
@sarimarton

Description

@sarimarton

Bug Report

πŸ”Ž Search Terms

autoimportprovider bundler

πŸ•— Version & Regression Information

This is related to a 5.0.0@next version feature. TS version in my app: 5.0.0-dev.20230109

⏯ Playground Link

The bug is related to an editor feature, so I don't have a playground link.

πŸ’» Code

App tsconfig.json (note: everything is probably irrelevant here except the "moduleResolution": "Bunder", line):

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "types": ["vite/client"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "paths": {
      "src/*": ["./src/*"]
    }
  },
  "include": ["src"]
}

Company library has a Button (react component) export in the /lib/engie/index.tsx file, here's a library package.json excerpt:

{
  "name": "@company/common",
  ...
  "exports": {
    ".": "./lib/index.tsx",
    "./engie": "./lib/engie/index.tsx"
  },

πŸ™ Actual behavior

When I type <Button in an app source file, VSCode offers the import from @company/common/lib/engie. When I accept the auto import, the import line shows the error "Cannot find module ...". When I manually delete the lib/ part, the error disappears.

πŸ™‚ Expected behavior

VSCode should offer the import from @company/common/engie. When I change app tsconfig moduleResolution to "NodeNext" or "Node16", and I delete the import line from the app source and try again, it offers the correct @company/common/engie path.

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions