Skip to content

Make it possible to disable code splitting #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
tats-u opened this issue Mar 25, 2025 · 10 comments
Open
3 tasks done

Make it possible to disable code splitting #78

tats-u opened this issue Mar 25, 2025 · 10 comments
Labels
enhancement New feature or request

Comments

@tats-u
Copy link

tats-u commented Mar 25, 2025

Clear and concise description of the problem

tsup can disable code splitting by the following config:

import { defineConfig } from "tsup";

export default defineConfig({
  entry: ["./src"],
  format: "esm",
  splitting: false, // !!!!!! HERE !!!!!
  dts: true,
  target: "es2021",
});

However, tsdown doesn't have such a splitting property.
Disabling code splitting improves readability and analyzability of output JS code.

tsup's doc: https://tsup.egoist.dev/#code-splitting

Suggested solution

Support splitting property

Alternative

Use tsup instead of tsdown. tsup has already been able to disable splitting.

Additional context

I tried tsdown in my packages in https://github.com/tats-u/markdown-cjk-friendly/, but gave up due to the lack of this feature.

Validations

@tats-u tats-u added the enhancement New feature or request label Mar 25, 2025
@tats-u tats-u changed the title Make it possible to disable splitting Make it possible to disable code splitting Mar 25, 2025
@sxzz
Copy link
Member

sxzz commented Mar 25, 2025

Now unsupported because of Rolldown

@tats-u
Copy link
Author

tats-u commented Mar 25, 2025

I see.

@tats-u
Copy link
Author

tats-u commented Mar 26, 2025

I found it's not supported in Rollup either.

rollup/rollup#2756

@sxzz
Copy link
Member

sxzz commented Apr 2, 2025

Is there any use cases that need disabling code splitting?

@tats-u
Copy link
Author

tats-u commented Apr 2, 2025

remarkjs/remark#1422

It looks like one of the main maintainers of remark prefer to keep .ts source and built .d.ts/.js 1:1 (one pair of .d.ts/.js per .ts).
He wants library authors to keep the published package source easily-analyzable/debuggable.

@tats-u
Copy link
Author

tats-u commented Apr 2, 2025

I personally prefer to bundle source files into single pair of .d.ts and .js.

By this, a JS runtime has only to open and parse just one JS file.

@sxzz
Copy link
Member

sxzz commented Apr 2, 2025

Maybe preserveModules is more like you needed (but Rolldown haven't implement preserveModules yet)

@tats-u
Copy link
Author

tats-u commented Apr 3, 2025

Is it a Rollup's option? I can't try it today because tsup is basically esbuild-powered. I couldn't find such an option in tsup's website.

@lishaduck
Copy link
Contributor

Is it a Rollup's option?

Yeah, it's this: https://rollupjs.org/configuration-options/#output-preservemodules

@tats-u
Copy link
Author

tats-u commented Apr 10, 2025

I googled it and it looks like what I've wanted. However I can't try it today unfortunately because I don't use Vite or Rollup to build my libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants