Skip to content

Detect 'types' fields nested in "exports" #885

Closed

Description

@dmurvihill

Reproduction link or steps

import { defineConfig } from "tsdown";

export default defineConfig({
  entry: "index.ts",
  fixedExtension: false,
  format: {
    esm: {
      outDir: "esm/",
    },
    cjs: {
      outDir: "cjs/",
    },
  },
});

package.json:

{
  "exports": {
    ".": {
      "import": {
        "default": "./esm/index.js",
        "types": "./esm/index.d.ts"
      },
      "require": {
        "default": "./cjs/index.cjs",
        "types": "./cjs/index.d.cts"
      }
    }
  }
}

What is expected?

The construct above should be enough for tsdown to generate types.

What is actually happening?

Types are not generated, since it only looks for types or typings at the top level.

Any additional comments?

One subtlety: if the "." entry contains a "types" field, but the "require" entry does not contain a "types" field, the types should be generated for one module but not the other. Tricky tricky.

Activity

  1. added theissue type on Mar 31, 2026
  2. sxzz commented on Apr 2, 2026

    @sxzz
    Member
  3. dmurvihill commented on Apr 2, 2026

    @dmurvihill
    Author

    Please reopen. The linked comment and related issues and pull requests discuss the export map while this one is about generation of the actual type definition files.

    See this StackBlitz; run npm run build and see that type definitions are not generated even though type entry points are specified.

    Note also that running npx tsdown --dts --exports causes a panic:

    Rolldown panicked. This is a bug in Rolldown, not your code.
    
    thread '<unnamed>' (3) panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/napi-3.8.3/src/tokio_runtime.rs:113:6:
    Access tokio runtime failed in spawn
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    Please report this issue at: https://github.com/rolldown/rolldown/issues/new?template=panic_report.yml
    
  4. reopened this on Apr 3, 2026
  5. added a commit that references this issue on Apr 28, 2026
    82fa153
  6. locked and limited conversation to collaborators on May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions