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

docs-bug(cdk/layout): LayoutModule is not needed #24248

Open
gultyayev opened this issue Jan 21, 2022 · 8 comments
Open

docs-bug(cdk/layout): LayoutModule is not needed #24248

gultyayev opened this issue Jan 21, 2022 · 8 comments
Labels
area: cdk/layout docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@gultyayev
Copy link

Documentation Feedback

In the docs it's mentioned that we need to import LayoutModule in order to use BreakpointObserver and MediaMatcher.
In the meantime from the source code it looks like the module is not needed for any purposes.
image
image
image

Affected documentation page

https://material.angular.io/cdk/layout/api

@gultyayev gultyayev added docs This issue is related to documentation needs triage This issue needs to be triaged by the team labels Jan 21, 2022
@crisbeto
Copy link
Member

I think that this is a leftover from before providedIn: 'root' existed.

@crisbeto crisbeto added area: cdk/layout P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Jan 21, 2022
@gultyayev
Copy link
Author

Perhaps it's worth using "providedIn: LayoutModule" so the services could be included in lazy loaded modules only instead of the app module?

@crisbeto
Copy link
Member

These services were always intended to be global so that the cached state can be reused as much as possible.

@gultyayev
Copy link
Author

I get that. However if you use providedIn: Module the service isn't re-created. The instance will be shared and it won't appear in the initial bundle if was used in lazy loaded modules only

@crisbeto
Copy link
Member

The same is true for providedIn: 'root' which the services are using.

@gultyayev
Copy link
Author

Not quite. If I use it in lazy loaded module only it will increase my initial bundle size.

@crisbeto
Copy link
Member

That's not how it works though. providedIn: 'root' means that it'll be pulled in only into the bundles that use it. If it's ending up in your initial bundle, it's likely being used across multiple lazy-loaded bundles.

@gultyayev
Copy link
Author

However, webpack is capable of making a chunk shared across other lazy loaded chunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/layout docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

2 participants