Skip to content

feat!: replace Inertia Vite plugin with @adonisjs/vite serverEntrypoints#88

Open
thetutlage wants to merge 2 commits into
5.xfrom
feat/use-load-server-module
Open

feat!: replace Inertia Vite plugin with @adonisjs/vite serverEntrypoints#88
thetutlage wants to merge 2 commits into
5.xfrom
feat/use-load-server-module

Conversation

@thetutlage
Copy link
Copy Markdown
Member

Summary

  • Drops the @adonisjs/inertia/vite plugin and the ssr.bundle config field.
  • Wires ServerRenderer.render() through the new vite.loadServerModule() API shipped in @adonisjs/vite@6.0.0-next.0.
  • Bumps @adonisjs/vite peer + dev dep to ^6.0.0-next.0, vite dev dep to ^8.0.0.

Why

@adonisjs/vite@6 ships a serverEntrypoints plugin option that owns SSR build configuration, plus vite.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/vite already does. Removing it cuts surface area and prevents the two plugins from fighting over environments.ssr config.

What changes

  • src/server_renderer.ts — collapses to a thin wrapper around vite.loadServerModule(config.ssr.entrypoint). The ModuleRunner ownership, restart-detect on server.environments.ssr swaps, and per-render clearCache are all gone (@adonisjs/vite owns runner lifecycle now; HMR keeps the cache fresh, no manual reset needed).
  • src/types.ts + src/define_config.ts — drop ssr.bundle. SSR bundle file path is no longer user-controlled; the SSR manifest is the source of truth.
  • src/client/vite.ts — deleted. ./vite removed from package exports and tsdown.config.ts entry list.
  • tests/inertia.spec.ts — production-mode SSR test rewritten to set up an SSR manifest under <buildDirectory>/server/.vite/manifest.json instead of pointing ssr.bundle at a file directly.

Migration

In vite.config.ts:

-import inertia from '@adonisjs/inertia/vite'
 import adonisjs from '@adonisjs/vite/client'

 export default defineConfig({
   plugins: [
     adonisjs({
       entrypoints: ['inertia/app/app.tsx'],
+      serverEntrypoints: ['inertia/app/ssr.tsx'],
     }),
-    inertia({ ssr: { enabled: true, entrypoint: 'inertia/app/ssr.tsx' } }),
   ],
 })

In config/inertia.ts:

 export default defineConfig({
   ssr: {
     enabled: true,
     entrypoint: 'inertia/app/ssr.tsx',
-    bundle: 'ssr/ssr.js',
   },
 })

Test plan

  • npm run typecheck clean
  • Full suite green: 172 passed, 4 skipped (186)
  • Manual sanity check against a real Inertia app: dev SSR renders, prod build + load works end-to-end

`@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`.
@thetutlage thetutlage requested a review from Julien-R44 May 10, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant