incorrect detection of zoneless app

Abierto
#30,689 10 comentarios 4 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
angular, typescript
Área
build-system, cli

Línea de trabajo

Empieza en packages/angular/build/src/tools/esbuild/utils.ts, en las líneas 469-478, y luego ejecuta el comando de build con un archivo JavaScript o TypeScript en el array de polyfills y zone.js no disponible. Está hecho cuando una aplicación zoneless no se detecta incorrectamente como non-zoneless y el polyfill basado en archivo sigue funcionando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

angular/build:application area: @angular/build freq1: low severity3: broken type: bug/fix
Command

build

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

Including any js/ts file in the polyfills array causes the angular server to incorrectly identify the app as a non-zoneless app. Thus it tries to include zone.js, which is deleted, because I uninstall the package as per the guide.

Minimal Reproduction
Exception or Error

Your Environment
Angular CLI: 20.1.0
Node: 22.14.0
Package Manager: pnpm 10.13.1
OS: linux x64

Angular: 20.1.0
... animations, build, cdk, cli, common, compiler, compiler-cli
... core, forms, language-service, material
... material-luxon-adapter, platform-browser
... platform-browser-dynamic, platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.2001.0
@angular-devkit/build-angular   20.1.0
@angular-devkit/core            20.1.0
@angular-devkit/schematics      20.1.0
@schematics/angular             20.0.6
ng-packagr                      20.0.1
rxjs                            7.8.1
typescript                      5.8.3
Anything else relevant?
TLDR

This is essentially a re-open of #28898. Developers are forced to avoid adding any js/ts file to the polyfills array. Instead, they have to create js scripts inline inside index.html, or write js files, and include them as assets with index.html


The problem is within these lines:
https://github.com/angular/angular-cli/blob/2c3a46b9ecf69049fbddb2c912636d9d62e197df/packages/angular/build/src/tools/esbuild/utils.ts#L469-L478

The presence of any js/ts file in the polyfills array causes zone to be included, even though I uninstalled zone.js and do everything zone-less-ly.

I had a file called polyfill-buffer.ts which I used to add to the polyfill array:

import { Buffer } from 'buffer';

if (!globalThis.Buffer) {
  Object.assign(globalThis, { Buffer });
}

Now I have to add it to index.html as a script

import { Buffer } from 'https://cdn.jsdelivr.net/npm/buffer/+esm';

if (!globalThis.Buffer) {
  Object.assign(globalThis, { Buffer });
}

This is maintainable for small scripts like these. But it eliminates the possibility of using any file-based polyfill stuff.

Lenguaje dominante
TypeScript
Estrellas
27k
Forks
11.8k
Merge medio
16 h 35 min
PR fusionados (30 d)
176

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de angular/angular-cli

Todos los issues de angular/angular-cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.