Skip to content

AOT code folding bug in esbuild #26438

@Shosetsu

Description

@Shosetsu

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

16.2.5 (used @angular-devkit/build-angular:browser)

Description

The same foldable source code unable to be folded when using esbuild.
But its worked by build-angular:browser.
If this bug is a feature when using esbuild, please update the description of aot in the guidelines document.

document refer: https://angular.dev/tools/cli/aot-compiler#foldable-syntax

Literal array
['cherries', 'flour', 'sugar']
yes

Array index
ingredients[0]
yes, if target and index are foldable

Minimal Reproduction

Minimal foldable source code:

// in external lib ts file
export const foldable = [{name: "obj1"}, {name: "obj2"}];
export const using = foldable[0];
// in angular application
import { using } from ...
export class AppComponent {
  title = using.name;
}

After ng build ...

17.0.0 (used @angular-devkit/build-angular:application)

  ry = [{ name: "obj1" }, { name: "obj2" }],
  od = ry[0];
  let t = class t {
    constructor() {
      this.title = od.name;
    }
  };

17.0.0 (used @angular-devkit/build-angular:browser)

  bj_name = "obj1";
  class e {
    constructor() {
      this.title = bj_name;
    }
  ...
  }

Exception or Error

No response

Your Environment

Angular CLI: 17.0.0
Node: 18.16.1
Package Manager: npm 9.7.1
OS: win32 x64

Angular: 17.0.2
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0
@angular-devkit/build-angular   17.0.0
@angular-devkit/core            17.0.0
@angular-devkit/schematics      17.0.0
@angular/cli                    17.0.0
@schematics/angular             17.0.0
ng-packagr                      17.0.0
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions