Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9fd3562

Browse filesBrowse files
committed
fix(@angular-devkit/build-angular): only set ngDevMode when script optimizations are enabled
When using the experimental esbuild-based browser application builder, the `ngDevMode` global runtime variable was unintentionally always being set to false due to a previous bug fix that stopped the variable from being replaced with the value of true when script optimizations were disabled. By doing so, the fix caused the imported compiler-cli `GLOBAL_DEFS_FOR_TERSER_WITH_AOT` constant to take precedence which contains an `ngDevMode` value of false. To prevent this situation for development builds where a non-false `ngDevMode` is helpful to surface potential runtime problems, `GLOBAL_DEFS_FOR_TERSER_WITH_AOT` will no longer change the value of `ngDevMode`. This fix does not have any effect on production builds since `ngDevMode` would have been set to false regardless. (cherry picked from commit 310144d)
1 parent ccc8e03 commit 9fd3562
Copy full SHA for 9fd3562

File tree

2 files changed

+8
-0
lines changed
Filter options

2 files changed

+8
-0
lines changed

‎packages/angular_devkit/build_angular/src/builders/browser-esbuild/compiler-plugin.ts

Copy file name to clipboardExpand all lines: packages/angular_devkit/build_angular/src/builders/browser-esbuild/compiler-plugin.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ export function createCompilerPlugin(
192192
// Skip keys that have been manually provided
193193
continue;
194194
}
195+
if (key === 'ngDevMode') {
196+
// ngDevMode is already set based on the builder's script optimization option
197+
continue;
198+
}
195199
// esbuild requires values to be a string (actual strings need to be quoted).
196200
// In this case, all provided values are booleans.
197201
build.initialOptions.define[key] = value.toString();

‎packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts

Copy file name to clipboardExpand all lines: packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ function createCodeBundleOptions(
296296
),
297297
],
298298
define: {
299+
// Only set to false when script optimizations are enabled. It should not be set to true because
300+
// Angular turns `ngDevMode` into an object for development debugging purposes when not defined
301+
// which a constant true value would break.
299302
...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
303+
// Only AOT mode is supported currently
300304
'ngJitMode': 'false',
301305
},
302306
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.