Skip to content

Commit 17abe6d

Browse files
alan-agius4AndrewKushnir
authored andcommitted
refactor(platform-server): remove deprecated renderModuleFactory (#49247)
The deprecated `renderModuleFactory` has been removed as it is no longer necessary with Ivy. BREAKING CHANGE: `renderModuleFactory` has been removed. Use `renderModule` instead. PR Close #49247
1 parent 4e9531f commit 17abe6d

File tree

7 files changed

+12
-63
lines changed

7 files changed

+12
-63
lines changed

aio/content/guide/deprecations.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ v15 - v18
7979
| `@angular/core` | [Factory-based signature of `ApplicationRef.bootstrap`](#core) | v13 | v15 |
8080
| `@angular/core` | [`PlatformRef.bootstrapModuleFactory`](#core) | v13 | v15 |
8181
| `@angular/core` | [Factory-based signature of `ViewContainerRef.createComponent`](api/core/ViewContainerRef#createComponent) | v13 | v15 |
82-
| `@angular/platform-server` | [`renderModuleFactory`](#platform-server) | v13 | v15 |
8382
| `@angular/upgrade` | [Factory-based signature of `downgradeModule`](#upgrade-static) | v13 | v15 |
8483
| template syntax | [`bind-`, `on-`, `bindon-`, and `ref-`](#bind-syntax) | v13 | v15 |
8584

@@ -228,7 +227,6 @@ In the [API reference section](api) of this site, deprecated APIs are indicated
228227

229228
| API | Replacement | Deprecation announced | Details |
230229
|:--- |:--- |:--- |:--- |
231-
| [`renderModuleFactory`](api/platform-server/renderModuleFactory) | [`renderModule`](api/platform-server/renderModule) | v13 | This symbol is no longer necessary. See [JIT API changes due to ViewEngine deprecation](#jit-api-changes) for additional context. |
232230
| [`ServerTransferStateModule`](api/platform-server/ServerTransferStateModule) | No replacement needed. | v14.1 | The `TransferState` class is available for injection without importing additional modules during server side rendering, when `ServerModule` is imported or `renderApplication` function is used for bootstrap. |
233231

234232
<a id="forms"></a>
@@ -383,7 +381,7 @@ The injector no longer requires the Reflect polyfill, reducing application size
383381
### Router class and InjectionToken guards and resolvers
384382

385383
Class and injection token guards and resolvers are deprecated. Instead, `Route`
386-
objects should use functional-style guards and resolvers. Class-based guards can
384+
objects should use functional-style guards and resolvers. Class-based guards can
387385
be converted to functions by instead using `inject` to get dependencies.
388386

389387
For testing a function `canActivate` guard, using `TestBed` and `TestBed.runInInjectionContext` is recommended.
@@ -408,8 +406,8 @@ const route = {
408406
This deprecation only affects the support for class and
409407
`InjectionToken` guards at the `Route` definition. `Injectable` classes
410408
and `InjectionToken` providers are _not_ deprecated in the general
411-
sense. That said, the interfaces like `CanActivate`,
412-
`CanDeactivate`, etc. will be deleted in a future release of Angular. Simply removing the
409+
sense. That said, the interfaces like `CanActivate`,
410+
`CanDeactivate`, etc. will be deleted in a future release of Angular. Simply removing the
413411
`implements CanActivate` from the injectable class and updating the route definition
414412
to be a function like `canActivate: [() => inject(MyGuard).canActivate()]` is sufficient
415413
to get rid of the deprecation warning.

aio/content/guide/universal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ It accepts an object with the following properties:
228228

229229
| Properties | Details |
230230
|:--- |:--- |
231-
| `bootstrap` | The root `NgModule` or `NgModule` factory to use for bootstrapping the application when rendering on the server. For the example application, it is `AppServerModule`. It's the bridge between the Universal server-side renderer and the Angular application. |
231+
| `bootstrap` | The root `NgModule` to use for bootstrapping the application when rendering on the server. For the example application, it is `AppServerModule`. It's the bridge between the Universal server-side renderer and the Angular application. |
232232
| `extraProviders` | This property is optional and lets you specify dependency providers that apply only when rendering the application on the server. Do this when your application needs information that can only be determined by the currently running server instance. |
233233

234234
The `ngExpressEngine()` function returns a `Promise` callback that resolves to the rendered page.
@@ -313,7 +313,7 @@ You don't need to do anything to make relative URLs work on the server.
313313

314314
If, for some reason, you are not using an `@nguniversal/*-engine` package, you might need to handle it yourself.
315315

316-
The recommended solution is to pass the full request URL to the `options` argument of [renderModule()](api/platform-server/renderModule) or [renderModuleFactory()](api/platform-server/renderModuleFactory) \(depending on what you use to render `AppServerModule` on the server\).
316+
The recommended solution is to pass the full request URL to the `options` argument of [renderModule()](api/platform-server/renderModule).
317317
This option is the least intrusive as it does not require any changes to the application.
318318
Here, "request URL" refers to the URL of the request as a response to which the application is being rendered on the server.
319319
For example, if the client requested `https://my-server.com/dashboard` and you are rendering the application on the server to respond to that request, `options.url` should be set to `https://my-server.com/dashboard`.

goldens/public-api/platform-server/index.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as i1 from '@angular/common/http';
1010
import * as i2 from '@angular/platform-browser/animations';
1111
import * as i3 from '@angular/platform-browser';
1212
import { InjectionToken } from '@angular/core';
13-
import { NgModuleFactory } from '@angular/core';
1413
import { PlatformRef } from '@angular/core';
1514
import { Provider } from '@angular/core';
1615
import { StaticProvider } from '@angular/core';
@@ -64,13 +63,6 @@ export function renderModule<T>(moduleType: Type<T>, options: {
6463
extraProviders?: StaticProvider[];
6564
}): Promise<string>;
6665

67-
// @public @deprecated
68-
export function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
69-
document?: string;
70-
url?: string;
71-
extraProviders?: StaticProvider[];
72-
}): Promise<string>;
73-
7466
// @public
7567
export class ServerModule {
7668
// (undocumented)

packages/platform-server/src/platform-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export {PlatformState} from './platform_state';
1010
export {platformDynamicServer, platformServer, ServerModule} from './server';
1111
export {BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformConfig} from './tokens';
1212
export {ServerTransferStateModule} from './transfer_state';
13-
export {renderApplication, renderModule, renderModuleFactory} from './utils';
13+
export {renderApplication, renderModule} from './utils';
1414

1515
export * from './private_export';
1616
export {VERSION} from './version';

packages/platform-server/src/tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface PlatformConfig {
5050
export const INITIAL_CONFIG = new InjectionToken<PlatformConfig>('Server.INITIAL_CONFIG');
5151

5252
/**
53-
* A function that will be executed when calling `renderApplication`, `renderModuleFactory` or
53+
* A function that will be executed when calling `renderApplication` or
5454
* `renderModule` just before current platform state is rendered to string.
5555
*
5656
* @publicApi

packages/platform-server/src/utils.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ApplicationRef, EnvironmentProviders, importProvidersFrom, InjectionToken, NgModuleFactory, NgModuleRef, PlatformRef, Provider, Renderer2, StaticProvider, Type, ɵinternalCreateApplication as internalCreateApplication, ɵisPromise} from '@angular/core';
9+
import {ApplicationRef, EnvironmentProviders, importProvidersFrom, InjectionToken, NgModuleRef, PlatformRef, Provider, Renderer2, StaticProvider, Type, ɵinternalCreateApplication as internalCreateApplication, ɵisPromise} from '@angular/core';
1010
import {BrowserModule, ɵTRANSITION_ID} from '@angular/platform-browser';
1111
import {first} from 'rxjs/operators';
1212

1313
import {PlatformState} from './platform_state';
14-
import {platformDynamicServer, platformServer, ServerModule} from './server';
14+
import {platformDynamicServer, ServerModule} from './server';
1515
import {BEFORE_APP_SERIALIZED, INITIAL_CONFIG} from './tokens';
16-
import {TRANSFER_STATE_SERIALIZATION_PROVIDERS} from './transfer_state';
1716

1817
interface PlatformOptions {
1918
document?: string|Document;
@@ -202,31 +201,3 @@ export function renderApplication<T>(rootComponent: Type<T>, options: {
202201
];
203202
return _render(platform, internalCreateApplication({rootComponent, appProviders}));
204203
}
205-
206-
/**
207-
* Bootstraps an application using provided {@link NgModuleFactory} and serializes the page content
208-
* to string.
209-
*
210-
* @param moduleFactory An instance of the {@link NgModuleFactory} that should be used for
211-
* bootstrap.
212-
* @param options Additional configuration for the render operation:
213-
* - `document` - the document of the page to render, either as an HTML string or
214-
* as a reference to the `document` instance.
215-
* - `url` - the URL for the current render request.
216-
* - `extraProviders` - set of platform level providers for the current render request.
217-
*
218-
* @publicApi
219-
*
220-
* @deprecated
221-
* This symbol is no longer necessary as of Angular v13.
222-
* Use {@link renderModule} API instead.
223-
*/
224-
export function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
225-
document?: string,
226-
url?: string,
227-
extraProviders?: StaticProvider[],
228-
}): Promise<string> {
229-
const {document, url, extraProviders: platformProviders} = options;
230-
const platform = _getPlatform(platformServer, {document, url, platformProviders});
231-
return _render(platform, platform.bootstrapModuleFactory(moduleFactory));
232-
}

packages/platform-server/test/integration_spec.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {animate, AnimationBuilder, state, style, transition, trigger} from '@ang
1010
import {DOCUMENT, isPlatformServer, PlatformLocation, ɵgetDOM as getDOM} from '@angular/common';
1111
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
1212
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
13-
import {ApplicationRef, CompilerFactory, Component, destroyPlatform, getPlatform, HostListener, Inject, inject as coreInject, Injectable, Input, NgModule, NgZone, PLATFORM_ID, PlatformRef, ViewEncapsulation} from '@angular/core';
14-
import {inject, TestBed, waitForAsync} from '@angular/core/testing';
13+
import {ApplicationRef, Component, destroyPlatform, getPlatform, HostListener, Inject, inject as coreInject, Injectable, Input, NgModule, NgZone, PLATFORM_ID, ViewEncapsulation} from '@angular/core';
14+
import {TestBed, waitForAsync} from '@angular/core/testing';
1515
import {BrowserModule, makeStateKey, Title, TransferState} from '@angular/platform-browser';
16-
import {BEFORE_APP_SERIALIZED, INITIAL_CONFIG, platformDynamicServer, PlatformState, renderModule, renderModuleFactory, ServerModule} from '@angular/platform-server';
16+
import {BEFORE_APP_SERIALIZED, INITIAL_CONFIG, platformDynamicServer, PlatformState, renderModule, ServerModule} from '@angular/platform-server';
1717
import {Observable} from 'rxjs';
1818
import {first} from 'rxjs/operators';
1919

@@ -702,18 +702,6 @@ describe('platform-server integration', () => {
702702
});
703703
}));
704704

705-
it('using renderModuleFactory should work',
706-
waitForAsync(inject([PlatformRef], (defaultPlatform: PlatformRef) => {
707-
const compilerFactory: CompilerFactory =
708-
defaultPlatform.injector.get(CompilerFactory, null)!;
709-
const moduleFactory =
710-
compilerFactory.createCompiler().compileModuleSync(AsyncServerModule);
711-
renderModuleFactory(moduleFactory, {document: doc}).then(output => {
712-
expect(output).toBe(expectedOutput);
713-
called = true;
714-
});
715-
})));
716-
717705
// Run the set of tests with regular and standalone components.
718706
[true, false].forEach((isStandalone: boolean) => {
719707
it(`using ${isStandalone ? 'renderApplication' : 'renderModule'} should work`,

0 commit comments

Comments
 (0)