-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small cosmetics for
@rep-protocol/vite, found while adopting it in a real Vite SPA.1.
data-rep-versionreported0.0.0getPackageVersion()readpackage.jsonat runtime viaimport.meta.url. When a consumer imports the plugin insidevite.config.ts, Vite bundles the config with esbuild and rewritesimport.meta.url, so the read failed and both the injecteddata-rep-versionattribute and the payload_meta.versionfell back to"0.0.0". (Thenextplugin has the same code but happens to work because it's loaded via a runtimeimport().)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. Verified0.1.15now appears indist/index.mjsand in the injected#__rep__payload.2. Missing README
plugins/nexthas a README;plugins/vitedidn't (which is partly why it went unnoticed in favor of hand-rolled plugins). Added one mirroring thenextplugin's structure, including a note on serving the build with the gateway'sembeddedmode in production.Validation
pnpm --filter @rep-protocol/vite typecheck— cleanpnpm --filter @rep-protocol/vite build— ESM + CJS + DTS succeed; version baked inpnpm --filter @rep-protocol/vite test— 49 passedNo API or behavior change beyond the corrected version string.