Skip to content

feat: add warning to discourage Vite with yarn pnp#21906

Merged
sapphi-red merged 1 commit into
vitejs:mainfrom
sapphi-red:feat/discorage-yarn-pnp
Jun 2, 2026
Merged

feat: add warning to discourage Vite with yarn pnp#21906
sapphi-red merged 1 commit into
vitejs:mainfrom
sapphi-red:feat/discorage-yarn-pnp

Conversation

@sapphi-red

@sapphi-red sapphi-red commented Mar 17, 2026

Copy link
Copy Markdown
Member

Adding the following message to discourage people from using yarn pnp with Vite:

Using Yarn PnP with Vite is discouraged and PnP-specific bugs will no longer be actively worked on.
Please switch to a different 'nodeLinker' mode or to a different package manager.

While yarn defaults to yarn pnp when running yarn set version stable, maintaining a dedicated code path to support it has been a consistent maintenance overhead for the Vite team. Given that users can easily opt out of PnP by setting nodeLinker: node-modules in their .yarnrc.yml, I think it is the right call to discourage its use and allocate time on the other areas.

If someone is willing to maintain the yarn pnp support in Vite including all the upstream dependencies and also fixes, #15809, we can remove this warning.

@sapphi-red sapphi-red added this to the 8.1 milestone Mar 17, 2026
@sapphi-red sapphi-red added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 17, 2026
@github-project-automation github-project-automation Bot moved this to Discussing in Team Board Mar 17, 2026
@sapphi-red sapphi-red changed the title feat: add warning to discorage yarn pnp feat: add warning to discourage Vite with yarn pnp Mar 17, 2026
@sapphi-red sapphi-red moved this from Discussing to Approved in Team Board Mar 18, 2026
@wojtekmaj

wojtekmaj commented Mar 18, 2026

Copy link
Copy Markdown

That's understandable but very disappointing. Yarn PnP may not provide the best DX for development, but allows to speed up CI jobs dramatically by avoiding unnecessary I/O (I've seen 20+ seconds saved on each job just by turning on PnP!) and is the easiest way to catch bugs in declared dependencies.

@pkg-pr-new

pkg-pr-new Bot commented Mar 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/plugin-legacy

pnpm add https://pkg.pr.new/@vitejs/plugin-legacy@21906 -D
npm i https://pkg.pr.new/@vitejs/plugin-legacy@21906 -D
yarn add https://pkg.pr.new/@vitejs/plugin-legacy@21906.tgz -D

vite

pnpm add https://pkg.pr.new/vite@21906 -D
npm i https://pkg.pr.new/vite@21906 -D
yarn add https://pkg.pr.new/vite@21906.tgz -D

commit: 833b407

@sapphi-red sapphi-red marked this pull request as ready for review March 19, 2026 04:52
@psychobolt

Copy link
Copy Markdown
Contributor

I propose we take a plugin approach if this is feasible? e.g. vite-plugin-pnp ?

@mrginglymus

Copy link
Copy Markdown
Contributor

Please consider adding a flag to make this warning skippable. I already have an unskippable warning from storybook telling me to stop using Yarn PnP.

As the author of the linked bug (and many others in vite, vitest and storybook relating to pnp support) I'm more than willing to take the risk locally of using PnP, so these warnings are quite annoying noise.

In terms of supporting yarn in vite, I've found that a very trivial plugin to intercept vite:resolve has fixed almost all the compatibility issues I've had personally, and I'd be happy to try and turn that into a published package. I did ask a while back about the possibility of making the vite:resolve plugin a bit more hookable, as currently monkey-patching core plugins is a bit of a pain.

@psychobolt

psychobolt commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

There is somewhat support for PnP in Rolldown: rolldown/rolldown#5147

But with the issues here: #21875 and in rolldown: #21875, what is the bundler ecosystem at play is here?

If support of PnP is not something the teams want to manage, then would it been better to migrate existing support to a external project/plugin (e.g. rolldown) over a warning?

@sapphi-red

Copy link
Copy Markdown
Member Author

You can suppress the warning by using the customLogger option.

Just in case, this PR won't block you from creating a plugin that supports yarn pnp. That plugin can also suppress the warning internally. That said, we cannot provide a dedicated API to hook into the internals of Vite for that plugin as that would be the same with maintaining the dedicated code path.

@sapphi-red sapphi-red merged commit 3fbb55a into vitejs:main Jun 2, 2026
23 checks passed
@sapphi-red sapphi-red deleted the feat/discorage-yarn-pnp branch June 2, 2026 04:15
@Glandos

Glandos commented Jun 15, 2026

Copy link
Copy Markdown

That's sad indeed. No shame on maintainer team, I totally understand the burden.

But JS ecosystem is built on belief that everything's unlimited: bandwidth, disk space, I/O, and sometimes CPU. Since the goal of Vite is speed by efficiency (and thanks a LOT for rolldown), supporting PnP should be a main target: it just avoid wasting 600MB for nothing on each CI job.

@sapphi-red

Copy link
Copy Markdown
Member Author

@Glandos FYI nodeLinker: pnpm has a similar benefit with nodeLinker: pnp.

@Glandos

Glandos commented Jun 23, 2026

Copy link
Copy Markdown

Here is the code to put in vite.config.ts:

const logger = createLogger()
const loggerWarnOnce = logger.warnOnce
logger.warnOnce = (msg, options) => {
  if (msg.includes('Using Yarn PnP with Vite is discouraged and PnP-specific bugs will no longer be actively worked on.')) {
    return
  }
  loggerWarnOnce(msg, options)
}

export default defineConfig({
  customLogger: logger,
}

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

Labels

p2-nice-to-have Not breaking anything but nice to have (priority) trigger: preview

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants