-
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
TEST - feat(platform-server): expose method for shimming global env #40544
Conversation
You can preview 468cefa at https://pr40544-468cefa.ngbuilds.io/. |
468cefa
to
14b9807
Compare
You can preview 14b9807 at https://pr40544-14b9807.ngbuilds.io/. |
14b9807
to
f27da00
Compare
You can preview f27da00 at https://pr40544-f27da00.ngbuilds.io/. |
The `platform-server` package currently depends on the [domino][1] package. This commit adds `domino` to the list of dependencies for the `platform-server` `ng_module` target. [1]: https://www.npmjs.com/package/domino
This commit adds an integration test that uses `@angular/elements` with `@angular/platform-server` in order to highlight a current incompatibility. The issue witll be fixed in a subsequent commit.
3fec49d
to
27cddb5
Compare
You can preview 27cddb5 at https://pr40544-27cddb5.ngbuilds.io/. |
`@angular/platform-server` provides the foundation for rendering an Angular app on the server. In order to achieve that, it uses a server-side DOM implementation (currently [domino][1]). For rendering on the server to work as closely as possible to running the app on the browser, we need to make DOM globals (such as `Element`, `HTMLElement`, etc.), which are normally provided by the browser, available as globals on the server as well. Currently, `@angular/platform-server` achieves this by extending the `global` object with the DOM implementation provided by `domino`. This assignment happens in the [setDomTypes()][2] function, which is [called in a `PLATFORM_INITIALIZER`][3]. While this works in most cases, there are some scenarios where the DOM globals are needed sooner (i.e. before initializing the platform). See, for example, angular#24551 and angular#39950 for more details on such issues. This commit provides a way to solve this problem by exposing an side-effect-ful entry-point (`@angular/platform-server/shims`), that shims the `global` object with DOM globals. People will be able to import this entry-point in their server-rendered apps before bootstrapping the app (for example, in their `main.server.ts` file). (See also [angular#39950 (comment)][4].) In a future update, the [`universal` schematics][5] will include such an import by default in newly generated projects. [1]: https://www.npmjs.com/package/domino [2]: https://github.com/angular/angular/blob/0fc8466f1be392917e0c/packages/platform-server/src/domino_adapter.ts#L17-L21 [3]: https://github.com/angular/angular/blob/0fc8466f1be392917e0c/packages/platform-server/src/server.ts#L33 [4]: angular#39950 (comment) [5]: https://github.com/angular/angular-cli/blob/cc51432661eb4ab4b6a3/packages/schematics/angular/universal
27cddb5
to
a9d33e8
Compare
Superceded by #40559. |
You can preview a9d33e8 at https://pr40544-a9d33e8.ngbuilds.io/. |
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. |
WIP