Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(vite): bake in version + add plugin README#54

Open
olamide226 wants to merge 2 commits into
main from
fix/vite-plugin-version-and-readme
Open

fix(vite): bake in version + add plugin README #54
olamide226 wants to merge 2 commits into
main from
fix/vite-plugin-version-and-readme

Conversation

@olamide226

@olamide226 olamide226 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Two small cosmetics for @rep-protocol/vite, found while adopting it in a real Vite SPA.

1. data-rep-version reported 0.0.0

getPackageVersion() read package.json at runtime via import.meta.url. When a consumer imports the plugin inside vite.config.ts, Vite bundles the config with esbuild and rewrites import.meta.url, so the read failed and both the injected data-rep-version attribute and the payload _meta.version fell back to "0.0.0". (The next plugin has the same code but happens to work because it's loaded via a runtime import().)

Fix: inject the version via a tsup define (tsup.config.ts) so it's baked into the bundle at build time, independent of how the consumer loads the plugin. Verified 0.1.15 now appears in dist/index.mjs and in the injected #__rep__ payload.

2. Missing README

plugins/next has a README; plugins/vite didn't (which is partly why it went unnoticed in favor of hand-rolled plugins). Added one mirroring the next plugin's structure, including a note on serving the build with the gateway's embedded mode in production.

Validation

  • pnpm --filter @rep-protocol/vite typecheck — clean
  • pnpm --filter @rep-protocol/vite build — ESM + CJS + DTS succeed; version baked in
  • pnpm --filter @rep-protocol/vite test — 49 passed

No API or behavior change beyond the corrected version string.

getPackageVersion() read package.json at runtime via import.meta.url. When a
consumer imports the plugin inside vite.config.ts, Vite bundles the config with
esbuild and rewrites import.meta.url, so the read failed and the injected
`data-rep-version` (and `_meta.version`) fell back to "0.0.0".
Inject the version via a tsup `define` (tsup.config.ts) so it is baked into the
bundle at build time, independent of how the consumer loads the plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /