Skip to content

feat: support onLog hook in dev#22941

Open
NgoQuocViet2001 wants to merge 2 commits into
vitejs:mainfrom
NgoQuocViet2001:feat-19937-dev-onlog
Open

feat: support onLog hook in dev#22941
NgoQuocViet2001 wants to merge 2 commits into
vitejs:mainfrom
NgoQuocViet2001:feat-19937-dev-onlog

Conversation

@NgoQuocViet2001

@NgoQuocViet2001 NgoQuocViet2001 commented Jul 15, 2026

Copy link
Copy Markdown

Description

Adds Rollup-compatible onLog hook support to the dev plugin container.

  • routes plugin debug, info, and warn calls through ordered onLog hooks
  • supports filtering with false and re-emitting logs at another level
  • preserves source-plugin metadata and Rollup's PLUGIN_LOG / PLUGIN_WARNING normalization
  • applies the configured log level before evaluating lazy log factories
  • gives options hooks their per-plugin minimal context
  • maps Rolldown's generated LogLevel type through the existing Rolldown.* namespace so bundled type validation passes

Includes regression coverage for filtering, level changes, hook ordering and recursion, source metadata, options-hook logs, and lazy log evaluation.

Fixes #19937.

Validation

  • corepack pnpm run build
  • corepack pnpm exec vitest run packages/vite/src/node/server/__tests__/pluginContainer.spec.ts — 24/24 passed
  • corepack pnpm exec eslint packages/vite/src/node/server/pluginContainer.ts packages/vite/src/node/server/__tests__/pluginContainer.spec.ts packages/vite/rolldown.dts.config.ts
  • corepack pnpm exec oxfmt --check packages/vite/src/node/server/pluginContainer.ts packages/vite/src/node/server/__tests__/pluginContainer.spec.ts packages/vite/rolldown.dts.config.ts
  • git diff --check

@NgoQuocViet2001

Copy link
Copy Markdown
Author

Rebased onto the latest main and fixed the CI build failure. The generated Rolldown LogLevel type is now mapped through the existing Rolldown.* namespace, so bundled type validation passes. Local validation: full monorepo build, 24/24 focused tests, ESLint, and Oxfmt.

@NgoQuocViet2001

Copy link
Copy Markdown
Author

CI retry is now green across Node 20/22/24/26, Ubuntu, macOS, and Windows, including lint and the full build/test matrix. The earlier Node 22 failure was a transient legacy watch test (legacy-styles-only-entry-watch.spec.ts) outside this PR's diff.

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.

Support onLog hook in dev

1 participant