Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): use browserslist when processing …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
clydin authored and alan-agius4 committed Nov 1, 2023
1 parent 08b958d commit 83b4b25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function executeBuild(
// Global Scripts
if (options.globalScripts.length > 0) {
for (const initial of [true, false]) {
const bundleOptions = createGlobalScriptsBundleOptions(options, initial);
const bundleOptions = createGlobalScriptsBundleOptions(options, target, initial);
if (bundleOptions) {
bundlerContexts.push(
new BundlerContext(workspaceRoot, !!options.watch, bundleOptions, () => initial),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { createVirtualModulePlugin } from './virtual-module-plugin';
*/
export function createGlobalScriptsBundleOptions(
options: NormalizedApplicationBuildOptions,
target: string[],
initial: boolean,
): BundlerOptionsFactory | undefined {
const {
Expand Down Expand Up @@ -69,6 +70,7 @@ export function createGlobalScriptsBundleOptions(
sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
write: false,
platform: 'neutral',
target,
preserveSymlinks,
plugins: [
createSourcemapIgnorelistPlugin(),
Expand Down

0 comments on commit 83b4b25

Please sign in to comment.