Skip to content

Commit 79503fd

Browse files
authored
build: upgrade storybook and dependencies (#474)
* build: upgrade storybook and dependencies * build: enable jit mode * ci: add babel-helper * ci: upgrade more deps
1 parent 238c01c commit 79503fd

File tree

10 files changed

+4734
-2766
lines changed

10 files changed

+4734
-2766
lines changed

.babelrc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"@babel/preset-react",
55
"@babel/preset-typescript"
66
],
7-
"plugins": ["@babel/plugin-proposal-class-properties"]
8-
7+
"plugins": [
8+
[
9+
"@babel/plugin-proposal-class-properties",
10+
{
11+
"loose": true
12+
}
13+
]
14+
]
915
}

.storybook/main.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const path = require('path');
2+
const postcssConfig = require('../postcss.config');
3+
14
module.exports = {
25
stories: [
36
'../src/stories/**/*.@(story|stories).mdx',
@@ -10,8 +13,28 @@ module.exports = {
1013
'@storybook/addon-viewport',
1114
'storybook-dark-mode/register',
1215
],
13-
reactOptions: {
14-
fastRefresh: true,
15-
strictMode: true,
16+
core: {
17+
builder: 'webpack5',
18+
},
19+
babel: async (options) => ({
20+
...options,
21+
}),
22+
webpackFinal: async (config) => {
23+
config.module.rules.push({
24+
test: /\.css$/,
25+
use: [
26+
{
27+
loader: 'postcss-loader',
28+
options: {
29+
postcssOptions: {
30+
...postcssConfig,
31+
},
32+
},
33+
},
34+
],
35+
include: path.resolve(__dirname, '../'),
36+
});
37+
38+
return config;
1639
},
1740
};

.storybook/preview-head.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<style>
2+
.sbdocs .sbdocs-hidden {
3+
display: none;
4+
}
5+
</style>

.storybook/preview.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'intersection-observer';
22
import 'tailwindcss/tailwind.css';
3-
import './styles.css';
43
import { themes } from '@storybook/theming';
54
import { themeOptions } from './theme';
65

.storybook/styles.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -126,66 +126,66 @@
126126
"jest-setup.js"
127127
]
128128
},
129-
"dependencies": {
130-
},
129+
"dependencies": {},
131130
"peerDependencies": {
132131
"react": "^15.0.0 || ^16.0.0 || ^17.0.0|| ^18.0.0"
133132
},
134133
"devDependencies": {
135-
"@babel/cli": "^7.12.10",
136-
"@babel/core": "^7.12.10",
137-
"@babel/plugin-proposal-class-properties": "^7.12.1",
138-
"@babel/plugin-transform-runtime": "^7.12.10",
139-
"@babel/preset-env": "^7.12.11",
140-
"@babel/preset-flow": "^7.9.0",
141-
"@babel/preset-react": "^7.12.10",
142-
"@babel/preset-typescript": "^7.12.7",
143-
"@storybook/addon-actions": "^6.1.14",
144-
"@storybook/addon-controls": "^6.1.14",
145-
"@storybook/addon-docs": "^6.1.14",
146-
"@storybook/addon-viewport": "^6.1.14",
147-
"@storybook/react": "^6.1.14",
148-
"@storybook/theming": "^6.1.14",
149-
"@testing-library/jest-dom": "^5.11.9",
150-
"@testing-library/react": "^11.2.3",
151-
"@types/jest": "^26.0.20",
152-
"@types/react": "^17.0.0",
153-
"@types/react-dom": "^17.0.0",
154-
"@typescript-eslint/eslint-plugin": "^4.13.0",
155-
"@typescript-eslint/parser": "^4.13.0",
156-
"autoprefixer": "^9",
134+
"@babel/cli": "^7.14.8",
135+
"@babel/core": "^7.15.0",
136+
"@babel/helper-builder-react-jsx": "^7.14.5",
137+
"@babel/plugin-proposal-class-properties": "^7.14.5",
138+
"@babel/plugin-transform-runtime": "^7.15.0",
139+
"@babel/preset-env": "^7.15.0",
140+
"@babel/preset-flow": "^7.14.5",
141+
"@babel/preset-react": "^7.14.5",
142+
"@babel/preset-typescript": "^7.15.0",
143+
"@storybook/addon-actions": "^6.3.7",
144+
"@storybook/addon-controls": "^6.3.7",
145+
"@storybook/addon-docs": "^6.3.7",
146+
"@storybook/addon-viewport": "^6.3.7",
147+
"@storybook/builder-webpack5": "^6.3.7",
148+
"@storybook/manager-webpack5": "^6.3.7",
149+
"@storybook/react": "^6.3.7",
150+
"@storybook/theming": "^6.3.7",
151+
"@testing-library/jest-dom": "^5.14.1",
152+
"@testing-library/react": "^12.0.0",
153+
"@types/jest": "^27.0.1",
154+
"@types/react": "^17.0.17",
155+
"@types/react-dom": "^17.0.9",
156+
"@typescript-eslint/eslint-plugin": "^4.29.1",
157+
"@typescript-eslint/parser": "^4.29.1",
158+
"autoprefixer": "^10.3.1",
157159
"babel-eslint": "^10.1.0",
158-
"babel-jest": "^26.6.3",
160+
"babel-jest": "^27.0.6",
159161
"babel-loader": "^8.2.2",
160162
"babel-plugin-dev-expression": "^0.2.2",
161-
"concurrently": "^5.1.0",
162-
"coveralls": "^3.0.11",
163-
"eslint": "^7.18.0",
163+
"concurrently": "^6.2.1",
164+
"coveralls": "^3.1.1",
165+
"eslint": "^7.32.0",
164166
"eslint-config-react-app": "^6.0.0",
165-
"eslint-plugin-flowtype": "^5.2.0",
166-
"eslint-plugin-import": "^2.20.2",
167+
"eslint-plugin-flowtype": "^5.9.0",
168+
"eslint-plugin-import": "^2.24.0",
167169
"eslint-plugin-jsx-a11y": "^6.4.1",
168-
"eslint-plugin-react": "^7.22.0",
170+
"eslint-plugin-react": "^7.24.0",
169171
"eslint-plugin-react-hooks": "^4.2.0",
170-
"framer-motion": "^3.2.1",
172+
"framer-motion": "^4.1.17",
171173
"husky": "^4.3.8",
172174
"intersection-observer": "^0.12.0",
173-
"jest": "^26.6.3",
174-
"lint-staged": "^10.5.2",
175-
"microbundle": "^0.13.0",
175+
"jest": "^27.0.6",
176+
"lint-staged": "^11.1.2",
177+
"microbundle": "^0.13.3",
176178
"npm-run-all": "^4.1.5",
177-
"postcss": "^7.0.35",
178-
"prettier": "^2.2.0",
179-
"prettier-plugin-pkg": "^0.8.0",
180-
"react": "^17.0.1",
181-
"react-dom": "^17.0.1",
182-
"react-test-renderer": "^17.0.1",
183-
"storybook-dark-mode": "^1.0.3",
184-
"tailwindcss": "npm:@tailwindcss/postcss7-compat",
185-
"typescript": "^4.1.3"
186-
},
187-
"resolutions": {
188-
"react": "^17.0.1",
189-
"react-dom": "^17.0.1"
179+
"postcss": "^8.3.6",
180+
"postcss-loader": "^6.1.1",
181+
"prettier": "^2.3.2",
182+
"prettier-plugin-pkg": "^0.10.0",
183+
"react": "^17.0.2",
184+
"react-dom": "^17.0.2",
185+
"react-test-renderer": "^17.0.2",
186+
"storybook-dark-mode": "^1.0.8",
187+
"tailwindcss": "^2.2.7",
188+
"typescript": "^4.3.5",
189+
"webpack": "^5.50.0"
190190
}
191191
}

src/observe.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ const ObserverMap = new Map<
99
}
1010
>();
1111

12-
const RootIds: WeakMap<Element, string> = new WeakMap();
13-
12+
const RootIds: WeakMap<Element | Document, string> = new WeakMap();
1413
let rootId = 0;
1514

1615
/**
1716
* Generate a unique ID for the root element
1817
* @param root
1918
*/
20-
function getRootId(root?: Element | null) {
19+
function getRootId(root: IntersectionObserverInit['root']) {
2120
if (!root) return '0';
2221
if (RootIds.has(root)) return RootIds.get(root);
2322
rootId += 1;

src/test-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ function triggerIntersection(
8888
toJSON(): any {},
8989
},
9090
isIntersecting,
91-
rootBounds: observer.root ? observer.root.getBoundingClientRect() : null,
91+
rootBounds:
92+
observer.root instanceof Element
93+
? observer.root?.getBoundingClientRect()
94+
: null,
9295
target: element,
9396
time: Date.now() - item.created,
9497
});

tailwind.config.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1+
/** @type {import("@types/tailwindcss/tailwind-config").TailwindConfig } */
12
module.exports = {
3+
// This "hack" ensures your IDE detects all normal Tailwind classes, while JIT is used when compiling the project.
4+
// All the normal Tailwind classes should show up in code completion. It can't show all the new classes generated by JIT.
5+
mode: process.env.NODE_ENV ? 'jit' : undefined,
26
purge: ['src/**/*.tsx'],
3-
theme: {
4-
extend: {},
5-
},
6-
variants: {
7-
extend: {},
8-
backgroundColor: [
9-
'responsive',
10-
'hover',
11-
'focus',
12-
'group-hover',
13-
'odd',
14-
'even',
15-
],
16-
opacity: ['responsive', 'hover', 'focus', 'group-hover'],
17-
display: ['responsive', 'hover', 'focus', 'group-hover'],
18-
},
19-
plugins: [],
207
};

0 commit comments

Comments
 (0)