-
Notifications
You must be signed in to change notification settings - Fork 20
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: v2.0.0 #46
Merged
Merged
feat: v2.0.0 #46
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: lihbr <lihbr@users.noreply.github.com> Co-authored-by: Angelo Ashmore <angeloashmore@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a rewrite of
@prismicio/richtext
with a focus on minimizing the bundle size and improving performance.It is written in TypeScript with a public TypeScript interface in mind. It integrates with
@prismicio/types
to ensure other libraries and user code will interface properly.Performance improvements
Benchmark results (compared to v1)
asTree
: ~75x fasterasText
: ~2.5x fasterserialize
: ~40x fasterBundle size reduction (compared to v1)
~64% smaller minified + gzipped
New APIs
The following new APIs are exposed:
wrapMapSerializer
This function allows a user to create a serializer using a map. This is a simpler interface than the existing function-based serializer and can cover most use cases.
An example HTML serializer could look like the following:
composeSerializers
This function combines two or more serializers into one serializer evaluated in the provided order. If a serializer returns a nullish value, the next serializer in line will be used until a value is found. At least one serializer must return a serialized value.
It looks like this:
Where
serializer1
,serializer2
, andserializer3
are function serializers.