adonisjs / adonisjs/vite

Align SSR build output with loadServerModule

Open
#42 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
49
Forks
8
Avg merge
2d 15h
Merged PRs (30d)
2

Description

Hey! 👋🏻

Problem

When serverEntryPoints are configured, the plugin allows overriding the SSR outDir, manifest, and rolldownOptions.input. Vite honors these options during the build.

However, Vite.loadServerModule() always reads <buildDirectory>/server/.vite/manifest.json. A customized SSR build can therefore succeed but fail when AdonisJS tries to load it in production.

Vite does not provide a production module loader for this. It expects frameworks to import their emitted server bundles directly.

Possible solutions

Reserve the SSR build contract

Make serverEntryPoints own outDir, manifest, and input. Reject incompatible overrides with a clear configuration error instead of silently ignoring them.

This is simple, but breaks users who intentionally customize their SSR output.

Generate an AdonisJS server module map

Preserve the Vite overrides and generate a small mapping from source entries to the files actually emitted by the SSR build. loadServerModule() would read this mapping instead of assuming a fixed Vite manifest location.

The mapping could live at <buildDirectory>/.vite/server-modules.json. Using .adonisjs is less suitable because the Assembler excludes that directory from production builds.

This keeps the existing customization behavior, but requires additional build metadata and resolver logic.


I believe the second solution look the best, but it means we own the mapping.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the serverEntryPoints handling and Vite.loadServerModule behavior, focusing on how SSR outDir, manifest, and rolldownOptions.input are applied. Compare the two proposed approaches and determine where build metadata could be generated and consumed. Done means customized SSR output remains supported and production module loading resolves emitted server bundles without assuming the fixed Vite manifest path.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
backend, build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.