Skip to content

Commit

Permalink
fix(@angular/build): handle esbuild-browser polyfills option as `st…
Browse files Browse the repository at this point in the history
…ring` during `ng serve`

With `esbuild-browser` the `polyfills` option can be a string which was not handled properly.

Closes #27693
  • Loading branch information
alan-agius4 authored and clydin committed May 23, 2024
1 parent a82a741 commit dd06768
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ export async function* serveWithVite(
const { root = '' } = await context.getProjectMetadata(projectName);
const projectRoot = join(context.workspaceRoot, root as string);
const browsers = getSupportedBrowsers(projectRoot, context.logger);

const target = transformSupportedBrowsersToTargets(browsers);
// Needed for browser-esbuild as polyfills can be a string.
const polyfills = Array.isArray((browserOptions.polyfills ??= []))
? browserOptions.polyfills
: [browserOptions.polyfills];

// Setup server and start listening
const serverConfiguration = await setupServer(
Expand All @@ -260,7 +265,7 @@ export async function* serveWithVite(
!!browserOptions.ssr,
prebundleTransformer,
target,
isZonelessApp(browserOptions.polyfills),
isZonelessApp(polyfills),
browserOptions.loader as EsbuildLoaderOption | undefined,
extensions?.middleware,
transformers?.indexHtml,
Expand Down

0 comments on commit dd06768

Please sign in to comment.