Skip to content

Module resolution: wildcard exports don't work without file extensions when "moduleResolution": "bundler" #62909

@Scalahansolo

Description

@Scalahansolo

Demo Repo

https://github.com/Scalahansolo/wild-card-exports

Which of the following problems are you reporting?

The module specifier resolves at runtime, but not at build time

Demonstrate the defect described above with a code sample.

With a shared library in the monorepo...

{
  "name": "@repo/library",
  "version": "1.0.0",
  "type": "module",
  "exports": {
    "./*": "./src/*"
  }
}

I would expect to be able to import the files from this package like so...

import { greet } from "@repo/library/utils";
import { Component } from "@repo/library/component";

Run tsc --showConfig and paste its output here

{
    "compilerOptions": {
        "target": "es2024",
        "module": "preserve",
        "moduleResolution": "bundler",
        "strict": true,
        "skipLibCheck": true,
        "jsx": "react-jsx",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "resolvePackageJsonExports": true,
        "resolvePackageJsonImports": true,
        "resolveJsonModule": true,
        "useDefineForClassFields": true,
        "noImplicitAny": true,
        "noImplicitThis": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "strictBindCallApply": true,
        "strictPropertyInitialization": true,
        "strictBuiltinIteratorReturn": true,
        "alwaysStrict": true,
        "useUnknownInCatchVariables": true
    },
    "files": [
        "./src/index.ts"
    ],
    "include": [
        "src"
    ]
}

Run tsc --traceResolution and paste its output here

src/index.ts:1:23 - error TS2307: Cannot find module '@repo/library/utils' or its corresponding type declarations.

1 import { greet } from "@repo/library/utils";
                        ~~~~~~~~~~~~~~~~~~~~~

src/index.ts:2:27 - error TS2307: Cannot find module '@repo/library/component' or its corresponding type declarations.

2 import { Component } from "@repo/library/component";
                            ~~~~~~~~~~~~~~~~~~~~~~~~~


Found 2 errors in the same file, starting at: src/index.ts:1

Paste the package.json of the importing module, if it exists

{
  "name": "@repo/app",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "tsc": "tsc"
  },
  "dependencies": {
    "@repo/library": "*",
    "@types/react": "19.2.7",
    "react": "19.2.3",
    "typescript": "5.9.3"
  }
}

Paste the package.json of the target module, if it exists

{
  "name": "@repo/library",
  "version": "1.0.0",
  "type": "module",
  "exports": {
    "./*": "./src/*"
  }
}

Any other comments can go here

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions