Skip to content

fix(@angular-devkit/build-angular): workaround for esbuild static block AOT generated code#25132

Merged
angular-robot[bot] merged 1 commit intoangular:mainfrom
clydin:esbuild/workaround-static-blocks
May 8, 2023
Merged

fix(@angular-devkit/build-angular): workaround for esbuild static block AOT generated code#25132
angular-robot[bot] merged 1 commit intoangular:mainfrom
clydin:esbuild/workaround-static-blocks

Conversation

@clydin
Copy link
Member

@clydin clydin commented May 4, 2023

esbuild currently has a defect involving self-referencing a class within a static code block or static field initializer. This is not an issue for projects that use the default browserslist as these elements are an ES2022 feature which is not support by all browsers in the default list. However, if a custom browserslist is used that only has newer browsers than the static code elements may be present. This issue is compounded by the default usage of the tsconfig "useDefineForClassFields": false option present in generated CLI projects which causes static code blocks to be used instead of static fields. esbuild currently unconditionally downlevels all static fields in top-level classes so to workaround the Angular issue only static code blocks are disabled here.

Fixes #25127

…ck AOT generated code

esbuild currently has a defect involving self-referencing a class within a static code block or
static field initializer. This is not an issue for projects that use the default browserslist as these
elements are an ES2022 feature which is not support by all browsers in the default list. However, if a
custom browserslist is used that only has newer browsers than the static code elements may be present.
This issue is compounded by the default usage of the tsconfig `"useDefineForClassFields": false` option
present in generated CLI projects which causes static code blocks to be used instead of static fields.
esbuild currently unconditionally downlevels all static fields in top-level classes so to workaround the
Angular issue only static code blocks are disabled here.

Fixes angular#25127
@clydin clydin added the target: patch This PR is targeted for the next patch release label May 4, 2023
@clydin clydin requested a review from alan-agius4 May 4, 2023 17:42
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 4, 2023
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 5, 2023
@angular-robot angular-robot bot merged commit 3aa1c4e into angular:main May 8, 2023
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

esbuild ng serve results in "ApplicationInitStatus is undefined" run-time error

2 participants