Skip to content

fix: update to use the old JSX transform #2513

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

Merged
merged 6 commits into from
Aug 26, 2022
Merged

fix: update to use the old JSX transform #2513

merged 6 commits into from
Aug 26, 2022

Conversation

zchenwei
Copy link
Contributor

@zchenwei zchenwei commented Aug 24, 2022

Description of changes

Update to use the old JSX transform to fix a regression.

Description of how you validated changes

Create a sample React app running on a React version prior to 16.14.0 and integrate ui-react library into the app

Before After
Screen Shot 2022-08-25 at 4 04 06 PM Screen Shot 2022-08-25 at 4 09 15 PM

Checklist

  • PR description included
  • yarn test passes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@zchenwei zchenwei requested a review from a team as a code owner August 24, 2022 22:05
@changeset-bot
Copy link

changeset-bot bot commented Aug 24, 2022

🦋 Changeset detected

Latest commit: 054dce2

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

This PR includes changesets to release 1 package
Name Type
@aws-amplify/ui-react Patch

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

@zchenwei zchenwei changed the title chore: downgrade to minimum React version for build chore: downgrade to the minimum React version for build Aug 24, 2022
@zchenwei zchenwei temporarily deployed to ci August 24, 2022 22:25 Inactive
@zchenwei zchenwei temporarily deployed to ci August 24, 2022 22:25 Inactive
@zchenwei zchenwei temporarily deployed to ci August 24, 2022 22:25 Inactive
@zchenwei zchenwei temporarily deployed to ci August 24, 2022 22:25 Inactive
@zchenwei zchenwei marked this pull request as draft August 24, 2022 23:00
@zchenwei zchenwei changed the title chore: downgrade to the minimum React version for build fix: update to use the old JSX transform Aug 26, 2022
@zchenwei zchenwei marked this pull request as ready for review August 26, 2022 17:02
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 17:39 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 17:39 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 17:39 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 17:39 Inactive
@@ -8,6 +8,7 @@ const iconNames = [];

const template = ({ iconName, source }) => {
return `import classNames from 'classnames';
import * as React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old transform will need React in scope so that why I added it in a few places

@zchenwei zchenwei temporarily deployed to ci August 26, 2022 18:25 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 18:25 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 18:25 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 18:25 Inactive
@calebpollman
Copy link
Member

Thanks for handling this! Looks straightforward to me, but can you cherry pick the commit and test against in-app-messaging/main please?

"@aws-amplify/ui-react": patch
---

fix: update to use the old JSX transform to support app running on React prior to 16.14.0 where the nex JSX transform does not get backported
Copy link
Contributor

Choose a reason for hiding this comment

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

nit typo: "next JSX"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhh, good catch I mean new

joebuono
joebuono previously approved these changes Aug 26, 2022
Copy link
Contributor

@joebuono joebuono left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for fixing this

@zchenwei zchenwei requested a review from joebuono August 26, 2022 20:24
@zchenwei
Copy link
Contributor Author

zchenwei commented Aug 26, 2022

Thanks for handling this! Looks straightforward to me, but can you cherry pick the commit and test against in-app-messaging/main please?

I test against that branch you mention in a sample app and it works good. For the build, since the old transform need React in scope, so anywhere you use JSX you will need to import React in the module and Rollup will hint you. There is only one place I can see you need to during my testing: packages/react/src/components/InAppMessaging/withInAppMessaging/__tests__/withInAppMessaging.spec.tsx

@zchenwei zchenwei temporarily deployed to ci August 26, 2022 20:38 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 20:38 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 20:38 Inactive
@zchenwei zchenwei temporarily deployed to ci August 26, 2022 20:38 Inactive
@@ -4,7 +4,7 @@
"baseUrl": ".",
"declaration": true,
"esModuleInterop": true,
"jsx": "react-jsx",
Copy link
Contributor

Choose a reason for hiding this comment

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

For my knowledge, can you briefly explain why this had to be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is controls how JSX constructs are emitted in JavaScript files. It has better details here <- https://www.typescriptlang.org/tsconfig#jsx

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL!

Copy link
Member

@calebpollman calebpollman left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

@zchenwei zchenwei merged commit 0dd3e16 into main Aug 26, 2022
@zchenwei zchenwei deleted the chenwz-react16 branch August 26, 2022 22:16
@github-actions github-actions bot mentioned this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants