Skip to content

docs: clarify lazy plugin side effects#1841

Open
leno23 wants to merge 1 commit into
voidzero-dev:mainfrom
leno23:codex/docs-lazy-plugins-background-1580
Open

docs: clarify lazy plugin side effects#1841
leno23 wants to merge 1 commit into
voidzero-dev:mainfrom
leno23:codex/docs-lazy-plugins-background-1580

Conversation

@leno23

@leno23 leno23 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • clarify that eager Vite plugins can affect editor integrations, language servers, and background tooling
  • recommend lazyPlugins for plugins with setup-time side effects

Addresses #1580 by covering the LSP/background-process case in the troubleshooting guidance.

Verification

  • pnpm exec oxfmt --check docs/guide/troubleshooting.md
  • node -e "const fs=require('fs'); const text=fs.readFileSync('docs/guide/troubleshooting.md','utf8'); for (const s of ['long-lived tooling processes','editor integrations','format or lint language servers','lazyPlugins']) if (!text.includes(s)) throw new Error('missing '+s); console.log('lazy plugin docs ok')"

@netlify

netlify Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview ready!

Name Link
🔨 Latest commit 8104d7e
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a2fbd752289b3000876ff54
😎 Deploy Preview https://deploy-preview-1841--viteplus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8104d7e2cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/guide/troubleshooting.md

```ts [vite.config.ts]
import { defineConfig } from 'vite-plus';
import { defineConfig } from "vite-plus";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the format replacement of single quotes be reverted? These should not need changes.

Comment on lines 70 to 74
When `vite.config.ts` imports heavy plugins at the top level, every `import` is evaluated eagerly, even for commands like `vp lint` or `vp fmt` that don't need those plugins. This can make config loading noticeably slow.

Eager plugins can also run unexpected side effects in long-lived tooling processes, such as editor integrations, format or lint language servers, and background workers. If a plugin touches the file system, starts a watcher, reads environment-specific files, or talks to a service during setup, prefer loading it through `lazyPlugins` so those side effects only happen for commands that actually execute the Vite pipeline.

Use `lazyPlugins` to wrap plugin loading. Plugins are only loaded for commands that need them (`dev`, `build`, `test`, `preview`), and skipped for everything else:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added guidance is useful, but the new paragraph feels a bit dense. I’d suggest merging the background-process and side-effect examples into a shorter version:

Suggested change
When `vite.config.ts` imports heavy plugins at the top level, every `import` is evaluated eagerly, even for commands like `vp lint` or `vp fmt` that don't need those plugins. This can make config loading noticeably slow.
Eager plugins can also run unexpected side effects in long-lived tooling processes, such as editor integrations, format or lint language servers, and background workers. If a plugin touches the file system, starts a watcher, reads environment-specific files, or talks to a service during setup, prefer loading it through `lazyPlugins` so those side effects only happen for commands that actually execute the Vite pipeline.
Use `lazyPlugins` to wrap plugin loading. Plugins are only loaded for commands that need them (`dev`, `build`, `test`, `preview`), and skipped for everything else:
When `vite.config.ts` imports plugins at the top level, they are evaluated for every command, including `vp lint`, `vp fmt`, editor integrations, and long-lived background processes. This can make config loading slow and may trigger plugin setup side effects, such as reading files, starting watchers, or connecting to services.
Use `lazyPlugins` to load plugins only when the Vite pipeline actually runs (`dev`, `build`, `test`, `preview`):

This keeps the same intent while making the guidance easier to scan.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants