Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoneless SSR doen't build when using file polyfill #28898

Open
martin-yumsto opened this issue Nov 19, 2024 · 3 comments
Open

Zoneless SSR doen't build when using file polyfill #28898

martin-yumsto opened this issue Nov 19, 2024 · 3 comments
Labels
angular/build:application area: @angular/build freq1: low Only reported by a handful of users who observe it rarely type: bug/fix

Comments

@martin-yumsto
Copy link

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

No

Description

I'm trying to go zoneless for my SSR angular app with hydration.

This condition seems to cause difficulties to migrate to zoneless for any SSR app that uses file based polyfills:

I guess you are aware of the issue, since there is a todo on the condition that feels too generic:

export function isZonelessApp(polyfills: string[] | undefined): boolean {

Basically it adds zone.js/node import for all the builds that have file polyfill.

Minimal repro would be:

angular.json:
"polyfills": ["@angular/localize/init", "polyfills.ts"]

polyfills.ts
(window as any).global = window; // Amplify

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)

ngular CLI: 19.0.0
Node: 20.17.0
Package Manager: pnpm 8.14.1
OS: darwin arm64

Angular: 19.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.0
@angular-devkit/build-angular   19.0.0
@angular-devkit/core            19.0.0
@angular-devkit/schematics      19.0.0
@schematics/angular             19.0.0
rxjs                            7.5.7
typescript                      5.6.3

Anything else?

No response

@JeanMeche JeanMeche transferred this issue from angular/angular Nov 19, 2024
@e-oz
Copy link

e-oz commented Nov 19, 2024

I didn't get it. My zoneless SSR app builds just fine with v19.

@martin-yumsto
Copy link
Author

@e-oz do you use file based polyfill ?

I just noticed I forgot to include the error log so it's here:

✘ [ERROR] Could not resolve "zone.js/node"

    angular:polyfills-server:angular:polyfills-server:2:7:
      2 │ import 'zone.js/node';

Basically for the server side package build the condition that detects whether it should build zone-based or zoneless app is very generic and it matches "zone.js" or any other js/ts file inside the polyfills array. So I suppose even empty file specified in that array inside angular.json build will cause the error.

@alan-agius4 alan-agius4 added area: @angular/build freq1: low Only reported by a handful of users who observe it rarely labels Nov 20, 2024
@e-oz
Copy link

e-oz commented Nov 20, 2024

polyfills.ts
(window as any).global = window; // Amplify

I guess that this thing alone will throw an exception on the server side.

In my polyfills I have only link to localize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular/build:application area: @angular/build freq1: low Only reported by a handful of users who observe it rarely type: bug/fix
Projects
None yet
Development

No branches or pull requests

4 participants