feat!: replace Inertia Vite plugin with @adonisjs/vite serverEntrypoints#88
Open
thetutlage wants to merge 2 commits into
Open
feat!: replace Inertia Vite plugin with @adonisjs/vite serverEntrypoints#88thetutlage wants to merge 2 commits into
thetutlage wants to merge 2 commits into
Conversation
`@adonisjs/vite@6.0.0-next.0` ships a new `serverEntrypoints` plugin
option that bundles SSR entries into the Vite ssr environment, plus a
`vite.loadServerModule()` runtime API that loads them in dev (through
Vite's module runner) and in production (through the SSR manifest).
That covers everything the Inertia Vite plugin used to do.
- `ServerRenderer.render()` now delegates to `vite.loadServerModule()`.
Drops the per-renderer `ModuleRunner` ownership, the SSR-environment
restart-detect, and the `clearCache` call on every render.
- Drop `src/client/vite.ts` and the `./vite` package export. SSR Vite
configuration moves to the app's `vite.config.ts` via
`adonisjs({ serverEntrypoints: ['inertia/ssr.tsx'] })`.
- Drop `ssr.bundle` from `InertiaConfig`. The bundle file path is no
longer user-controlled — the SSR manifest emitted by Vite is the
source of truth, and `loadServerModule` resolves the entry through
it. `ssr.entrypoint` remains the runtime contract.
- Bump `@adonisjs/vite` peer + dev dep to `^6.0.0-next.0` and `vite`
dev dep to `^8.0.0` (required by the new vite version).
Migration: in `vite.config.ts`, remove the `inertia()` plugin import
and add `serverEntrypoints` to the existing `adonisjs()` plugin call.
In `config/inertia.ts`, remove `ssr.bundle`.
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
@adonisjs/inertia/viteplugin and thessr.bundleconfig field.ServerRenderer.render()through the newvite.loadServerModule()API shipped in@adonisjs/vite@6.0.0-next.0.@adonisjs/vitepeer + dev dep to^6.0.0-next.0,vitedev dep to^8.0.0.Why
@adonisjs/vite@6ships aserverEntrypointsplugin option that owns SSR build configuration, plusvite.loadServerModule()that loads SSR modules in both dev (Vite module runner with HMR-driven cache invalidation) and production (pre-built bundle resolved through the SSR manifest). With that landed, the Inertia-side plugin and bundle plumbing duplicate what@adonisjs/vitealready does. Removing it cuts surface area and prevents the two plugins from fighting overenvironments.ssrconfig.What changes
src/server_renderer.ts— collapses to a thin wrapper aroundvite.loadServerModule(config.ssr.entrypoint). TheModuleRunnerownership, restart-detect onserver.environments.ssrswaps, and per-renderclearCacheare all gone (@adonisjs/viteowns runner lifecycle now; HMR keeps the cache fresh, no manual reset needed).src/types.ts+src/define_config.ts— dropssr.bundle. SSR bundle file path is no longer user-controlled; the SSR manifest is the source of truth.src/client/vite.ts— deleted../viteremoved from package exports andtsdown.config.tsentry list.tests/inertia.spec.ts— production-mode SSR test rewritten to set up an SSR manifest under<buildDirectory>/server/.vite/manifest.jsoninstead of pointingssr.bundleat a file directly.Migration
In
vite.config.ts:In
config/inertia.ts:export default defineConfig({ ssr: { enabled: true, entrypoint: 'inertia/app/ssr.tsx', - bundle: 'ssr/ssr.js', }, })Test plan
npm run typecheckclean