Skip to content

[Feature Request]: add support for preserveModules output option #2622

@marcalexiei

Description

@marcalexiei

What problem does this feature solve?

Instead of creating as few chunks as possible,
this mode will create separate chunks for all modules using the original module names as file names.

Use case

I'm using this rollup preserveModules option to build packages inside a mono-repo and I heavy rely on tree shaking to reduce the size of the final app bundle as much as possible.

E.g:
I have a UI package with a single index export which provides a series of components.
In some of the apps I use only one or two of the above mentioned components and I would like that only the code of these components is included in the final bundle.

What does the proposed API look like?

Right know this is implemented by rollup using the following options:

Configuration example:

import { defineConfig } from "rolldown";

export default defineConfig({
  input: ["src/entryA.js", "src/entryB.js"],
  output: {
    dir: "dist",
    preserveModules: true,
    preserveModulesRoot: 'src'
  },
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions