Skip to content

fix: support default and reqHandler exports in Angular #8145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 8, 2025
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Added code generation of React hooks for Data Connect
- Genkit init improvements around gcloud login and flow input values.
- Fixes symbol generation when uploading Unity 6 symbols to Crashlytics.
- Fixed SSR issues in Angular 19 by adding support for default and reqHandler exports. (#8145)
- Added Angular 19 as supported version. (#8145)
17 changes: 11 additions & 6 deletions src/frameworks/angular/index.ts
Original file line number Diff line number Diff line change
@@ -36,21 +36,21 @@

const DEFAULT_BUILD_SCRIPT = ["ng build"];

export const supportedRange = "16 - 18";
export const supportedRange = "16 - 19";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export async function discover(dir: string): Promise<Discovery | undefined> {

Check warning on line 41 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Missing JSDoc comment
if (!(await pathExists(join(dir, "package.json")))) return;
if (!(await pathExists(join(dir, "angular.json")))) return;
const version = getAngularVersion(dir);
return { mayWantBackend: true, version };
}

export function init(setup: any, config: any) {

Check warning on line 48 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 48 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Missing JSDoc comment

Check warning on line 48 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 48 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Unexpected any. Specify a different type
execSync(
`npx --yes -p @angular/cli@"${supportedRange}" ng new ${setup.projectId} --directory ${setup.hosting.source} --skip-git`,

Check warning on line 50 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 50 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Unsafe member access .projectId on an `any` value

Check warning on line 50 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 50 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Unsafe member access .hosting on an `any` value
{
stdio: "inherit",
cwd: config.projectDir,

Check warning on line 53 in src/frameworks/angular/index.ts

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
},
);
return Promise.resolve();
@@ -243,19 +243,24 @@
};\n`;
} else if (serverOutputPath) {
bootstrapScript = `
const app = new Promise((resolve) => {
const app = new Promise((resolve, reject) => {
setTimeout(() => {
const port = process.env.PORT;
const socket = 'express.sock';
process.env.PORT = socket;

${
serverEntry?.endsWith(".mjs")
? `import(\`./${serverOutputPath}/${serverEntry}\`)`
: `Promise.resolve(require('./${serverOutputPath}/${serverEntry}'))`
}.then(({ app }) => {
process.env.PORT = port;
resolve(app());
}.then(({ default: defHandler, reqHandler, app }) => {
const handler = app?.() ?? reqHandler ?? defHandler;
if (!handler) {
reject(\`The file at "./${serverOutputPath}/${serverEntry}" did not export a valid request handler. Expected exports: 'app', 'default', or 'reqHandler'.\`);
} else {
process.env.PORT = port;
resolve(handler);
}
});
}, 0);
});
Loading