Skip to content
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

Build-time prerendering not working anymore in Angular 19 #28959

Closed
lucawalter opened this issue Nov 23, 2024 · 3 comments
Closed

Build-time prerendering not working anymore in Angular 19 #28959

lucawalter opened this issue Nov 23, 2024 · 3 comments

Comments

@lucawalter
Copy link

lucawalter commented Nov 23, 2024

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

In Angular 18, I used SSG Build-time Prerendering by following this documentation: (https://angular.dev/guide/prerendering) I added a script to generate a routes.txt. The routes from the routes.txt have been prerendered without any problems. After updating to Angular 19, the build fails with following error message, although I did not change anything in my angular.json and also did not add a renderMode:

The ':uid' route uses prerendering and includes parameters, but 'getPrerenderParams' is missing. Please define 'getPrerenderParams' function for this route in your server routing configuration or specify a different 'renderMode'.

Isn't this way of prerendering not available anymore?

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

The ':uid' route uses prerendering and includes parameters, but 'getPrerenderParams' is missing. Please define 'getPrerenderParams' function for this route in your server routing configuration or specify a different 'renderMode'.

Please provide the environment you discovered this bug in (run ng version)

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "cli": {
        "packageManager": "yarn"
    },
    "newProjectRoot": "projects",
    "projects": {
        "dummy-project": {
            "projectType": "application",
            "schematics": {
                "@schematics/angular:component": {
                    "style": "scss",
                    "skipTests": true
                },
                "@schematics/angular:class": {
                    "skipTests": true
                },
                "@schematics/angular:directive": {
                    "skipTests": true
                },
                "@schematics/angular:guard": {
                    "skipTests": true
                },
                "@schematics/angular:interceptor": {
                    "skipTests": true
                },
                "@schematics/angular:pipe": {
                    "skipTests": true
                },
                "@schematics/angular:resolver": {
                    "skipTests": true
                },
                "@schematics/angular:service": {
                    "skipTests": true
                }
            },
            "root": "",
            "sourceRoot": "src",
            "prefix": "app",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:application",
                    "options": {
                        "outputPath": "dist/dummy-project",
                        "aot": true,
                        "index": "src/index.html",
                        "browser": "src/main.ts",
                        "polyfills": ["zone.js"],
                        "tsConfig": "tsconfig.app.json",
                        "inlineStyleLanguage": "scss",
                        "assets": ["src/favicon.ico", "src/assets"],
                        "styles": ["@angular/material/prebuilt-themes/azure-blue.css", "src/styles.scss"],
                        "scripts": [],
                        "stylePreprocessorOptions": {
                            "includePaths": ["src"],
                        },
                        "server": "src/main.server.ts",
                        "prerender": {
                            "routesFile": "routes.txt",
                            "discoverRoutes": true
                        },
                        "ssr": {
                            "entry": "server.ts"
                        }
                    },
                    "configurations": {
                        "production": {
                            "optimization": true,
                            "sourceMap": false,
                            "budgets": [
                                {
                                    "type": "initial",
                                    "maximumWarning": "500kb",
                                    "maximumError": "1mb"
                                },
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "2kb",
                                    "maximumError": "4kb"
                                }
                            ],
                            "outputHashing": "all",
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.prod.ts"
                                }
                            ],
                            "assets": ["src/assets", "src/.htaccess", "src/robots.txt"]
                        },
                        "development": {
                            "optimization": false,
                            "extractLicenses": false,
                            "sourceMap": true
                        }
                    },
                    "defaultConfiguration": "development"
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "configurations": {
                        "production": {
                            "buildTarget": "dummy-project:build:production"
                        },
                        "development": {
                            "buildTarget": "dummy-project:build:development"
                        }
                    },
                    "defaultConfiguration": "development"
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "buildTarget": "dummy-project:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "polyfills": ["zone.js", "zone.js/testing"],
                        "tsConfig": "tsconfig.spec.json",
                        "inlineStyleLanguage": "scss",
                        "assets": ["src/favicon.ico", "src/assets"],
                        "styles": ["@angular/material/prebuilt-themes/azure-blue.css", "src/styles.scss"],
                        "scripts": []
                    }
                }
            }
        }
    }
}


"@angular/animations": "^19.0.0",
    "@angular/cdk": "18.2.2",
    "@angular/common": "^19.0.0",
    "@angular/compiler": "^19.0.0",
    "@angular/core": "^19.0.0",
    "@angular/forms": "^19.0.0",
    "@angular/platform-browser": "^19.0.0",
    "@angular/platform-browser-dynamic": "^19.0.0",
    "@angular/platform-server": "^19.0.0",
    "@angular/router": "^19.0.0",
    "@angular/ssr": "^19.0.1",

Anything else?

No response

@e-oz

This comment has been minimized.

@lucawalter
Copy link
Author

lucawalter commented Nov 25, 2024

In this documentation https://angular.dev/guide/prerendering , nobody explains that I have do define Server Routes. I just want to have the build-time Prerendering behaviour with txt. file

@lucawalter lucawalter reopened this Nov 25, 2024
@JeanMeche JeanMeche transferred this issue from angular/angular Nov 25, 2024
@alan-agius4
Copy link
Collaborator

Duplicate of #28948

@alan-agius4 alan-agius4 marked this as a duplicate of #28948 Nov 25, 2024
@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants