You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 48fc292
Browse filesBrowse the repository at this point in the historyBrowse files
As in the pull request after its review, `format` is a separate object
in the `oneOf` of the prerender option, so it cannot be combined with
routesFile and discoverRoutes, which only apply without outputMode.
`format` is required in that object, so `"prerender": {}` keeps
matching the object of @angular/build only. Schema defaults no longer
add `format` to that object, so with outputMode the builder warns for
every prerender value other than an object with `format`. A schema
test covers both objects.
BREAKING CHANGE: `prerender.format` cannot be combined with
`routesFile` or `discoverRoutes`. `ng add` stops if the prerender
option contains them.
`application/schema.json` is generated: the schema of `@angular/build:application` from the installed version plus `format` in the `prerender`object. Regenerate it after updating `@angular/build` and commit the result. `npm test` fails if it is out of sync.
29
+
`application/schema.json` is generated: the schema of `@angular/build:application` from the installed version plus a separate object with `format` in the `oneOf` of `prerender`, as in the pull request, so `format` cannot be combined with `routesFile` and `discoverRoutes`. `format` is required in that object, so `{}` keeps matching the object of `@angular/build` only. Regenerate it after updating `@angular/build` and commit the result. `npm test` fails if it is out of sync.
30
30
31
31
### Test
32
32
```bash
@@ -77,14 +77,14 @@ The option must never make a build fail. Whenever the "file" format does not app
77
77
## Architecture
78
78
79
79
1.**Builder** (`src/application/`):
80
-
-`builder.ts` - Angular builder entry point, called by `ng build`. Takes `format` out of the `prerender` option (`toApplicationOptions()`) and delegates to `buildApplication`. With `outputMode`, `@angular/build` ignores `prerender`, so the builder drops it there and applies only `format`. If one of the other `prerender` settings has no effect, the builder warns with the rule and the message of the pull request. Whenever the "file" format does not apply (a server is produced, the internals of `@angular/build` differ, nothing went through the wrapper), it logs a warning and the build behaves like `@angular/build:application`.
80
+
-`builder.ts` - Angular builder entry point, called by `ng build`. Takes `format` out of the `prerender` option (`toApplicationOptions()`) and delegates to `buildApplication`. With `outputMode`, `@angular/build` ignores `prerender`, so the builder drops it there and applies only `format`. If `prerender` is set to anything other than an object with `format`, the builder warns with the rule and the message of the pull request. Whenever the "file" format does not apply (a server is produced, the internals of `@angular/build` differ, nothing went through the wrapper), it logs a warning and the build behaves like `@angular/build:application`.
81
81
-`ships-server.ts` - The rule for "this build ships an SSR server", shared by builder and `ng add`.
82
82
-`file-format.ts` - Wraps the internal `prerenderPages()` of `@angular/build`. `execute-post-bundle.js` reads it from the module's exports object at call time, so replacing the export takes effect for regular and localized builds.
- Swaps the build target's builder and sets `prerender.format: "file"`, keeping other`prerender`settings
87
+
- Swaps the build target's builder and sets `"prerender": { "format": "file" }`; stops if`prerender`contains `routesFile` or `discoverRoutes`, which cannot be combined with `format`
88
88
- Warns if the build target or one of its configurations produces an SSR server
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ ng build
64
64
65
65
`ng add @angular-schule/prerender-format` installs the package, changes the builder of your build target in `angular.json` and sets `prerender.format`.
66
66
`"format": "file"` only applies to static builds. If the build target (or one of its configurations) produces an SSR server, `ng add` still sets it up and shows a warning.
67
+
If `prerender` contains `routesFile` or `discoverRoutes`, `ng add` stops, as they cannot be combined with `format`.
67
68
68
69
```json
69
70
"build": {
@@ -97,7 +98,8 @@ The name and the values follow Astro's [`build.format`](#other-frameworks).
97
98
Parent and child routes live side by side: `blog.html` next to the folder `blog/`.
98
99
The start page of each locale (for example with base href `/en/`) stays `index.html`.
99
100
100
-
`prerender.format` is also considered with `"outputMode": "static"`, where Angular ignores the other `prerender` settings.
101
+
`prerender.format` cannot be combined with `routesFile` and `discoverRoutes`, which only apply to builds without `"outputMode"`.
102
+
With `"outputMode": "static"`, Angular ignores every other value of `prerender`, and `prerender.format` is considered.
101
103
102
104
## 🔭 Other frameworks <aname="other-frameworks"></a>
Copy file name to clipboardExpand all lines: src/application/schema.json
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -620,18 +620,26 @@
620
620
"type": "boolean",
621
621
"description": "Whether the builder should process the Angular Router configuration to find all unparameterized routes and prerender them.",
622
622
"default": true
623
-
},
623
+
}
624
+
},
625
+
"additionalProperties": false
626
+
},
627
+
{
628
+
"type": "object",
629
+
"properties": {
624
630
"format": {
625
631
"type": "string",
626
632
"description": "Defines the file layout of prerendered pages. 'directory': '/foo' is written to 'foo/index.html'. 'file': '/foo' is written to 'foo.html', which some hosting services serve for '/foo' without a redirect to '/foo/'. The root route of the application and of each locale is always written to 'index.html'. Only considered when the build does not produce a server.",
0 commit comments