Skip to content

Commit 12d555f

Browse files
committed
refactor(@angular/build): extract esbuild top-level await error string into named constant
1 parent 8c9238e commit 12d555f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/angular/build/src/builders/application/execute-build.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ import { inlineI18n, loadActiveTranslations } from './i18n';
3838
import { NormalizedApplicationBuildOptions } from './options';
3939
import { createComponentStyleBundler, setupBundlerContexts } from './setup-bundling';
4040

41+
/** The esbuild error text prefix used to detect top-level await errors. */
42+
const TOP_LEVEL_AWAIT_ERROR_TEXT =
43+
'Top-level await is not available in the configured target environment';
44+
4145
// eslint-disable-next-line max-lines-per-function
4246
export async function executeBuild(
4347
options: NormalizedApplicationBuildOptions,
@@ -162,11 +166,7 @@ export async function executeBuild(
162166
// the actual reason is that async/await is downleveled for Zone.js compatibility.
163167
if (!isZonelessApp(options.polyfills)) {
164168
for (const error of bundlingResult.errors) {
165-
if (
166-
error.text?.startsWith(
167-
'Top-level await is not available in the configured target environment',
168-
)
169-
) {
169+
if (error.text?.startsWith(TOP_LEVEL_AWAIT_ERROR_TEXT)) {
170170
error.notes = [
171171
{
172172
text:

0 commit comments

Comments
 (0)