Skip to content

Commit 83b4b25

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): use browserslist when processing global scripts in application builder
When using the `scripts` option with the esbuild-based builders (`application`/`browser-esbuild`), the JavaScript code from the scripts will now be processed based on the targets provided in the application's browserslist file. This prevents unsupported syntax from being present in the output script chunk that is generated. (cherry picked from commit 2aa55ec)
1 parent 08b958d commit 83b4b25

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/angular_devkit/build_angular/src/builders/application/execute-build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export async function executeBuild(
108108
// Global Scripts
109109
if (options.globalScripts.length > 0) {
110110
for (const initial of [true, false]) {
111-
const bundleOptions = createGlobalScriptsBundleOptions(options, initial);
111+
const bundleOptions = createGlobalScriptsBundleOptions(options, target, initial);
112112
if (bundleOptions) {
113113
bundlerContexts.push(
114114
new BundlerContext(workspaceRoot, !!options.watch, bundleOptions, () => initial),

packages/angular_devkit/build_angular/src/tools/esbuild/global-scripts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { createVirtualModulePlugin } from './virtual-module-plugin';
2525
*/
2626
export function createGlobalScriptsBundleOptions(
2727
options: NormalizedApplicationBuildOptions,
28+
target: string[],
2829
initial: boolean,
2930
): BundlerOptionsFactory | undefined {
3031
const {
@@ -69,6 +70,7 @@ export function createGlobalScriptsBundleOptions(
6970
sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
7071
write: false,
7172
platform: 'neutral',
73+
target,
7274
preserveSymlinks,
7375
plugins: [
7476
createSourcemapIgnorelistPlugin(),

0 commit comments

Comments
 (0)