mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-25 00:31:36 +08:00
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.
This commit is contained in:
parent
bb74a21114
commit
2aa55ec096
@ -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),
|
||||
|
@ -25,6 +25,7 @@ import { createVirtualModulePlugin } from './virtual-module-plugin';
|
||||
*/
|
||||
export function createGlobalScriptsBundleOptions(
|
||||
options: NormalizedApplicationBuildOptions,
|
||||
target: string[],
|
||||
initial: boolean,
|
||||
): BundlerOptionsFactory | undefined {
|
||||
const {
|
||||
@ -69,6 +70,7 @@ export function createGlobalScriptsBundleOptions(
|
||||
sourcemap: sourcemapOptions.scripts && (sourcemapOptions.hidden ? 'external' : true),
|
||||
write: false,
|
||||
platform: 'neutral',
|
||||
target,
|
||||
preserveSymlinks,
|
||||
plugins: [
|
||||
createSourcemapIgnorelistPlugin(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user