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

Make code splitting for CJS optional instead of dropping #408

@antfu

Description

@antfu

I have been using tsup for almost all my projects during the past year. I really enjoy the DX and minimal configuration it offers. Thanks so much for this awesome project.

However, the dropping of code splitting for CJS in v5.0 via #403, could be a huge obstacle to me. Giving that the ecosystem is still quite far from taking ESM-only packages, shipping CJS along with ESM seems to be a good transition approach (and this is one of the sweet points of tsup). It could be a common practice to expose some submodules we some reusable logic with the main package, for example, https://github.com/antfu/unplugin-icons/blob/main/src/vite.ts, the lack of CJS code-splitting make all submodules contain the full package content, which will not only make the usage costly but also break functionalities like internal sharing variables.

I do understand the limitation of CJS code-splitting and the reason for dropping it, but I hope this could be somehow delayed by making it disabled by default but able to opt-in optionally. Until the ecosystem catches up, or esbuild implements the naive code-splitting for CJS.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions