-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add function-based manager providers #1004
feat: add function-based manager providers #1004
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1004 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 90 90
Lines 390 440 +50
Branches 49 49
=========================================
+ Hits 390 440 +50 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
📦 Bundle size (Angular v15)Git ref:
|
📦 Bundle size (Angular v17)Git ref:
|
📦 Bundle size (Angular v16)Git ref:
|
📦 Bundle size (Angular v18)Git ref:
|
8d79461
to
1069d4e
Compare
1069d4e
to
1c90565
Compare
ContextAt the moment of writing this, new metadata provider functions have been added and used around. Deprecating Bundle size weird changesSomething interesting happens regarding bundle size! For Angular v17 and v18, a bundle size increase happens as predicted in #960:
However, for Angular v15 and v16 (using Webpack instead of ESBuild), bundle size is reduced!! 🤔
What is happening in there? When making the predictions, comparisons were done with Angular v18. Assumed something similar would happen for older versions. But turns out it doesn't! Guess everyday you learn something new. In Angular v18, observed that due to the arrow functions introduced, some extra bytes are added to the bundle: var qK=vn() // before
var qK=()=>vn() // after Hence the increase in size due to adding But in Angular v15/16 seems that something else happens! After investigating a bit by comparing formatted versions of bundles before and after the change, seems the reason is some kind of optimization. Instead of first declaring the provider and then using it, the provider is inlined where used. Hence no need to declare something to later use it. That would explain the reduction in bundle size. Btw, these bundle size snapshots above will be useful to compare bundle size changes before and after introducing back deprecated, but pure |
1c90565
to
ac10dd7
Compare
ac10dd7
to
67eb5e5
Compare
Also: - Move types to the `types` directory - Rename provider to make it a bit more specific
67eb5e5
to
7dd298b
Compare
After adding back However, for Angular v17/18 it went from 162 extra bytes to 242 extra bytes. Hmmm. Taking a look to see if those |
Seems that it's mainly because
Let's analyze the Open Graph module. There are 11 metadata providers in Open Graph. So 88 bytes for that reason. However seems first provider of each kind (basic / optional and profile) is actually added in same Then, adding up the extra As expected, old |
Issue or need
Fixes #960
Proposed changes
Add tree shakeable providers by making them functions instead of
const
s. This way the code they can be tree shaken if unused.JSON_LD_METADATA_PROVIDER
. Which has been removed as it's essentially the same asprovideNgxMetaJsonLd
Removes non tree-shakeableMarksconst
providersconst
providers as deprecated and pure. Pure so they can bee tree-shaken if unused. Deprecated to favour new functions instead.Add schematics to migrate automatically from old to new ones in #1005
Other changes:
ReturnMoved to refactor: return genericProvider
instead ofFactoryProvider
. No need to reveal implementation detail of which kind of provider is returnedProvider
type for providers #1045 to reduce diffReturn. Moved to refactor: return genericProvider
instead ofProvider[]
Provider
type for providers #1045 to reduce diffJSON_LD_METADATA_PROVIDER
toprovideJsonLdInHead
(instead ofprovideJsonLd
, to differentiate a bit)Quick reminders