这是indexloc提供的服务,不要输入任何密码
Skip to content

Include/Generate declaration files for bundled external libraries #1368

@shaharkedar

Description

@shaharkedar

We're trying to use tsup to bundle typebox (which is an ESM only library) into a CommonJS library. This works well for the code itself, however we also need to include or generate the type declaration files of typebox to allow its types propagate to consumers.

Is there a way of doing that? It seems that just enabled dts doesn't do the trick.

This is the configuration file I'm using:

import { defineConfig } from 'tsup'

export default defineConfig({
  entry: ['src/index.ts'],
  format: ['cjs', 'esm'],
  dts: {
    tsconfig: './tsconfig.lib.json',
  },
  sourcemap: true,
  clean: true,
  splitting: false,
  treeshake: true,
  minify: false,
  target: 'es2022',
  noExternal: ['typebox'],
  esbuildOptions(options) {
    options.conditions = ['module']
  },
})

Using tsup version 8.5.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions