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

feat: update o-teaser to use date-fns version 2 #1331

Merged
merged 2 commits into from
Nov 9, 2023

Conversation

benwallman
Copy link
Contributor

@benwallman benwallman commented Nov 1, 2023

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)

The royal wedding The royal wedding

Issue ticket number and link

https://financialtimes.atlassian.net/browse/CPREL-852

Link to Figma designs

Checklist before requesting a review

  • I have applied percy label on my PR before merging and after review.
  • If it is a new feature, I have added thorough tests.
  • I have updated relevant docs.

@benwallman benwallman requested a review from a team as a code owner November 1, 2023 15:26
@benwallman benwallman added the percy This will tell the percy github action to run label Nov 2, 2023
@akomiqaia
Copy link
Contributor

Hi @benwallman. Sorry for the delayed reply. Thank you for your PR everything looks good to me and we are happy to merge this PR but there are some important things to mention. These TSX templates are not in use and your changes might not have an effect. What you might be looking for is x-teaser. x-teaser is a customer products wrapper on o-teaser but does not use TSX templates.

@benwallman
Copy link
Contributor Author

Thanks @akomiqaia !

My path of fixing this had led me to this being the root module, then x-dash, then cp-content-pipeline and finally next-article!

Will still like this merged, to stop future date-fns v1 usage, but this makes it one step easier thank you :)

@benwallman
Copy link
Contributor Author

benwallman commented Nov 6, 2023

Actually @akomiqaia I've double checked my working and I'm a bit confused!

image

https://www.npmjs.com/package/@financial-times/cp-content-pipeline-ui

https://github.com/Financial-Times/next-article/blob/main/package.json#L86

To me it looks like it's being used, can you clarify?

@akomiqaia
Copy link
Contributor

hi @benwallman. Origami is used to create components using only JS and SCSS. Last year we started writing TSX templates to make life easier for TSX users. o-teaser was one of the components that got a new TSX template but it was hard to implement this in x-teaser and o-teaser TSX templates were never used. I think what is happening here is that o-teaser is used to get styles working but then actual Teaser markup is brought in from x-dash.

@benwallman
Copy link
Contributor Author

Thanks @akomiqaia makes sense to me!

Would be good to get the merged in if possible, primarily to stop the legacy-peer-deps warning and faster build tiimes!

@notlee notlee merged commit c53316b into main Nov 9, 2023
11 of 12 checks passed
@notlee notlee deleted the o-teaser-update-date-fns-v2 branch November 9, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
percy This will tell the percy github action to run
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants