Skip to content

Commit

Permalink
revert back to the old JSX transform (#2122)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank99 committed Jul 2, 2024
1 parent bc49a79 commit d47d9bd
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-bags-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

The new JSX transform added in [v3.12.0](https://github.com/iTwin/iTwinUI/releases/tag/%40itwin%2Fitwinui-react%403.12.0) has been reverted, because React 17 [doesn't properly support it](https://github.com/facebook/react/issues/20235).
9 changes: 0 additions & 9 deletions packages/itwinui-react/.eslintignore

This file was deleted.

3 changes: 3 additions & 0 deletions packages/itwinui-react/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ module.exports = {
rules: {
...preset.rules,
'@typescript-eslint/no-explicit-any': 'off',
'react/jsx-uses-react': 1,
'react/react-in-jsx-scope': 1,
},
ignorePatterns: ['**/esm/**', '**/cjs/**', '**.test.*', '**.types-test.*'],
};
6 changes: 5 additions & 1 deletion packages/itwinui-react/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const swcOptions = {
'jsc.parser.syntax=typescript',
'jsc.parser.tsx=true',
'jsc.transform.react.useBuiltins=true',
'jsc.transform.react.runtime=automatic',

// We cannot (currently) use the new JSX transform, because it relies on ESM exports
// which are not available in React 17. See https://github.com/facebook/react/issues/20235
// 'jsc.transform.react.runtime=automatic',

'jsc.target=es2020',
'jsc.minify.format.comments=false',
'jsc.externalHelpers=true',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import type {
CellProps,
CellRendererProps,
Expand Down
16 changes: 11 additions & 5 deletions packages/itwinui-react/src/utils/icons/StatusIconMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { SvgInfoCircular } from './SvgInfoCircular.js';
import { SvgStatusError } from './SvgStatusError.js';
import { SvgStatusSuccess } from './SvgStatusSuccess.js';
import { SvgStatusWarning } from './SvgStatusWarning.js';
import type { CommonProps } from '../props.js';

export const StatusIconMap = {
negative: (args?: CommonProps) => <SvgStatusError aria-hidden {...args} />,
positive: (args?: CommonProps) => <SvgStatusSuccess aria-hidden {...args} />,
warning: (args?: CommonProps) => <SvgStatusWarning aria-hidden {...args} />,
informational: (args?: CommonProps) => (
negative: (args?: React.ComponentPropsWithoutRef<'svg'>) => (
<SvgStatusError aria-hidden {...args} />
),
positive: (args?: React.ComponentPropsWithoutRef<'svg'>) => (
<SvgStatusSuccess aria-hidden {...args} />
),
warning: (args?: React.ComponentPropsWithoutRef<'svg'>) => (
<SvgStatusWarning aria-hidden {...args} />
),
informational: (args?: React.ComponentPropsWithoutRef<'svg'>) => (
<SvgInfoCircular aria-hidden {...args} />
),
};
2 changes: 1 addition & 1 deletion packages/itwinui-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"esModuleInterop": true,
"sourceMap": false,
"allowJs": false,
"jsx": "react-jsx",
"jsx": "react",
"moduleResolution": "NodeNext",
"traceResolution": false,
"forceConsistentCasingInFileNames": true,
Expand Down
7 changes: 5 additions & 2 deletions packages/itwinui-react/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "./tsconfig.json",
// TODO: Test all the files, and not just the Table files or just the build files.
"include": ["src/**/*.test.*", "src/**/*.types-test.*"]
"compilerOptions": {
"jsx": "react-jsx",
"noUnusedLocals": false
},
"include": ["**/*.test.*", "**/*.types-test.*"]
}
3 changes: 3 additions & 0 deletions packages/itwinui-react/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ export default defineConfig({
},
},
],
esbuild: {
jsx: 'automatic',
},
});

0 comments on commit d47d9bd

Please sign in to comment.