Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

The same plugin instance is used for dep optimizer multiple times (optimizeDeps.rollupOptions.plugins option) #114

Closed as not planned

Description

@sapphi-red

Describe the bug

This is a problem even when there's a single environment that enables the dep optimizer because the scanner uses the same plugin.

const { plugins: pluginsFromConfig = [], ...rollupOptions } =
environment.config.optimizeDeps.rollupOptions ?? {}
// The plugin pipeline automatically loads the closest tsconfig.json.
// Rolldown reads the tsconfig.json when a ts file is passed to it.
const plugins = await asyncFlatten(arraify(pluginsFromConfig))

const plugins = await asyncFlatten(arraify(pluginsFromConfig))
if (external.length) {
plugins.push(rolldownCjsExternalPlugin(external, platform))
}
plugins.push(...rolldownDepPlugin(environment, flatIdDeps, external))

It's similar to the problem we had with worker.plugins option. In that case, we made the option () => Plugin[] from Plugin[] (vitejs#14685).

Reproduction

const plugins = await asyncFlatten(arraify(pluginsFromConfig))
if (external.length) {
plugins.push(rolldownCjsExternalPlugin(external, platform))
}
plugins.push(...rolldownDepPlugin(environment, flatIdDeps, external))

Steps to reproduce

No response

System Info

For all environments

Used Package Manager

npm

Logs

No response

Validations

Activity

  1. added theissue type on Apr 16, 2025
  2. moved this from Discussing to Later in Team Boardon Apr 30, 2025
  3. sapphi-red commented on Apr 30, 2025

    @sapphi-red
    MemberAuthor

    This isn't a problem for multiple environments because multiple environments have different optimizeDeps.rollupOptions instances.

    The problem we had with worker.plugins option doesn't happen with reusing the plugins for the scanner and the dep optimizer. This is because we run the scanner and the optimizer in serial.

    Closing for now as there's no cases that would cause a problem. We can think about the solution when we find an actual case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions