Skip to content

Commit ba70a50

Browse files
alan-agius4clydin
authored andcommittedMay 23, 2024·
fix(@angular/build): handle esbuild-browser polyfills option as string during ng serve
With `esbuild-browser` the `polyfills` option can be a string which was not handled properly. Closes #27693 (cherry picked from commit dd06768)
1 parent 7d253e9 commit ba70a50

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎packages/angular/build/src/builders/dev-server/vite-server.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,12 @@ export async function* serveWithVite(
248248
const { root = '' } = await context.getProjectMetadata(projectName);
249249
const projectRoot = join(context.workspaceRoot, root as string);
250250
const browsers = getSupportedBrowsers(projectRoot, context.logger);
251+
251252
const target = transformSupportedBrowsersToTargets(browsers);
253+
// Needed for browser-esbuild as polyfills can be a string.
254+
const polyfills = Array.isArray((browserOptions.polyfills ??= []))
255+
? browserOptions.polyfills
256+
: [browserOptions.polyfills];
252257

253258
// Setup server and start listening
254259
const serverConfiguration = await setupServer(
@@ -260,7 +265,7 @@ export async function* serveWithVite(
260265
!!browserOptions.ssr,
261266
prebundleTransformer,
262267
target,
263-
isZonelessApp(browserOptions.polyfills),
268+
isZonelessApp(polyfills),
264269
browserOptions.loader as EsbuildLoaderOption | undefined,
265270
extensions?.middleware,
266271
transformers?.indexHtml,

0 commit comments

Comments
 (0)
Please sign in to comment.