Skip to content

Commit 42a4f7d

Browse files
authored
Migrate to React 18 (#658)
1 parent 4b1d4b2 commit 42a4f7d

14 files changed

+2076
-1899
lines changed

.storybook/main.ts

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { StorybookConfig } from "@storybook/react-vite";
2+
import react from "@vitejs/plugin-react";
23

34
const config: StorybookConfig = {
45
stories: ["../src/**/*.mdx", "../src/**/*.@(story|stories).@(ts|tsx)"],
@@ -16,9 +17,7 @@ const config: StorybookConfig = {
1617

1718
framework: {
1819
name: "@storybook/react-vite",
19-
options: {
20-
legacyRootApi: true,
21-
},
20+
options: {},
2221
},
2322

2423
core: {
@@ -29,6 +28,30 @@ const config: StorybookConfig = {
2928
autodocs: "tag",
3029
defaultName: "Docs",
3130
},
31+
32+
// eslint-disable-next-line @typescript-eslint/require-await -- setup support for css prop
33+
async viteFinal(viteConfig) {
34+
viteConfig.plugins = viteConfig.plugins?.filter(
35+
(plugin) =>
36+
!(Array.isArray(plugin) &&
37+
plugin[0] != null &&
38+
typeof plugin[0] === "object" &&
39+
"name" in plugin[0]
40+
? plugin[0].name.includes("vite:react")
41+
: false)
42+
);
43+
44+
viteConfig.plugins?.push(
45+
react({
46+
exclude: [/\.stories\.(t|j)sx?$/, /node_modules/],
47+
babel: {
48+
plugins: ["babel-plugin-styled-components"],
49+
},
50+
})
51+
);
52+
53+
return viteConfig;
54+
},
3255
};
3356

3457
export default config;

.storybook/preview.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const preview: Preview = {
88
parameters: {
99
viewport: {
1010
viewports: INITIAL_VIEWPORTS, // newViewports would be an ViewportMap. (see below for examples)
11-
defaultViewport: "desktop",
1211
},
1312

1413
options: {

knip.jsonc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://unpkg.com/knip@next/schema.json",
33
"entry": ["src/index.ts!"],
4-
"project": ["src/**/*.{ts,tsx,mdx}!", ".storybook/**/*.js"],
4+
"project": ["src/**/*.{ts,tsx,mdx}!", ".storybook/**/*.{js,ts}"],
55
"ignoreDependencies": [
66
// False-positives
77
"@typescript-eslint/parser",
@@ -14,7 +14,9 @@
1414
// Can be listed explicitly in the future
1515
"@types/eslint",
1616
// Used in `src/setupTests.ts`
17-
"@testing-library/jest-dom"
17+
"@testing-library/jest-dom",
18+
"@vitejs/plugin-react",
19+
"babel-plugin-styled-components"
1820
],
1921
"rules": {
2022
"enumMembers": "warn"

0 commit comments

Comments
 (0)