-
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 metadata manager provider APIs v2 #926
feat: add metadata manager provider APIs v2 #926
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @davidlj95 and the rest of your teammates on |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #926 +/- ##
==========================================
+ Coverage 98.11% 98.16% +0.04%
==========================================
Files 83 85 +2
Lines 372 382 +10
Branches 70 70
==========================================
+ Hits 365 375 +10
Misses 3 3
Partials 4 4 ☔ View full report in Codecov by Sentry. |
📦 Bundle size (Angular v17)Git ref:
|
📦 Bundle size (Angular v18)Git ref:
|
📦 Bundle size (Angular v16)Git ref:
|
📦 Bundle size (Angular v15)Git ref:
|
1c48014
to
e02ec1d
Compare
3b959cc
to
d27fae4
Compare
8cc3a37
to
e2de376
Compare
e2de376
to
bdf0527
Compare
🎉 This PR is included in version 1.0.0-beta.20 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* refactor: use manager provider APIs v2 for Open Graph * refactor: use manager provider APIs v2 for JSON-LD * refactor: use manager provider APIs v2 for standard * refactor: use manager provider APIs v2 for Twitter Card * fix: use with options API around * refactor: use same name global API around * refactor: use manager provider APIs v2 for example apps * perf: remove unneeded array initialization * refactor: use new module manager API scope arg around * chore: bring internal module manager APIs from #926 * refactor: rename same name global API to add prefix * chore: remove istanbul ignore now that API is used * feat: upgrade manager provider APIs v2 to public * docs: update custom metadata docs * chore: remove unneeded scenario for coverage * perf: inline function to shave bundle size * chore: update API report
Issue or need
Current APIs to help providing metadata managers are a bit convulated and not very developer friendly. Issues:
makeMetadataManagerProviderFromSetterFactory
is a quite long name 😆d
for deps,jP
for JSON Path...) do not provide a good development experience eitherprovideX
convention, which is the usual in Angular to create a providerAll of the above lead to an improvable development experience when providing a custom metadata manager:
Proposed changes
Add a new set of APIs to create metadata managers. This way old ones keep working, but a new & friendlier way is provided.
Here's how providing a custom metadata manager looks like now:
Name uses
provide
prefix. Library name is added to avoid clashes.JSON Path is moved to first argument as right now using a JSON object to specify metadata values is the most common way. The param could be made optional or pass an empty string if another way is used. Anyway, not a use case right now. This way is very clear that the metadata value will come from the
custom.title
JSON Path of the JSON object containing the metadata values.Final and greatest improvement comes with the option to specify manager options. Options can be provided using functions instead of remembering the option name in the object. For instance:
withManagerDeps
,withManagerGlobal
... Notice theNgxMeta
name has been avoided in there to avoid long names.Manager
prefix is added to avoid name clashes, discoverability & they also get nicely organized together in the API report.withOptions
is used as a small util that grabs all objects passed as arguments and joins them using the spread operator. It's named without any prefixes as this can be useful for many purposes. Not only the manager options. Avoids library name because of same reason just stated plus previous reasons in the previous case ofwithX
APIs.Internal part of new APIs was moved to #927 so that coverage doesn't go down. As given those APIs are unused here and they're untested, they're not covered by tests.
The implementation has gone through several rounds of optimizations to improve uncompressed bundle size:
withOptions
. One of those was an internal module API, which is now in feat: use metadata manager provider APIs v2 around #927.Following bundle size optimizations were thought of, but weren't performed:
string
. Avoids the utility to convert to it (plus then having to split it back). But nothing much else. Would save 10 bytes. But having first argument as a string is more developer friendly. Worth those 10 bytes.Quick reminders