Which @angular/* package(s) are the source of the bug?
compiler-cli, compiler
Is this a regression?
Yes
Description
When building a completely clean, freshly generated Angular 22 project (ng new with SSR enabled), the production build (ng build) fails consistently with a "contents" must be a string or a Uint8Array error.
The project is completely pristine with no custom configurations or other third-party packages.
Key Observations:
- SSR Dependency: The error only occurs when Server-Side Rendering (SSR) is enabled during project generation. If I create the exact same clean project without SSR, the build succeeds.
- Dev Server Works: The development server (ng serve) works perfectly without any issues; it only crashes during ng build.
- Vite 8 / Rolldown Context: In earlier Angular 22 versions using Vite 7 (Rollup), this was not an issue. This freshly generated project uses the newer Vite 8 with the Rolldown bundler. It appears the angular-compiler plugin in esbuild fails to resolve or load these specific UI library modules during the SSR/prerendering build phase under this new architecture.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
✘ [ERROR] "contents" must be a string or a Uint8Array [plugin angular-compiler]
node_modules/esbuild/lib/main.js:534:29:
534 │ if (mustBe !== null) throw new Error(`${quote(key)} must be ${m...
╵ ^
at getFlag (<workspace>/node_modules/esbuild/lib/main.js:534:30)
at requestCallbacks.on-load (<workspace>/node_modules/esbuild/lib/main.js:1559:26)
at async handleRequest (<workspace>/node_modules/esbuild/lib/main.js:909:11)
This error came from the "onLoad" callback registered here:
node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:18:
397 │ build.onLoad({ filter: /\.[cm]?js$/ }, (0, load_resul...
╵ ~~~~~~
at setup (<workspace>/node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:19)
at async handlePlugins (<workspace>/node_modules/esbuild/lib/main.js:1466:20)
The plugin "angular-compiler" was triggered by this import
src/app/shared/components/bs-reuse-tab/reuse-tab-context.service.ts:2:32:
2 │ import { ComponentPortal } from '@angular/cdk/portal';
╵ ~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] "contents" must be a string or a Uint8Array [plugin angular-compiler]
node_modules/esbuild/lib/main.js:534:29:
534 │ if (mustBe !== null) throw new Error(`${quote(key)} must be ${m...
╵ ^
at getFlag (<workspace>/node_modules/esbuild/lib/main.js:534:30)
at requestCallbacks.on-load (<workspace>/node_modules/esbuild/lib/main.js:1559:26)
at async handleRequest (<workspace>/node_modules/esbuild/lib/main.js:909:11)
This error came from the "onLoad" callback registered here:
node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:18:
397 │ build.onLoad({ filter: /\.[cm]?js$/ }, (0, load_resul...
╵ ~~~~~~
at setup (<workspace>/node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:19)
at async handlePlugins (<workspace>/node_modules/esbuild/lib/main.js:1466:20)
The plugin "angular-compiler" was triggered by this import
src/app/shared/components/bs-reuse-tab/reuse-tab.component.ts:7:48:
7 │ import { NzTabComponent, NzTabsComponent } from 'ng-zorro-antd/tabs';
╵ ~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] "contents" must be a string or a Uint8Array [plugin angular-compiler]
node_modules/esbuild/lib/main.js:534:29:
534 │ if (mustBe !== null) throw new Error(`${quote(key)} must be ${m...
╵ ^
at getFlag (<workspace>/node_modules/esbuild/lib/main.js:534:30)
at requestCallbacks.on-load (<workspace>/node_modules/esbuild/lib/main.js:1559:26)
at async handleRequest (<workspace>/node_modules/esbuild/lib/main.js:909:11)
Please provide the environment you discovered this bug in (run ng version)
**Environment:**
Angular CLI : 22.1.3
Node.js : 24.16.0
Package Manager : npm 11.13.0
Operating System : linux x64 (KylinOS, Kernel: 5.4.18.63-generic x86_64)
Anything else?
No response
Which @angular/* package(s) are the source of the bug?
compiler-cli, compiler
Is this a regression?
Yes
Description
When building a completely clean, freshly generated Angular 22 project (ng new with SSR enabled), the production build (ng build) fails consistently with a "contents" must be a string or a Uint8Array error.
The project is completely pristine with no custom configurations or other third-party packages.
Key Observations:
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response