Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/angular/build/src/builders/dev-server/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,15 @@ export async function* serveWithVite(
? browserOptions.polyfills
: [browserOptions.polyfills];

const target = transformSupportedBrowsersToTargets(browsers);
if (!isZonelessApp(polyfills)) {
// Rolldown doesn't have an option to support Zone.js/async-await, so we need to support es2016.
target.push('es2016');
}
// TODO(alanagius): This is a workaround for https://github.com/rolldown/rolldown/issues/10633
const target = isZonelessApp(polyfills) ? ['es2022'] : ['es2016'];

// Once the above issue is fixed, uncomment the below code.
// const target = transformSupportedBrowsersToTargets(browsers);
// if (!isZonelessApp(polyfills)) {
// // Rolldown doesn't have an option to support Zone.js/async-await, so we need to support es2016.
// target.push('es2016');
// }

let ssrMode: ServerSsrMode = ServerSsrMode.NoSsr;
if (
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/build/src/builders/dev-server/vite/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ function createSsrConfig(
prebundleLoaderExtensions: RolldownLoaderOption | undefined,
thirdPartySourcemaps: boolean,
define: ApplicationBuilderInternalOptions['define'],
target: string[],
): Vite.SSROptions {
return {
// Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
noExternal: /.*/,
// Exclude any Node.js built in module and provided dependencies (currently build defined externals)
external: externalMetadata.explicitServer,
optimizeDeps: getDepOptimizationConfig({
target,
// Only enable with caching since it causes prebundle dependencies to be cached
disabled: serverOptions.prebundle === false,
// Exclude any explicitly defined dependencies (currently build defined externals and node.js built-ins)
Expand Down Expand Up @@ -214,6 +216,7 @@ export async function setupServer(
prebundleLoaderExtensions,
thirdPartySourcemaps,
define,
target,
),
plugins: [
createAngularSetupMiddlewaresPlugin({
Expand All @@ -239,6 +242,7 @@ export async function setupServer(
],
// Browser only optimizeDeps. (This does not run for SSR dependencies).
optimizeDeps: getDepOptimizationConfig({
target,
// Only enable with caching since it causes prebundle dependencies to be cached
disabled: serverOptions.prebundle === false,
// Exclude any explicitly defined dependencies (currently build defined externals)
Expand Down
3 changes: 3 additions & 0 deletions packages/angular/build/src/tools/vite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type RolldownLoaderOption = Exclude<
>['moduleTypes'];

export function getDepOptimizationConfig({
target,
disabled,
exclude,
include,
Expand All @@ -56,6 +57,7 @@ export function getDepOptimizationConfig({
thirdPartySourcemaps,
define = {},
}: {
target: string[];
disabled: boolean;
exclude: string[];
include: string[];
Expand All @@ -73,6 +75,7 @@ export function getDepOptimizationConfig({
noDiscovery: disabled,
rolldownOptions: {
transform: {
target,
define,
},
moduleTypes: loader,
Expand Down