Skip to content

Commit 4970c94

Browse files
authored
chore: update mega app setup to support angular 21 (#6760)
1 parent 9372fa7 commit 4970c94

File tree

6 files changed

+43
-9
lines changed

6 files changed

+43
-9
lines changed

build-system-tests/scripts/mega-app-copy-files.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,27 @@ if [[ "$FRAMEWORK" == 'angular' ]]; then
8585
USE_STANDALONE="false"
8686
fi
8787

88+
# Check if Angular 21+ for zone.js and app.config support
89+
if [[ "$FRAMEWORK_VERSION" == "latest" || "$FRAMEWORK_VERSION" -ge 21 ]]; then
90+
USE_V21_CONFIG="true"
91+
else
92+
USE_V21_CONFIG="false"
93+
fi
94+
8895
if [[ "$USE_STANDALONE" == "true" ]]; then
8996
echo "cp templates/components/angular/app-standalone.component.ts mega-apps/${MEGA_APP_NAME}/src/app/app.component.ts"
9097
cp templates/components/angular/app-standalone.component.ts mega-apps/${MEGA_APP_NAME}/src/app/app.component.ts
9198

92-
echo "cp templates/components/angular/main-standalone.ts mega-apps/${MEGA_APP_NAME}/src/main.ts"
93-
cp templates/components/angular/main-standalone.ts mega-apps/${MEGA_APP_NAME}/src/main.ts
99+
if [[ "$USE_V21_CONFIG" == "true" ]]; then
100+
echo "cp templates/components/angular/main-standalone-v21.ts mega-apps/${MEGA_APP_NAME}/src/main.ts"
101+
cp templates/components/angular/main-standalone-v21.ts mega-apps/${MEGA_APP_NAME}/src/main.ts
102+
103+
echo "cp templates/components/angular/app.config.ts mega-apps/${MEGA_APP_NAME}/src/app/app.config.ts"
104+
cp templates/components/angular/app.config.ts mega-apps/${MEGA_APP_NAME}/src/app/app.config.ts
105+
else
106+
echo "cp templates/components/angular/main-standalone.ts mega-apps/${MEGA_APP_NAME}/src/main.ts"
107+
cp templates/components/angular/main-standalone.ts mega-apps/${MEGA_APP_NAME}/src/main.ts
108+
fi
94109

95110
if [ -f "mega-apps/${MEGA_APP_NAME}/src/app/app.module.ts" ]; then
96111
echo "rm mega-apps/${MEGA_APP_NAME}/src/app/app.module.ts"

build-system-tests/scripts/mega-app-install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ elif [ "$FRAMEWORK" == 'angular' ]; then
9595
# remove angular since it's deprecated https://www.npmjs.com/package/angular
9696
# We've install @amplify/cli when creating the app
9797
DEPENDENCIES="$TAGGED_UI_FRAMEWORK aws-amplify"
98+
99+
# Angular 21+ requires zone.js to be explicitly installed
100+
if [[ "$FRAMEWORK_VERSION" == "latest" || "$FRAMEWORK_VERSION" -ge 21 ]]; then
101+
DEPENDENCIES="$DEPENDENCIES zone.js"
102+
fi
103+
98104
echo "DEPENDENCIES=$DEPENDENCIES"
99105
fi
100106

build-system-tests/scripts/setup-mega-app.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ echo "##################"
8282
echo "# Setup Mega App #"
8383
echo "##################"
8484

85-
# Override Angular latest to v20 until v21 compatibility is resolved
86-
if [ "$FRAMEWORK" == "angular" ] && [ "$BUILD_TOOL" == "angular-cli" ] && [ "$FRAMEWORK_VERSION" == "latest" ] && [ "$BUILD_TOOL_VERSION" == "latest" ]; then
87-
FRAMEWORK_VERSION="20"
88-
BUILD_TOOL_VERSION="20"
89-
echo "Overriding Angular latest to v20 to bypass compatibility issues with v21+"
90-
fi
91-
9285
BASE_OPTIONS="--build-tool $BUILD_TOOL --name $MEGA_APP_NAME --framework $FRAMEWORK --framework-version $FRAMEWORK_VERSION"
9386

9487
# Create mega app
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2+
import { provideRouter } from '@angular/router';
3+
4+
import { routes } from './app.routes';
5+
6+
export const appConfig: ApplicationConfig = {
7+
providers: [
8+
provideZoneChangeDetection({ eventCoalescing: true }),
9+
provideRouter(routes),
10+
],
11+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { AppComponent } from './app/app.component';
3+
import { appConfig } from './app/app.config';
4+
5+
bootstrapApplication(AppComponent, appConfig).catch((err) =>
6+
console.error(err)
7+
);

build-system-tests/templates/components/angular/polifills-appendix.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'zone.js';
2+
13
(window as any).global = window;
24
(window as any).process = {
35
env: { DEBUG: undefined },

0 commit comments

Comments
 (0)