From a1dc3bb5033b8af5ea733c8ea8b79f869401803b Mon Sep 17 00:00:00 2001 From: AleksanderBodurri Date: Sun, 30 Apr 2023 22:49:50 -0400 Subject: [PATCH] build(devtools): target es2020 explicitly (#50086) We do this because of a bug caused by https://github.com/evanw/esbuild/issues/2950 and a recent change to how angular static properties are attached to class constructors. Targeting esnext or es2022 will cause the static initializer blocks that attach these static properties on class constructors to reference a class constructor variable that they do not have access to. Because of this we explicitly target es2020 in our Angular DevTools builds. PR Close #50086 --- devtools/projects/shell-browser/src/BUILD.bazel | 14 ++++++++++++-- devtools/src/BUILD.bazel | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/devtools/projects/shell-browser/src/BUILD.bazel b/devtools/projects/shell-browser/src/BUILD.bazel index a52e84f78a8..b849e1f3fad 100644 --- a/devtools/projects/shell-browser/src/BUILD.bazel +++ b/devtools/projects/shell-browser/src/BUILD.bazel @@ -64,7 +64,12 @@ esbuild( minify = True, platform = "browser", splitting = False, - target = "esnext", + # todo(aleksanderbodurri): here we target es2020 explicitly. + # We do this because of a bug caused by https://github.com/evanw/esbuild/issues/2950 and an Angular v16 change + # to how angular static properties are attached to class constructors. + # Targeting esnext or es2022 will cause the static initializer blocks that attach these static properties on class + # constructors to reference a class constructor variable that they do not have access to. + target = "es2020", deps = LINKER_PROCESSED_FW_PACKAGES + [":src"], ) @@ -76,7 +81,12 @@ esbuild( minify = True, platform = "browser", splitting = False, - target = "esnext", + # todo(aleksanderbodurri): here we target es2020 explicitly. + # We do this because of a bug caused by https://github.com/evanw/esbuild/issues/2950 and an Angular v16 change + # to how angular static properties are attached to class constructors. + # Targeting esnext or es2022 will cause the static initializer blocks that attach these static properties on class + # constructors to reference a class constructor variable that they do not have access to. + target = "es2020", deps = [":devtools"], ) diff --git a/devtools/src/BUILD.bazel b/devtools/src/BUILD.bazel index bbeab0fdf7e..0501830cd43 100644 --- a/devtools/src/BUILD.bazel +++ b/devtools/src/BUILD.bazel @@ -45,7 +45,12 @@ esbuild( entry_points = [":main.ts"], platform = "browser", splitting = True, - target = "es2016", + # todo(aleksanderbodurri): here we target es2020 explicitly. + # We do this because of a bug caused by https://github.com/evanw/esbuild/issues/2950 and an Angular v16 change + # to how angular static properties are attached to class constructors. + # Targeting esnext or es2022 will cause the static initializer blocks that attach these static properties on class + # constructors to reference a class constructor variable that they do not have access to. + target = "es2020", deps = LINKER_PROCESSED_FW_PACKAGES + [":demo"], )