question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Declaration files don't work with multiple entrypoints

See original GitHub issue

This is my tsup config:

"tsup": {
    "splitting": false,
    "sourcemap": true,
    "clean": true,
    "dts": true,
    "format": [
      "esm",
      "cjs"
    ],
    "entryPoints": [
      "src/index.ts",
      "src/cli/index.ts"
    ]
  },

When I run build, the file dist/index.d.ts only has #!/usr/bin/env node as contents (even though this is not the CLI declaration file), nothing else. There is no file dist/cli/index.d.ts. If I run it with only a single entrypoint: src/index.ts, the dist/index.d.ts file is generated properly to correspond to src/index.ts.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
kristojorgcommented, Jun 17, 2021

Found a workaround:

dts: {
    entry: {
      index: "src/index.ts",
      "src/cli/index": "src/cli/index.ts",
    },
  },

This will create a dist/cli/index.d.ts file as well as a dist/index.d.ts file

1reaction
cyberaliencommented, Oct 22, 2021

My workaround for this issue is this:

  • Using tsc -b to generate .d.ts and .js files with CommonJS syntax.
  • Using esbuild to generate ES modules with .mjs extension.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Exporting declarations for library with multiple entry points
Let's say I'm exporting a library with a file structure like |__ src | |__ index.
Read more >
Bundling with Rollup & multiple entry points - Reddit
So, I'm using Rollup and currently just letting ESBuild output my bundle and Typescript exports .d.ts typing files according to the original ...
Read more >
tsup
Files are written into ./dist . You can bundle multiple files in one go: tsup src/index.ts src/cli.ts. This will output dist/index.js and dist/cli.js...
Read more >
Multiple entry points in create-react-app without ejecting
You can create multiple entry points in create-react-app without ejecting by using an environment variable to conditionally import container ...
Read more >
EntryPoints - Traefik Labs documentation
They can be defined by using a file (YAML or TOML) or CLI arguments. ... If both TCP and UDP are wanted for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found