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

Typescript migration #6307

Merged
merged 17 commits into from
May 19, 2022
Merged

Typescript migration #6307

merged 17 commits into from
May 19, 2022

Conversation

pettinarip
Copy link
Member

@pettinarip pettinarip commented May 12, 2022

First iteration on TS migration (#6392).

Description

Core files has been migrated.

Some extra things:

  • Package scripts were refactored a bit. The prebuild script processes has been moved into onPreBootstrap hook in gatsby-node.
  • Migrated data/translations.json into utils/languages.ts.
  • Removed unused LegacyPageHome.js page.
  • Decoupled a but the logic that lives inside the translations.ts file. I moved them into the languages.ts.

More reference: https://www.gatsbyjs.com/docs/how-to/custom-configuration/typescript/#migrating-to-typescript

TODO

  • migrate and see how to test the docsearchConfigScript.js file
  • fix GC build issue

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies review needed 👀 tooling 🔧 Changes related to tooling of the project labels May 12, 2022
@gatsby-cloud
Copy link

gatsby-cloud bot commented May 12, 2022

Gatsby Cloud Build Report

ethereum-org-website-dev

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 24m

Performance

Lighthouse report

Metric Score
Performance 🔶 24
Accessibility 💚 100
Best Practices 💚 100
SEO 💚 92

🔗 View full report

@github-actions github-actions bot added the translation 🌍 This is related to our Translation Program label May 12, 2022
@pettinarip pettinarip removed content 🖋️ This involves copy additions or edits translation 🌍 This is related to our Translation Program labels May 12, 2022
@github-actions github-actions bot added content 🖋️ This involves copy additions or edits translation 🌍 This is related to our Translation Program labels May 12, 2022
@pettinarip pettinarip marked this pull request as draft May 13, 2022 14:10
@pettinarip pettinarip marked this pull request as ready for review May 13, 2022 21:10
Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome ❤️
Site is building properly locally, and not getting any issues with any pages breaking...

...Dare I say we're on the verge of Deploy v4.0.0??

Copy link
Member

@nhsz nhsz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, great job! 🎉 Just left a couple of suggestions

"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["./src"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add the "exclude": ["node_modules"] prop here for faster compilation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 I wonder what you lose from doing that. Do you know if that is not equivalent of doing "skipLibCheck": true (which we are already doing). https://www.typescriptlang.org/tsconfig#skipLibCheck

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it has the same effect

types.ts Outdated
@@ -0,0 +1,21 @@
import { Lang } from "./src/utils/languages"
import { IMessages } from "./src/utils/flattenMessages"
Copy link
Member

@nhsz nhsz May 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can move the IMessages interface (and other defined interfaces) to an interfaces.ts file, like we do with types.ts. I'd also suggest to remove the I from the interface name (and use just Messages), to standardize the naming

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will standardize these names without the I but not sure about putting them into a single file.

Let me know what do you think about the following. Maybe we can have:

  • interfaces.ts file -> for global or cross-app interfaces
  • each [module].ts -> interfaces related to that module

Basically to avoid having a huge interfaces.ts file and to quickly find the interfaces related to the code.

I guess this is more the convention we want to follow as a team.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pettinarip agree with that convention

@samajammin
Copy link
Member

One small thought (that isn't a blocker on this PR): should /utils/translations.ts & /utils/languages.ts be separate files? Or should we just merge them?

@samajammin
Copy link
Member

One note, we'll have to account for at least one recent PR: #6366

@@ -0,0 +1,27 @@
import fs from "fs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Organization nitpick question - do getMessages & flattenMessages both need their own files? They both have to do with i18n support (specifically the gatsby-plugin-intl plugin).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. I tried to avoid doing a lot of refactors just to keep this PR as much as scoped as possible but your suggestion makes total sense.

I will take note of this and implement that in the next PR 👍🏼

This comment was marked as spam.

@@ -1,4 +1,4 @@
import { mergeObjects } from "../merge-translations"
import mergeObjects from "../../utils/mergeObjects"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we'll eventually want to migrate these test files as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm ok if it's not this PR).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! will migrate them in next PRs 💪🏼

@nloureiro
Copy link
Contributor

I pulled the PR, and local got this error; not sure if it's something on my end, but I got this.
Screen Shot 2022-05-18 05 35 22 PM

@corwintines
Copy link
Member

I pulled the PR, and local got this error; not sure if it's something on my end, but I got this. Screen Shot 2022-05-18 05 35 22 PM

This has to do with the hot reload module. Usually a refresh fixes this. Happens sometimes when changing code and the cache coming out of sync I believe.

Copy link
Member

@corwintines corwintines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @pettinarip! I would have approved, but there's a conflict. Let me know if you need a hand!

@pettinarip
Copy link
Member Author

One small thought (that isn't a blocker on this PR): should /utils/translations.ts & /utils/languages.ts be separate files? Or should we just merge them?

I separated them on purpose because:

  • translations.ts depends on the existence of src/intl/en.json. The latter is generated on build time by mergeTranslations that is called by gatsby-node, which needs some functions from languages.ts. If we merge them, we will have a conflict.
  • and for organization matters, to have smaller files with related things.

One note, we'll have to account for at least one recent PR: #6366
Thanks, yes, I'll resolve the conflicts soon and include that PR content.

@pettinarip
Copy link
Member Author

Nice @pettinarip! I would have approved, but there's a conflict. Let me know if you need a hand!

Thanks for the review @corwintines! Yes, tomorrow I'll resolve the conflicts and merge it.

Copy link
Member

@samajammin samajammin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some comments but no blockers in my opinion. Great work!

Only (minor) concern I have is that while yarn start works fine, netlify dev no longer works on my local env:
https://discord.com/channels/714888181740339261/974453286134485072/976522784891084870

But seems like that is just an issue for me? e.g. @wackerow said everything works fine for him.

@pettinarip pettinarip merged commit ea6d453 into dev May 19, 2022
@pettinarip pettinarip deleted the ts branch May 19, 2022 18:35
@DaveyD233

This comment was marked as spam.

@pettinarip pettinarip mentioned this pull request May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project translation 🌍 This is related to our Translation Program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants