Skip to content

Commit

Permalink
Stop using jsx-runtime in opensource/sdk-js (#4994)
Browse files Browse the repository at this point in the history
In order to increase compatibility with potential customer build
configurations, stop using the new JSX transform for React[1].

There are two issues with the new transform.  One is that it's only
supported on React 17+, as well as some backported versions of 15 and
16.  The other is that, pre-React 18, the new transform involves an
import from `react/jsx-runtime`, but that file isn't explicitly
exported by the `react` package, and as a result some build systems
(notably, Webpack 5+) will not be able to process the import [2].

[1] https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

[2] facebook/react#20235 (comment)


Test Plan:

npm run build

npm run tsc-packages

Ran the testbed, all components seemed to render fine, including
ThreadedComments.

monorepo-commit: 0c6f26eb5e8bc8bc3a4dc8d6a16325081d3ec473
  • Loading branch information
flooey authored and jwatzman committed Jun 14, 2023
1 parent 72c87f1 commit 74320e7
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/react/components/AddReaction.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Composer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Facepile.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Inbox.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import type { InboxWebComponentEvents } from '@cord-sdk/types';
import {
componentAttributes,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/InboxLauncher.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import type {
BadgeStyle,
InboxLauncherWebComponentEvents,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Message.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/NotificationList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/NotificationListLauncher.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/PagePresence.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import type {
Orientation,
PagePresenceWebComponentEvents,
Expand Down
2 changes: 2 additions & 0 deletions packages/react/components/Pin.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-ignore TS wants us to `import type` this, but we need it for JSX
import * as React from 'react';
import type { PropsWithChildren } from 'react';
import { useCallback } from 'react';

Expand Down
1 change: 1 addition & 0 deletions packages/react/components/PresenceFacepile.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import type {
Orientation,
PresenceFacepileWebComponentEvents,
Expand Down
2 changes: 2 additions & 0 deletions packages/react/components/PresenceObserver.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-ignore TS wants us to `import type` this, but we need it for JSX
import * as React from 'react';
import type { PresenceObserverWebComponentEvents } from '@cord-sdk/types';
import {
componentAttributes,
Expand Down
2 changes: 2 additions & 0 deletions packages/react/components/SelectionComments.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-ignore TS wants us to `import type` this, but we need it for JSX
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import {
componentAttributes,
propsToAttributeConverter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/SidebarLauncher.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import type {
BadgeStyle,
SidebarLauncherWebComponentEvents,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/Thread.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import type { PropsWithChildren } from 'react';
import { useCallback } from 'react';

Expand Down
1 change: 1 addition & 0 deletions packages/react/components/ThreadFacepile.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { Facepile, thread } from '@cord-sdk/react';

export function ThreadFacepile({ threadId }: { threadId: string }) {
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/ThreadList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { useCallback } from 'react';
import type {
ThreadListFilter,
Expand Down
1 change: 1 addition & 0 deletions packages/react/components/ThreadedComments.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import cx from 'classnames';
import type { Location, ThreadSummary } from '@cord-sdk/types';
import type { Dispatch, SetStateAction } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"strict": true,
"esModuleInterop": true,
"declaration": true,
"jsx": "react-jsx",
"jsx": "react",
"inlineSourceMap": true
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function rollupConfig() {
packageBuildConfig('types'),
packageBuildConfig('components'),
packageBuildConfig('jsx'),
packageBuildConfig('react', { extraExternal: ['react/jsx-runtime'] }),
packageBuildConfig('react'),
packageBuildConfig('server'),
packageBuildConfig('api-types', {
extraCopyTargets: [
Expand Down

0 comments on commit 74320e7

Please sign in to comment.