Skip to content

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

Closed
nagahara-naoki wants to merge 1 commit into
voidzero-dev:mainfrom
nagahara-naoki:fix/ssr-manifest-import-order
Closed

nagahara-naoki wants to merge 1 commit into
voidzero-dev:mainfrom
nagahara-naoki:fix/ssr-manifest-import-order

Conversation

@nagahara-naoki

@nagahara-naoki nagahara-naoki commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Hi everyone!

An SSR entry can import @angular/compiler before @angular/ssr/node to initialize JIT support for externalized Angular libraries. The manifest plugin currently prepends its own import of @angular/ssr. With Angular 21.2.1 this makes the server fail on startup with JIT compilation failed for injectable [class PlatformLocation], even though the entry imports the compiler first.

Changes

Append a static import of a virtual module to the server entry. The entry's original dependencies now evaluate first, then the virtual module registers both manifests before the entry constructs AngularNodeAppEngine. The virtual module resolves Angular and the bootstrap relative to the original entry.

The regression test builds and executes an SSR entry and records the evaluation order. It uses JSX in a .js entry to exercise a custom Rolldown module type.

Checks

  • All 32 tests in ssr-manifest.test.ts passed. On the base commit, the new test records ssr before compiler.
  • Built a minimal app with Angular 21.2.1 and Vite 8.3.4. The built server returned HTTP 200 with the component rendered inside its custom root element.
  • A client-only edit during vite build --app --watch updated the client asset embedded in the server bundle.

Related to #60.

@Brooooooklyn

Copy link
Copy Markdown
Member

Thanks for the fix and the clear repro! A review turned up two cases the virtual: import breaks that worked before (a config that keeps every bare import external, and @angular/ssr resolving from the root instead of the entry). This branch doesn't allow edits by maintainers, so I opened #733. It keeps your commit as is and adds a follow-up commit on top with tests for both cases. We'll land it there, and this one can be closed once #733 merges.

Brooooooklyn added a commit that referenced this pull request Nov 24, 2026
…#733)

* fix(vite): preserve SSR entry import order when registering manifests

* fix(vite): import the SSR manifest module through a relative specifier

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>

---------

Co-authored-by: naoki <0512.naoki.job@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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