feat: update o-teaser to use date-fns version 2 #1331
Merged
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.
Describe your changes
Currently o-teaser uses date-fns version 1. This functionally is fine, however v1 has bad tree shaking capabilities. This means and repository using o-teaser on the front end has a significantly larger bundle size. In next-article, date-fns is responsible for around 1/6th of the JS we ship to the browser.
By updating to version 2, this allows tree shaking and other nice things. The v1 -> v2 change was mostly around types, removing default support for strings in date-fns methods.
This change was pretty hard to test, as I couldn't see examples of testing React components in Origami. I messed around with Storybook to verify it, but if anyone is able to help me write some tests that would be fantastic!
Here's the screenshots of it working (required me to override component props in Storybook, which I didn't commit)
Issue ticket number and link
https://financialtimes.atlassian.net/browse/CPREL-852
Link to Figma designs
Checklist before requesting a review
percy
label on my PR before merging and after review.