Skip to content

feat: add vite plugin#189

Merged
HugoRCD merged 12 commits intomainfrom
feat/vite-plugin
Mar 15, 2026
Merged

feat: add vite plugin#189
HugoRCD merged 12 commits intomainfrom
feat/vite-plugin

Conversation

@HugoRCD
Copy link
Copy Markdown
Owner

@HugoRCD HugoRCD commented Mar 15, 2026

Summary

  • Introduces evlog/vite — a Vite plugin that brings Nuxt-level DX to any Vite-based framework (React, SvelteKit, Astro, SolidStart, Qwik, etc.)
  • Zero-config auto-initialization via Vite's define — no virtual import or manual initLogger() needed
  • Opt-in auto-imports for log, createEvlogError, parseError with .d.ts generation
  • Build-time log.debug() stripping (production builds only)
  • Source location injection (__source: 'file:line') for the simple log API
  • Client-side auto-init via transformIndexHtml
  • New evlog/client public entrypoint
  • Wires strip + source-location into the Nuxt module via addVitePlugin() (no breaking changes)

Usage

// vite.config.ts
import evlog from 'evlog/vite'

export default defineConfig({
  plugins: [
    evlog({
      service: 'my-api',
      autoImports: true,
      strip: ['debug'],
      sourceLocation: true,
      client: { transport: { enabled: true } },
    }),
  ],
})

Fixes EVL-62

Introduces `evlog/vite` — a Vite plugin that brings Nuxt-level DX to any
Vite-based framework (React, SvelteKit, Astro, SolidStart, etc.).

Features:
- Zero-config auto-init via Vite `define` (no virtual import needed)
- Opt-in auto-imports for `log`, `createEvlogError`, `parseError`
- Build-time log stripping (production only)
- Source location injection (`__source: 'file:line'`)
- Client-side auto-init via `transformIndexHtml`
- `evlog/client` re-export for generic Vite usage

Also wires strip and source-location into the Nuxt module via
`addVitePlugin()` with no breaking changes.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 Mar 15, 2026 2:19pm

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 15, 2026

Thank you for following the naming conventions! 🙏

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 15, 2026

Benchmark report

Bundle size

Threshold: 5% · 🔴 larger · 🟡 warning · 🟢 smaller · ⚪ unchanged · 🆕 new

Status Entry Base (gzip) Current (gzip) Change Raw delta
logger 3.74 kB 3.78 kB +0.9% +75 B
framework/elysia 1.06 kB 1.07 kB +0.3% 0 B
framework/hono 593 B 594 B +0.2% 0 B
framework/next 3.02 kB 3.02 kB +0.0% 0 B
enrichers 1.92 kB 1.92 kB 0.0% 0 B
adapter/posthog 1.48 kB 1.48 kB 0.0% 0 B
utils 1.41 kB 1.41 kB 0.0% 0 B
pipeline 1.35 kB 1.35 kB 0.0% 0 B
browser 1.21 kB 1.21 kB 0.0% 0 B
error 1.21 kB 1.21 kB 0.0% 0 B
workers 960 B 960 B 0.0% 0 B
core (index) 205 B 205 B 0.0% 0 B
types 31 B 31 B 0.0% 0 B
framework/nitro 6.85 kB 6.85 kB -0.0% 0 B
adapter/sentry 2.33 kB 2.33 kB -0.0% 0 B
adapter/otlp 2.09 kB 2.09 kB -0.0% 0 B
framework/sveltekit 1.54 kB 1.54 kB -0.1% 0 B
adapter/axiom 1.30 kB 1.30 kB -0.1% 0 B
framework/nestjs 1.21 kB 1.21 kB -0.1% 0 B
adapter/better-stack 1.08 kB 1.08 kB -0.1% 0 B
framework/fastify 1010 B 1009 B -0.1% 0 B
adapter/fs 1.42 kB 1.41 kB -0.1% 0 B
framework/express 702 B 701 B -0.1% 0 B
toolkit 243 B 242 B -0.4% 0 B
Total 37.87 kB 37.90 kB +0.1% +75 B

@HugoRCD HugoRCD changed the title feat(vite): add vite plugin for build-time DX enhancements feat(vite): add vite plugin Mar 15, 2026
@HugoRCD HugoRCD changed the title feat(vite): add vite plugin feat: add vite plugin Mar 15, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 15, 2026

Merging this PR will degrade performance by 65.13%

⚡ 2 improved benchmarks
❌ 5 (👁 1) regressed benchmarks
✅ 89 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
Firefox Linux 87.7 µs 248.5 µs -64.72%
small payload (2 fields) 98.4 µs 253.7 µs -61.2%
evlog 120.8 µs 276.7 µs -56.33%
winston 591.1 µs 448 µs +31.94%
👁 push 1000 events (no flush) 1.8 ms 2.7 ms -31.95%
with traceparent 337.1 µs 299.6 µs +12.53%
with content-length 79.2 µs 227.2 µs -65.13%

Comparing feat/vite-plugin (45438da) with main (2165483)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (dc19ba4) during the generation of this report, so 2165483 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

- Create examples/vite/ standalone Hono + Vite app showcasing auto-init,
  auto-imports, strip, source-location, and client-inject
- Update examples/sveltekit/ to use evlog/vite plugin, removing manual
  initLogger() call in hooks.server.ts
- Add example:vite script to root package.json
vite-node doesn't serve static files or process index.html.
Replace index.html/client.ts with an inline HTML UI served by Hono,
matching the pattern from the hono example.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 15, 2026

npm i https://pkg.pr.new/evlog@189
npm i https://pkg.pr.new/@evlog/nuxthub@189

commit: 45438da

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an evlog/vite build-time plugin and supporting client entrypoint to improve developer experience in Vite-based apps (auto-init, optional auto-imports, stripping, source locations, and client init), and wires parts of it into the Nuxt module and examples/docs.

Changes:

  • Introduce evlog/vite plugin (auto-init, auto-imports, strip, source location, client inject) plus a new public evlog/client entry.
  • Integrate strip + source-location plugins into the Nuxt module via addVitePlugin().
  • Add Vite-focused tests, docs updates, and new Vite example (plus SvelteKit example switching to Vite plugin auto-init).

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
skills/review-logging-patterns/SKILL.md Documents Vite plugin usage pattern for Vite-based frameworks.
packages/evlog/tsdown.config.ts Adds build entries for vite + client and updates bundling config.
packages/evlog/test/vite/strip.test.ts Tests production stripping of log.*() calls.
packages/evlog/test/vite/source-location.test.ts Tests __source injection behavior.
packages/evlog/test/vite/index.test.ts Tests plugin composition and ordering.
packages/evlog/test/vite/client-inject.test.ts Tests HTML injection for client init.
packages/evlog/test/vite/auto-init.test.ts Tests define-time auto-init config injection.
packages/evlog/test/vite/auto-imports.test.ts Tests symbol detection and auto-import injection.
packages/evlog/src/vite/utils.ts Shared AST walking + transform filtering helpers.
packages/evlog/src/vite/types.ts Public types for Vite plugin options.
packages/evlog/src/vite/strip.ts Implements build-time log-level stripping.
packages/evlog/src/vite/source-location.ts Implements dev/prod __source injection.
packages/evlog/src/vite/index.ts Main evlog/vite entry that returns a plugin array.
packages/evlog/src/vite/client-inject.ts Injects initLog() module script into HTML.
packages/evlog/src/vite/auto-init.ts Injects __EVLOG_CONFIG__ define for auto-init.
packages/evlog/src/vite/auto-imports.ts Adds optional auto-imports + generates auto-imports.d.ts.
packages/evlog/src/nuxt/module.ts Adds Nuxt options for strip/sourceLocation and installs Vite plugins.
packages/evlog/src/logger.ts Auto-inits logger when __EVLOG_CONFIG__ is defined.
packages/evlog/src/client.ts New evlog/client re-export entrypoint.
packages/evlog/package.json Exports ./vite + ./client, adds deps/peer dep updates.
package.json Adds example:vite root script.
examples/vite/vite.config.ts Demonstrates evlog/vite usage.
examples/vite/tsconfig.json TS config for the new Vite example.
examples/vite/src/utils/billing.ts Example utility producing logs for strip/sourceLocation demo.
examples/vite/src/ui.ts Example UI page describing plugin features.
examples/vite/src/server.ts Hono server to exercise example routes/logging.
examples/vite/README.md Documents the Vite example and claimed features.
examples/vite/package.json Adds the new example package and scripts/deps.
examples/sveltekit/vite.config.ts Adds evlog/vite plugin to SvelteKit example.
examples/sveltekit/src/hooks.server.ts Removes manual initLogger() in favor of Vite auto-init.
bun.lock Updates lockfile for new deps/examples.
apps/docs/app/components/features/FeaturePerformance.vue Formatting-only template changes.
AGENTS.md Documents the new Vite plugin and repo structure update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Add dedicated Vite plugin documentation page covering auto-init, debug
stripping, source location, and auto-imports. Update landing page and
framework overview to reference the plugin. Add Vite icon to the
"Your Stack. Covered" section. Update SvelteKit docs to use the Vite
plugin for initialization. Add callouts to Express, Hono, Fastify,
Elysia, and Standalone docs for Vite-based setups.
@HugoRCD HugoRCD marked this pull request as ready for review March 15, 2026 13:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an evlog/vite build-time plugin to the evlog package (plus a new evlog/client entrypoint), updates Nuxt to reuse the same strip/source-location transforms, and expands docs/examples to promote the Vite-based setup.

Changes:

  • Introduces evlog/vite plugin suite: auto-init via define, optional auto-imports + .d.ts generation, optional client HTML injection, production log stripping, and source-location injection.
  • Exposes new public entrypoints/exports (evlog/vite, evlog/client) and wires build + peer deps accordingly.
  • Adds tests, docs, and a new Vite example; updates SvelteKit example/docs to use the Vite plugin instead of manual initLogger().

Reviewed changes

Copilot reviewed 43 out of 45 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
skills/review-logging-patterns/SKILL.md Adds Vite plugin guidance to the “review logging patterns” skill docs.
packages/evlog/tsdown.config.ts Adds build entries for vite + client; updates externals/inlining for new deps.
packages/evlog/test/vite/strip.test.ts Unit tests for the strip transform behavior.
packages/evlog/test/vite/source-location.test.ts Unit tests for source-location injection.
packages/evlog/test/vite/index.test.ts Unit tests for plugin composition + option-driven inclusion/order.
packages/evlog/test/vite/client-inject.test.ts Unit tests for HTML injection plugin.
packages/evlog/test/vite/auto-init.test.ts Unit tests for define-based auto-init config serialization.
packages/evlog/test/vite/auto-imports.test.ts Unit tests for auto-import transform + .d.ts behavior.
packages/evlog/src/vite/utils.ts Shared AST walk + transform filtering utilities for Vite plugins.
packages/evlog/src/vite/types.ts Type definitions for Vite plugin options (autoImports/client/strip/sourceLocation).
packages/evlog/src/vite/strip.ts Implements production stripping of selected log.<level>() calls.
packages/evlog/src/vite/source-location.ts Implements dev/prod source location injection into object-form log calls.
packages/evlog/src/vite/index.ts Main evlog/vite entry: returns ordered plugin array based on options.
packages/evlog/src/vite/client-inject.ts Injects initLog() client boot script via transformIndexHtml.
packages/evlog/src/vite/auto-init.ts Injects __EVLOG_CONFIG__ via Vite define.
packages/evlog/src/vite/auto-imports.ts Adds optional auto-imports + .d.ts generation for chosen symbols.
packages/evlog/src/nuxt/module.ts Adds strip + sourceLocation options and wires them via addVitePlugin().
packages/evlog/src/logger.ts Auto-initializes via __EVLOG_CONFIG__ when present.
packages/evlog/src/client.ts New evlog/client entrypoint re-exporting runtime client log APIs.
packages/evlog/package.json Adds exports/typesVersions + peer deps metadata for ./vite and ./client.
package.json Adds example:vite turbo script.
examples/vite/vite.config.ts New Vite example config using evlog/vite.
examples/vite/tsconfig.json TypeScript config for the new Vite example.
examples/vite/src/utils/billing.ts Example utility that logs info/debug.
examples/vite/src/ui.ts Example HTML UI for calling demo routes and rendering responses.
examples/vite/src/server.ts Example Hono server demonstrating evlog logging + error handling.
examples/vite/README.md Usage + feature overview for the new Vite example.
examples/vite/package.json New example package definition and scripts.
examples/sveltekit/vite.config.ts Adds evlog/vite to SvelteKit example’s Vite config.
examples/sveltekit/src/hooks.server.ts Removes manual initLogger() in favor of Vite-plugin auto-init.
bun.lock Lockfile updates for new deps/packages (vite, magic-string, acorn, example workspace).
apps/docs/content/3.core-concepts/10.vite-plugin.md New docs page for the Vite plugin (features/options/compatibility).
apps/docs/content/2.frameworks/12.standalone.md Adds a callout pointing vite-node users to evlog/vite.
apps/docs/content/2.frameworks/10.elysia.md Mentions Vite plugin as an alternative to manual init; adds callout.
apps/docs/content/2.frameworks/09.fastify.md Mentions Vite plugin as an alternative to manual init; adds callout.
apps/docs/content/2.frameworks/08.hono.md Mentions Vite plugin as an alternative to manual init; adds callout.
apps/docs/content/2.frameworks/07.express.md Mentions Vite plugin as an alternative to manual init; adds callout.
apps/docs/content/2.frameworks/03.sveltekit.md Rewrites setup to use Vite plugin; removes manual init snippets.
apps/docs/content/2.frameworks/00.overview.md Adds a “Vite Plugin” section linking to the new core-concept doc.
apps/docs/content/0.landing.md Mentions Vite plugin capability in landing-page description copy.
apps/docs/app/components/features/FeaturePerformance.vue Formatting-only changes to feature text markup.
apps/docs/app/components/features/FeatureFrameworks.vue Adds Vite as a selectable item/link in frameworks section.
apps/docs/app/assets/icons/vite.svg Adds Vite icon asset for docs UI.
AGENTS.md Documents the new Vite plugin architecture/entrypoints for contributors.
.github/workflows/codspeed.yml Excludes packages/evlog/src/vite/** changes from CodSpeed benchmark triggers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@HugoRCD HugoRCD merged commit d92fb46 into main Mar 15, 2026
15 of 16 checks passed
@HugoRCD HugoRCD deleted the feat/vite-plugin branch March 15, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants