Skip to content

[Bug]: Rolldown creates unnecessary facade chunks #5726

@wmertens

Description

@wmertens

Reproduction link or steps

rolldown produces unnecessary facade chunks, which causes extra round trips and therefore severely impacts startup time.

https://stackblitz.com/edit/vitejs-rolldown-vite-5gozxfed?file=vite.config.ts

in the repro, run vite build. It creates 2 files with counter in the name, and one of them is a facade chunk.

(relevant code:

      {
        name: 'signature',
        enforce: 'pre',
        resolveId: {
          order: 'pre',
          async handler(id, imp) {
            if (id === './counter.js') {
              console.log('turning counter into a chunk');
              const result = await this.resolve(id, imp, { skipSelf: true });
              if (result) {
                this.emitFile({
                  id: result.id,
                  type: 'chunk',
                  preserveSignature: 'allow-extension',
                });
              }
              return result;
            }
          },
        },
      }

)

What is expected?

Facades are only created when needed

What is actually happening?

Any entry gets a facade

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    rolldown-vite:  7.1.2

Any additional comments?

See rollup/rollup#5891 for how this was solved in rollup.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions