Skip to content

Commit

Permalink
fix: use react compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Oct 29, 2024
1 parent da5943d commit 7d0abf2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = {
'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'error', // Checks effect dependencies
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-compiler/react-compiler': 'warn', // Set to error once existing warnings are fixed
'react-compiler/react-compiler': 'error',
'react/no-unescaped-entities': 'off',
'no-restricted-imports': [
'error',
Expand Down
41 changes: 23 additions & 18 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import type {StorybookConfig} from '@storybook/react-vite'
import viteReact from '@vitejs/plugin-react'
import {mergeConfig} from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import type { StorybookConfig } from "@storybook/react-vite";
import viteReact from "@vitejs/plugin-react";
import { mergeConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

const config: StorybookConfig = {
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
stories: [
"../stories/**/*.mdx",
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
'@storybook/addon-a11y',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-storysource',
'@storybook/addon-themes',
'@storybook/addon-mdx-gfm',
"@storybook/addon-a11y",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-storysource",
"@storybook/addon-themes",
"@storybook/addon-mdx-gfm",
],
framework: {
name: '@storybook/react-vite',
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: 'tag',
autodocs: "tag",
},
viteFinal(config) {
return mergeConfig(config, {
plugins: [
viteReact({
babel: {plugins: [['babel-plugin-react-compiler', {target: '18'}]]},
babel: {
plugins: [["babel-plugin-react-compiler", { target: "18" }]],
},
}),
tsconfigPaths(),
],
})
});
},
}
export default config
};
export default config;
3 changes: 3 additions & 0 deletions package.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export default defineConfig({
noImplicitBrowsersList: 'off',
},
tsconfig: 'tsconfig.dist.json',
babel: {reactCompiler: true},
// @ts-expect-error - add `target` to `pkg-utils` types

Check failure on line 18 in package.config.ts

View workflow job for this annotation

GitHub Actions / build

Unused '@ts-expect-error' directive.
reactCompilerOptions: {target: '18'},
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"@sanity/icons": "^3.4.0",
"csstype": "^3.1.3",
"framer-motion": "11.0.8",
"react-compiler-runtime": "19.0.0-beta-6fc168f-20241025",
"react-refractor": "^2.2.0",
"use-effect-event": "^1.0.2"
},
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/core/utils/conditionalWrapper/conditionalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export function ConditionalWrapper({
condition,
wrapper,
}: {
children: React.ReactNode
condition: boolean
wrapper: (children: React.ReactNode) => React.ReactNode
children: React.ReactNode;
condition: boolean;
wrapper: (children: React.ReactNode) => React.ReactNode;
}): React.ReactNode {
if (!condition) {
return children
return children;
}

return wrapper(children)
return wrapper(children);
}

ConditionalWrapper.displayName = 'ConditionalWrapper'
ConditionalWrapper.displayName = "ConditionalWrapper";

0 comments on commit 7d0abf2

Please sign in to comment.