Skip to content

fix(config): forward top-level input to implicit build.ssr environment (fix #23847) - #23850

Closed
szupzj18 wants to merge 1 commit into
vitejs:mainfrom
szupzj18:chris/fix/ssr-lib-top-level-input
Closed

szupzj18 wants to merge 1 commit into
vitejs:mainfrom
szupzj18:chris/fix/ssr-lib-top-level-input

Conversation

@szupzj18

Copy link
Copy Markdown

Description

When a build uses library mode together with the deprecated build.ssr option and specifies only the top-level input (no build.lib.entry), the build fails with:

Either "build.lib.entry" or the top-level "input" option is required when "build.lib" is set.

even though the top-level input is provided, and the same config builds fine once build.ssr is removed.

Root cause

During config resolution, the implicit ssr environment created for the deprecated build.ssr option was instantiated as an empty object, whereas the client environment inherits the top-level input. As a result, build.lib.entry could not be defaulted to the top-level input inside the SSR environment, and resolveRolldownOptions threw the error above.

The top-level input is intentionally not inherited by the SSR environment in dev (SSR entries come dynamically through ssrLoadModule there), so the fix only forwards it for the implicit build-time SSR environment.

Change

Forward the top-level input to the implicit SSR environment when building via build.ssr, mirroring how the client environment inherits it. This also fixes the non-library case (where the missing input previously fell through to index.html and raised the "input should not be an html file when building for SSR" error).

Closes #23847

Validation

  • New unit test asserting the top-level input is forwarded to the implicit build.ssr environment and defaults build.lib.entry (failed before the fix, passes after).
  • Full pnpm run test-unit: 1043 passed, 3 skipped.
  • Manually verified with a minimal reproduction (input + build.lib + build.ssr: true): fails on main, builds with the change; the non-library SSR build and the legacy build.ssr: '<entry>' form behave unchanged.

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.

Top-level input is ignored when build.ssr is enabled with build.lib

1 participant