Skip to content

fix(vite): preserve SSR entry import order when registering manifests - #733

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/ssr-manifest-import-order
Nov 24, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/ssr-manifest-import-order

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Supersedes #725 by @nagahara-naoki and keeps their commit. Their branch doesn't allow edits by maintainers, so the follow-up lands here.

Problem (from #725)

The SSR manifest plugin prepended import … from '@angular/ssr' plus the manifest calls to the server entry. An entry that imports @angular/compiler first (JIT support for externalized libraries) then failed at startup with JIT compilation failed for injectable [class PlatformLocation], because @angular/ssr ran before the compiler.

Fix

Commit 1 (#725): append an import of a generated manifest module to the entry instead. ESM runs it after the entry's own imports and before the entry body constructs the engine.

Commit 2 (follow-up): change how that module is imported and resolved:

before (#725)                               after
import 'virtual:oxc-angular/ssr-manifest'   import "./server.ts?oxc-angular-ssr-manifest"
  → \0virtual:…?entry=src%2Fserver.ts         → /abs/src/server.ts?oxc-angular-ssr-manifest
Case #725 This PR
external keeps every bare import external output keeps import "virtual:…" and Node crashes (ERR_UNSUPPORTED_ESM_URL_SCHEME) bundled
@angular/ssr next to the entry, another copy at the root, bundled manifests set on the root copy, so "manifest is not set" the entry's copy
package with "sideEffects": false kept kept: resolved before Vite's resolver, which would drop it

Tests

  • Build-and-run tests for: import order (from fix(vite): preserve SSR entry import order when registering manifests #725), external-everything config, "sideEffects": false, and an entry in src/ with its own @angular/ssr and main.server.ts (decoys at the root).
  • Each test fails on the code it guards. The order test fails on the base (ssr before compiler). The external and src/ tests fail on fix(vite): preserve SSR entry import order when registering manifests #725 alone. The side-effects test fails without order: 'pre'.
  • The Nitro "inject twice" test now feeds the inlined manifests, so it checks the ɵsetAngularAppManifest guard again.
  • Locally: unit 579/579, SSR e2e (ssr-manifest.spec.ts) 9/9, tsc, oxfmt --check, oxlint --type-aware --type-check.

Known limits (pre-existing, not changed here)

  • With output.preserveModules (or chunking that splits the manifest module out) and an external @angular/compiler, Rolldown writes chunk imports before external imports, so the manifest can still run first. Rolldown reorders the user's own imports the same way.

Closes #725

🤖 Generated with Claude Code

nagahara-naoki and others added 2 commits November 24, 2026 17:31
Follow-up to #725, which appends an import of a virtual manifest module
to the server entry:

- Import `./<entry file>?oxc-angular-ssr-manifest` instead of
  `virtual:oxc-angular/ssr-manifest`. Server configs that keep every bare
  import external turned the bare `virtual:` import into a runtime import
  that Node cannot load.
- The module id is now `<entry path>?oxc-angular-ssr-manifest`, so its
  imports of `@angular/ssr` and the bootstrap resolve from the entry's
  directory. With the `\0virtual:` id, Vite resolved `@angular/ssr` from
  the root, which can be another copy than the one the entry uses.
- Resolve the import before Vite's resolver, which would mark the module
  free of side effects in a `"sideEffects": false` package and drop it.
- Tests: build and run the server for an external-everything config, a
  `"sideEffects": false` package and an entry in `src/` with its own
  `@angular/ssr`; keep the Nitro test on the `ɵsetAngularAppManifest`
  guard by feeding it the inlined manifests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T09:33:53.525176Z f5cb0a0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f5cb0a0efa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn
Brooooooklyn merged commit 4574146 into main Nov 24, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/ssr-manifest-import-order branch November 24, 2026 09:53
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.

2 participants