-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
[REQUIRED] Environment info
firebase-tools: 12.8.1
Platform: Windows 11
[REQUIRED] Test case
https://github.com/misomarcell/fire-chat/tree/cb090fbc5b6dae4da079cd0b2b3d0ea4b2108ba1
[REQUIRED] Steps to reproduce
- Install the Angular 17.0.0 CLI
- Install the above mentioned version of firebase-tools
- Create a new Angular project with SSR enabled
- Enabled webframeworks with
firebase experiments:enable webframeworks - Init the firebase project using
firebase init - Set up at least one route in
app.routes.ts - Set the rewrite rules in firebase.json to your SSR function:
hosting": [
{
"target": "example-app",
"source": ".",
"rewrites": [
{
"source": "**",
"function": "ssrexampleapp"
}
]
}
]
- Modify
angular.jsonso it builds your browser and server bundles separately:
"build": {
"builder": "@angular-devkit/build-angular:browser",
...
}
"server": {
"builder": "@angular-devkit/build-angular:server",
...
}
- Deploy the application with
firebase deploy --only hosting - Open the generated web.app link and navigate a route other than
/ - It displays an error, usually "Service Unavailable". If you open the logs of your ssr function, you'll see that the error that caused this response is:
TypeError: require(...).app is not a function
at Object.<anonymous> (/workspace/bootstrap.js:1:51)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Which originates from .firebase/example-app/functions/bootstrap.js that was generated by firebase-tools:
exports.handle = require("./dist/server/main.js").app();
[REQUIRED] Expected behavior
Render function works without an exception.
[REQUIRED] Actual behavior
Render function crashes due to the above mentioned exception.
Additional comment
The current firebase-tools library clearly lacks support for Angular 17 and it's renewed way of building the application bundle. Starting from the required modification in angular.json in order to force the firebase CLI to upload the server bundle, all the way to the generated function code is not supported by the cloud running environment or the missing rewrite rule that you need to manually add to firebase.json even tho it's aware that the application has SSR capability.