-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Deprecate withServerTransition
call and generate static APP_ID
#49422
Conversation
bf94712
to
30edba2
Compare
Nit: You could add an entry to the depreciation guide. |
187ca88
to
8a6c8fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍
* | ||
* @publicApi | ||
*/ | ||
export const APP_ID = new InjectionToken<string>('AppId', { | ||
providedIn: 'root', | ||
factory: _appIdRandomProviderFactory, | ||
factory: () => 'ng', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can extract this value to a separate const to make it more self-documenting:
factory: () => 'ng', | |
factory: () => DEFAULT_APP_ID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just static, can we use a value provider? useValue: DEFAULT_APP_ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, the default value, will be set in a totally different package since an InjectorToken doesn’t allow useValue
.
Ex:
{provide: INJECTOR_SCOPE, useValue: 'root'}, |
@@ -49,12 +49,6 @@ function _render<T>( | |||
bootstrapPromise: Promise<NgModuleRef<T>|ApplicationRef>): Promise<string> { | |||
return bootstrapPromise.then((moduleOrApplicationRef) => { | |||
const environmentInjector = moduleOrApplicationRef.injector; | |||
const transitionId = environmentInjector.get(APP_ID, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also remove this call (in the same file)?
angular/packages/platform-server/src/utils.ts
Line 242 in ed110a0
importProvidersFrom(BrowserModule.withServerTransition({appId})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not remove this one as this overload of renderApplication
will be deleted in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed-for: public-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the second commit (refactor(core): generate a static application ID.) a breaking change for when there are multiple applications (however rare that would be)
I’ll add a breaking change message. |
This commit deprecated ` BrowserModule.withServerTransition` instead `APP_ID` should be used instead to configure the app id. DEPRECATED: `BrowserModule.withServerTransition` has been deprecated. `APP_ID` should be used instead to set the application ID. NB: Unless, you render multiple Angular applications on the same page, setting an application ID is not necessary. Before: ```ts imports: [ BrowserModule.withServerTransition({ appId: 'serverApp' }), ... ] ``` After: ```ts imports: [ BrowserModule, { provide: APP_ID, useValue: 'serverApp' }, ... ], ```
Prior to this change, a random application ID was generated each time which forced users using server rendering to provide an application ID themselves. This was needed to handle rare cases when multiple Angular applications are rendered on the same page. With this change the application ID is no longer generated randomly and instead it is hard coded. BREAKING CHANGE: The `APP_ID` token value is no longer randomly generated. If you are bootstrapping multiple application on the same page you will need to set to provide the `APP_ID` yourself. ```ts bootstrapApplication(ComponentA, { providers: [ { provide: APP_ID, useValue: 'app-a' }, // ... other providers ... ] }); ```
This commit removes the usages of `withServerTransition` form tests.
df29310
to
915ab07
Compare
@atscott, PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
This PR was merged into the repository by commit cf98777. |
Prior to this change, a random application ID was generated each time which forced users using server rendering to provide an application ID themselves. This was needed to handle rare cases when multiple Angular applications are rendered on the same page. With this change the application ID is no longer generated randomly and instead it is hard coded. BREAKING CHANGE: The `APP_ID` token value is no longer randomly generated. If you are bootstrapping multiple application on the same page you will need to set to provide the `APP_ID` yourself. ```ts bootstrapApplication(ComponentA, { providers: [ { provide: APP_ID, useValue: 'app-a' }, // ... other providers ... ] }); ``` PR Close #49422
This commit removes the usages of `withServerTransition` form tests. PR Close #49422
…rverTransition` This commit removes generation of `.withServerTransition` in the universal schematic as is deprecated. DEPRECATED: the `app-id` option in the app-shell and universal schematics has been deprecated without replacement. See: angular/angular#49422 for more information about the rational of this change.
…rverTransition` This commit removes generation of `.withServerTransition` in the universal schematic as is deprecated. DEPRECATED: the `app-id` option in the app-shell and universal schematics has been deprecated without replacement. See: angular/angular#49422 for more information about the rational of this change.
…rverTransition` This commit removes generation of `.withServerTransition` in the universal schematic as is deprecated. DEPRECATED: the `app-id` option in the app-shell and universal schematics has been deprecated without replacement. See: angular/angular#49422 for more information about the rational of this change.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
feat(platform-browser): deprecate
withServerTransition
callThis commit deprecated
BrowserModule.withServerTransition
insteadAPP_ID
should be used instead to configure the app id.DEPRECATED:
BrowserModule.withServerTransition
has been deprecated.APP_ID
should be used instead to set the application ID.NB: Unless, you render multiple Angular applications on the same page, setting an application ID is not necessary.
Before:
After:
refactor(core): generate a static application ID.
Prior to this change, a random application ID was generated each time which forced users using server rendering to provide an application ID themselves. This was needed to handle rare cases when multiple Angular applications are rendered on the same page.
With this change the application ID is no longer generated randomly and instead it is hard coded.
BREAKING CHANGE:
The
APP_ID
token value is no longer randomly generated. If you are bootstrapping multiple application on the same page you will need to set to provide theAPP_ID
yourself.