Skip to content

devExports: true doesn't generate subpath exports for unbundled output #752

@brunobely

Description

@brunobely

Reproduction link or steps

  1. Create a tsdown config:
  import { defineConfig } from 'tsdown'

  export default defineConfig({
    entry: ['./src/index.ts'],
    format: ['esm'],
    unbundle: true,
    dts: true,
    exports: {
      devExports: true,
    },
  })
  1. Create this file structure:
  src/
    index.ts
    components/
      text/
        index.ts
  1. Run tsdown. It outputs: dist/
    index.js
    components/
      text/
        index.js
  1. Check package.json. Only main export is generated:
  {
    "exports": {
      ".": "./src/index.ts",
      "./package.json": "./package.json"
    }
  }

What is expected?

devExports: true should generate subpath exports for each unbundled module:

  {
    "exports": {
      ".": "./src/index.ts",
      "./text": "./src/components/text/index.ts"
    },
    "publishConfig": {
      "exports": {
        ".": "./dist/index.js",
        "./text": "./dist/components/text/index.js"
      }
    }
  }

What is actually happening?

Only the main . export is generated. Consumers can't import individual unbundled modules:

  // Doesn't work - no subpath export defined
  import { Text } from '@my-lib/text'

  // Only this works - defeats the purpose of unbundling
  import { Text } from '@my-lib'

Any additional comments?

This makes it hard to build component libraries following modern patterns (Base UI, Radix UI, etc.) where each component is individually importable for better tree-shaking.

Current workaround is setting exports: false and manually maintaining all subpath exports, but that defeats the purpose of devExports: true.

When unbundle: true, it would be useful if devExports scanned the output structure and auto-generated subpath exports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions