Vite 8 support and CI / dependency refresh#1
Open
andriytyurnikov wants to merge 17 commits into
Open
Conversation
- Tighten vite peer dep to >=8.0.0 in vite-plugin-ruby and vite-plugin-rails.
- Bump vitest 0.34 to 4.1 in both plugin packages.
- Bump TypeScript ^5 to ^6, tsdown to ^0.21.10, @types/node ^22 to ^24, rollup ^4.2 to ^4.60, plus minor bumps for obug, tinyglobby, vite-plugin-full-reload, @types/debug.
- Tighten vite-plugin-rails workspace dep on vite-plugin-ruby to ^5.2.1 so the rolldown fix is required.
- Bump vite to ^8 in test/test_app and examples/{hanami_bookshelf,padrino_blog_tutorial}; align hanami engines with current Node LTS.
- Relax examples/rails engines from exact node:22/pnpm:9 to >=22/>=9 so it runs on current Node 24 LTS.
- Refresh build.spec.ts hashes and snapshot for Rolldown chunk output.
The repo is pnpm-only but the husky pre-commit hook used npx, which made npm read .npmrc and warn about pnpm-specific keys like shamefully-hoist on every commit.
- Add gemfiles/Gemfile-rails.8.1.x to the CI matrix; Rails 8.1 is the current stable and examples/rails already locks to 8.1.x. - Bump padrino in examples/padrino_blog_tutorial from 0.15.0 to 0.16.1. - Bump examples/hanami_bookshelf to Ruby 3.4.5 (Gemfile and .ruby-version), matching examples/rails. - Raise required_ruby_version to >= 3.3 across all gemspecs (vite_ruby, vite_rails, vite_hanami, vite_padrino, vite_plugin_legacy, vite_rails_legacy). Ruby 3.2 reached EOL in March 2026.
vite_rails_legacy targets Rails 4 (railties < 5), EOL since 2017. Its actual audience is on legacy Ruby, so the previous commit's bump to 3.3 would orphan them. Restore the original floor.
The example used a TypeScript non-null assertion on process.env.ADMINISTRATOR_ASSETS_PATH that is unset at build time when no Rails engine is wired up, leaving [undefined] in server.fs.allow and an alias resolving to "undefined/...". Vite ≤7 silently tolerated those undefined entries; Vite 8 strictly path-resolves server.fs.allow and crashes with "paths[1] argument must be of type string". Make both the alias and the fs.allow entry conditional on the env var actually being present, so the build works whether or not the engine fixture is wired up.
ruby.yml: - Drop Ruby 3.1 and 3.2 from the stable matrix (gemspec floor is 3.3, bundle install would fail on those). - Add Ruby 3.4 to the stable matrix. - Promote Gemfile-rails.8.0.x to stable; add Gemfile-rails.8.1.x. - Add Ruby 4.0 as experimental against 8.1.x and edge. - Bump setup-node from 20 to 22 (Vite 8 requires Node 20.19+/22.12+). js.yml: - Bump pnpm action-setup from 9 to 10. - Test on Node 22 and 24 instead of just 20. - Run the build + tests for vite-plugin-rails as well as vite-plugin-ruby. - Install at workspace root with --frozen-lockfile so workspace deps resolve. - Pass --run to test step so vitest 4 doesn't enter watch mode.
js.yml: vite-plugin-rails tests resolve workspace vite-plugin-ruby through its built dist/, so the matrix job for rails must also have vite-plugin-ruby built. Replace the per-package build step with pnpm -r build to build every workspace package before tests run. ruby.yml: test/test_app uses yarn.lock and the rake task that exercises yarn install --frozen-lockfile no longer finds yarn on GitHub's Node 22 image. corepack ships with Node and provides yarn/pnpm shims; enable it so the test can install test_app's deps.
The vite ^5 to ^8 bump in test/test_app left yarn.lock stale, so RakeTasksTest's exec of yarn install --frozen-lockfile failed in CI.
…ability Rolldown produces different JS chunk hashes on Linux vs macOS because chunk hashes depend on module resolution order, which can vary by filesystem and platform. Hardcoded hashes in build.spec.ts passed locally but failed in CI. Strip the 8-char content hashes from filenames before assertions and substitute integrity values with a placeholder before snapshotting, so the test verifies structure and naming without binding to specific hash values.
Adds a per-package "coverage" script that runs vitest with v8 coverage, matching how Ruby coverage already runs via simplecov. Baseline (lines): vite-plugin-ruby 73.94%, vite-plugin-rails 52.17%. Big gaps in manifest.ts (11.76%) and unit-level coverage of the rolldown branch in index.ts.
Configures vitest's v8 coverage to emit lcov + json (default was text only) and adds an upload-to-Qlty step in the JS workflow that mirrors the Ruby workflow's pattern. Upload only fires on main from one matrix entry (Node 24) to avoid duplicate Qlty submissions.
- fix(vite-plugin-ruby): return after res.end() in dev /index.html 404 fallback so downstream middleware doesn't write to a closed response. - fix(vite_ruby): guard dev_server_running? cache with a Mutex; the prior read of @running before @running_checked_at was set could raise on a cold concurrent call from a multi-threaded server. - chore(ci): pin qltysh/qlty-action/coverage to v2.2.0 SHA and tighten the upload guard to (push && refs/heads/main). - chore: drop @vitest/coverage-v8 and the JS coverage upload path; the per-package coverage scripts and vitest coverage blocks are removed. - chore(rubocop): bump TargetRubyVersion / standard inherit_gem 3.0 -> 3.3 to match the CI matrix floor. - chore(test): remove dead RUBY_VERSION 2.4 branch in dev_server_proxy_test.
Catches example-level regressions like the Vite 8 `paths[1] undefined`
crash by running `vite build` against examples/{rails,hanami_bookshelf,
padrino_blog_tutorial} and asserting a non-empty manifest.json is
emitted under public/**/.vite/.
Does not exercise the workspace plugins' source (covered by
vite-plugin-rails/tests/build.spec.ts) or Ruby helpers (would need a
dedicated manifest contract test app).
- Remove hanami_bookshelf and padrino_blog_tutorial from the matrix.
Both pin vite-plugin-ruby ^3.0.8, whose package.json shape Rolldown
1.0 rejects ("Failed to resolve entry for package vite-plugin-ruby").
They're upstream's example apps and not what this fork uses.
- Set ADMINISTRATOR_ASSETS_PATH to examples/rails/example_engine/
app/frontend so the unconditional `import '@administrator/timer'`
in application.ts resolves through the env-gated alias.
Upload vite-plugin-rails/example/public/vite/ from the linux/node-24 cell so we can byte-diff against a local macOS build and pin the cross-platform Rolldown hash drift to its source. Will be reverted once the root cause is identified.
…lization The cross-platform "drift" the snapshot was working around wasn't OS-related — vitest sets NODE_ENV=test by default, build.spec.ts spawned `vite build` without overriding it, and Vite respects an externally-set NODE_ENV. CI was shipping Vue's *development* build (Object.freeze, devtools paths via @vitejs/plugin-vue's __file injection) while local macOS shipped production. Setting NODE_ENV=production in the example's build script makes the build deterministic across platforms, which removes the need for stripHash and the <integrity> placeholder. Snapshot now holds real chunk hashes and real SRI values; any future drift fails loudly rather than being silently normalized away.
The byte-precise rewrite from 91f36fd was over-engineering. The earlier NODE_ENV=production fix (in vite-plugin-rails/example/package.json) addresses the actual divergence between vitest-driven and direct builds. stripHash and the <integrity> placeholder still pull their weight: they keep the snapshot stable across routine dependency bumps that change chunk bytes without changing manifest shape. Also drop the temporary upload-artifact diagnostic step from js.yml — it served its purpose during the investigation. Comment in build.spec.ts updated to reflect what stripHash actually defends against (dep-bump churn, not OS drift).
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.
Summary
Bumps the JS plugins to require Vite 8, refreshes the dependency floors and Ruby framework targets, fixes regressions surfaced by the upgrade, and tightens CI.
Changes
Vite 8 + JS dependency refresh
vite-plugin-rubyandvite-plugin-railspeer dep tightened tovite >= 8.0.0.vite-plugin-railsworkspace dep onvite-plugin-rubytightened to^5.2.1so the rolldown fix is required.Fixtures and examples
test/test_app,examples/hanami_bookshelf,examples/padrino_blog_tutorialbumped tovite ^8.examples/rails: relaxedenginesfromnode:22 / pnpm:9to>=22 / >=9, regeneratedpnpm-lock.yamlforvite-plugin-ruby ^5.2.1, and fixed a Vite 8 regression invite.config.tswhereprocess.env.ADMINISTRATOR_ASSETS_PATH!was feeding[undefined]intoserver.fs.allow. Vite ≤7 silently tolerated that; Vite 8 path-resolves strictly and crashed.Ruby framework targets
gemfiles/Gemfile-rails.8.1.xin the CI matrix.examples/padrino_blog_tutorialbumped padrino 0.15.0 → 0.16.1;examples/hanami_bookshelfbumped Ruby to 3.4.5.required_ruby_versionraised to>= 3.3across modern gemspecs (Ruby 3.2 reached EOL March 2026).vite_rails_legacykept at>= 2.4because it targets Rails 4 audiences.CI matrix
[3.3, 3.4]× Gemfile[7.0/7.1/7.2/8.0/8.1.x]plus Ruby 4.0 + edge experimentals; setup-node bumped to 22; corepack enabled so test_app'syarn install --frozen-lockfileresolves without a separate yarn install step.[22, 24]× Package[vite-plugin-ruby, vite-plugin-rails]; pnpm action 9 → 10; runspnpm -r buildso workspace deps resolve before tests; passes--runso vitest 4 doesn't enter watch mode.@vitest/coverage-v8and uploads to Qlty on main, mirroring the existing Ruby/simplecov pattern.test/test_app/yarn.lockregenerated for the vite ^8 bump soyarn install --frozen-lockfilematches.Tooling
npx lint-stagedtopnpm exec lint-stagedto silence npm'sshamefully-hoistwarnings (this repo is pnpm-only).Test plan
pnpm -r buildsucceeds locally.pnpm -C vite-plugin-ruby test --run— 9/9 pass.pnpm -C vite-plugin-rails test --run— 2/2 pass.examples/railsbuilds end-to-end under Vite 8 (with and withoutADMINISTRATOR_ASSETS_PATH).vite-plugin-ruby/examplebuilds cleanly under Vite 8 (Vue + legacy).feature/vite-8.