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

Update/react imports #670

Merged
merged 10 commits into from Jan 26, 2021
Merged

Conversation

nicholasio
Copy link
Collaborator

@nicholasio nicholasio commented Jan 20, 2021

What:

Updates React imports as per the new JSX transform (React 17). #668 .

Why:

React does not need to be in scope anymore with React 17 and the new JSX transform.
How:

npx react-codemod update-react-imports and selecting the Typescript option. ESLint errors were ignored. Also had to update the babel config for jest for the unit tests to pass.

Tasks:

  • Code
  • Unit tests
  • End to end tests
  • Update starter themes
  • Update other packages
  • Add a changeset (with link to its Feature Discussion if it exists)

Unrelated Tasks

  • TSDocs
  • TypeScript
  • TypeScript tests
  • Update community discussions
  • Open an issue for this feature in the docs repo

Additional Comments

In some places we have imports like this:

import { MouseEvent, useEffect, useRef, useCallback } from "react";
import * as React from "react";

This is basically because in some places we are using React.FC instead of importing FC directly. I noticed we're not very consistent on how we import TypeScript types, it seems like the React codemod prefers React.FC as it didn't update them and instead converted the react imports to the new recommended version import * as React from 'react'

@changeset-bot
Copy link

changeset-bot bot commented Jan 20, 2021

🦋 Changeset detected

Latest commit: bcb5c04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@frontity/analytics Minor
@frontity/components Minor
@frontity/comscore-analytics Minor
@frontity/connect Minor
@frontity/core Minor
frontity Minor
@frontity/google-ad-manager Minor
@frontity/google-analytics Minor
@frontity/google-tag-manager-analytics Minor
@frontity/head-tags Minor
@frontity/hooks Minor
@frontity/html2react Minor
@frontity/mars-theme Minor
@frontity/smart-adserver Minor
@frontity/twentytwenty-theme Minor
@frontity/types Minor
@frontity/yoast Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Jan 20, 2021

Codecov Report

Merging #670 (bcb5c04) into dev (0d67328) will increase coverage by 0.01%.
The diff coverage is 81.82%.

Impacted Files Coverage Δ
packages/components/iframe.tsx 100.00% <ø> (ø)
packages/components/image.tsx 100.00% <ø> (ø)
packages/components/script.tsx 0.00% <0.00%> (ø)
packages/core/src/app/index.tsx 0.00% <ø> (ø)
packages/core/src/client/index.tsx 0.00% <ø> (ø)
packages/core/src/server/index.tsx 0.00% <ø> (ø)
packages/frontity/src/utils/slot-and-fill/slot.tsx 100.00% <ø> (ø)
...ges/frontity/src/utils/slot-and-fill/use-fills.tsx 100.00% <ø> (ø)
...ackages/google-ad-manager/src/components/index.tsx 0.00% <ø> (ø)
packages/google-analytics/src/components/index.tsx 100.00% <ø> (ø)
... and 12 more

@luisherranz
Copy link
Member

luisherranz commented Jan 20, 2021

npx react-codemod update-react-imports and selecting the Typescript option.

That's a good one 😄

It seems like some of the e2e tests are failing. We need to investigate that. Were you able to take a look @nicholasio?

@nicholasio
Copy link
Collaborator Author

npx react-codemod update-react-imports and selecting the Typescript option.

That's a good one 😄

It seems like some of the e2e tests are failing. We need to investigate that. Were you able to take a look @nicholasio?

Noticed that, will investigate that, had some issues yesterday with e2e tests not running but I'll figure it out.

@nicholasio
Copy link
Collaborator Author

It looks like the update to React 17 and the new JSX transform is not quite working, frontity is still requiring react to be in scope.

@nicholasio nicholasio self-assigned this Jan 21, 2021
@nicholasio
Copy link
Collaborator Author

FYI - I'm still looking into this.

@cristianbote
Copy link
Member

It looks like the update to React 17 and the new JSX transform is not quite working, frontity is still requiring react to be in scope.

@nicholasio really sorry for this one. Do you know what fails? Or where exactly is the import needed? 🤔

@nicholasio
Copy link
Collaborator Author

nicholasio commented Jan 21, 2021

It looks like the update to React 17 and the new JSX transform is not quite working, frontity is still requiring react to be in scope.

@nicholasio really sorry for this one. Do you know what fails? Or where exactly is the import needed? 🤔

Apparently, the new JSX transform is not being used, I know that babel will only use if it's available (even when you set to automatic so perhaps when frontity compiles the app, babel can´t find the jsx transform.

@cristianbote
Copy link
Member

@nicholasio I've look a bit more into it and applying the codemod on this branch #666 will make everything work smoothly.

I believe the problem lies in the React 17 and emotion 10 not working smoothly by default. So, would you mind applying the mods on that branch instead?

@nicholasio
Copy link
Collaborator Author

@cristianbote Nice! I'll wait for that branch to get merged then 👍

@nicholasio
Copy link
Collaborator Author

@cristianbote I just merged your branch here things seem to be working now, I got a couple of e2e tests failing locally but I think they are unrelated.

@cristianbote
Copy link
Member

@nicholasio I've just merged in the emotion 11 PR and now things should be smoother. Thank you so much for your contribution! ✌️

@cristianbote cristianbote self-requested a review January 25, 2021 08:03
Comment on lines +2 to +18
"@frontity/analytics": minor
"@frontity/components": minor
"@frontity/comscore-analytics": minor
"@frontity/connect": minor
"@frontity/core": minor
"frontity": minor
"@frontity/google-ad-manager": minor
"@frontity/google-analytics": minor
"@frontity/google-tag-manager-analytics": minor
"@frontity/head-tags": minor
"@frontity/hooks": minor
"@frontity/html2react": minor
"@frontity/mars-theme": minor
"@frontity/smart-adserver": minor
"@frontity/twentytwenty-theme": minor
"@frontity/types": minor
"@frontity/yoast": minor
Copy link
Member

Choose a reason for hiding this comment

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

@nicholasio was thinking if these updates require a minor update or rather a patch instead? These are not changing public facing API but rather the environment the code is running on. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point, I think I didn't go with a patch because this is not exactly a bug fix, but I'm fine to change it to patch

@cristianbote
Copy link
Member

@nicholasio thank you so much for working on this, but can you try and solve the merge conflicts above? 🙏 afterwards I believe this is gonna be ready to be merged in 🎉 .

If there's anything I can do to help, please let me know. Thank you!

@nicholasio
Copy link
Collaborator Author

@nicholasio thank you so much for working on this, but can you try and solve the merge conflicts above? 🙏 afterwards I believe this is gonna be ready to be merged in 🎉 .

If there's anything I can do to help, please let me know. Thank you!

Merge conflicts have been fixed!

@cristianbote
Copy link
Member

@nicholasio thank you so much for working on this, but can you try and solve the merge conflicts above? 🙏 afterwards I believe this is gonna be ready to be merged in 🎉 .
If there's anything I can do to help, please let me know. Thank you!

Merge conflicts have been fixed!

Awesome! Waiting for tests and then we'll approve and merge. Thank you! 😃

@cristianbote cristianbote merged commit be1cae9 into frontity:dev Jan 26, 2021
@cristianbote
Copy link
Member

Boom! 🎉 Thank you @nicholasio!

@cristianbote cristianbote linked an issue Jan 26, 2021 that may be closed by this pull request
@frontibotito frontibotito mentioned this pull request Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove old React imports from the themes
3 participants