Skip to content

Commit 05840e0

Browse files
committed
perf: scrolling performance
1 parent abd2709 commit 05840e0

20 files changed

+9471
-5503
lines changed

.babelrc.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { NODE_ENV, BABEL_ENV } = process.env
2+
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
3+
const loose = true
4+
5+
module.exports = {
6+
presets: [
7+
[
8+
'@babel/env',
9+
{
10+
loose,
11+
modules: false,
12+
exclude: ['@babel/plugin-transform-regenerator'],
13+
},
14+
],
15+
'@babel/preset-typescript',
16+
'@babel/react',
17+
],
18+
plugins: [
19+
[
20+
'const-enum',
21+
{
22+
transform: 'constObject',
23+
},
24+
],
25+
'babel-plugin-transform-async-to-promises',
26+
cjs && ['@babel/transform-modules-commonjs', { loose }],
27+
[
28+
'@babel/transform-runtime',
29+
{
30+
useESModules: !cjs,
31+
version: require('./package.json').dependencies[
32+
'@babel/runtime'
33+
].replace(/^[^0-9]*/, ''),
34+
},
35+
],
36+
].filter(Boolean),
37+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ size-plugin.json
2222
stats.html
2323
yarn-debug.log*
2424
yarn-error.log*
25+
es
26+
lib
27+
types

examples/simple/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function App() {
4343
</div>
4444
);
4545
})}
46-
<div style={{ height: "5rem" }} />
46+
<div style={{ height: "50rem" }} />
4747
</div>
4848
);
4949
}

package.json

+88-55
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
{
22
"name": "react-charts",
3-
"author": "Tanner Linsley",
4-
"description": "Charts for React",
5-
"repository": "tannerlinsley/react-charts",
6-
"module": "dist/react-charts.esm.js",
7-
"version": "0.1.0",
3+
"version": "1.0.0-semantic-release",
4+
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5+
"author": "tannerlinsley",
86
"license": "MIT",
9-
"main": "dist/index.js",
10-
"typings": "dist/index.d.ts",
7+
"repository": "tannerlinsley/react-charts",
8+
"homepage": "https://github.com/tannerlinsley/react-charts#readme",
119
"funding": {
1210
"type": "github",
1311
"url": "https://github.com/sponsors/tannerlinsley"
1412
},
13+
"main": "lib/index.js",
14+
"unpkg": "dist/react-charts.development.js",
15+
"types": "types/index.d.ts",
16+
"module": "es/index.js",
1517
"files": [
1618
"dist",
17-
"src"
19+
"es",
20+
"lib",
21+
"scripts",
22+
"types"
1823
],
19-
"engines": {
20-
"node": ">=10"
21-
},
2224
"scripts": {
23-
"start": "tsdx watch",
24-
"build": "tsdx build",
25-
"test": "tsdx test --passWithNoTests",
26-
"lint": "tsdx lint",
27-
"prepare": "tsdx build",
28-
"size": "size-limit",
29-
"analyze": "size-limit --why",
25+
"test": "is-ci \"test:ci\" \"test:dev\"",
26+
"test:dev": "npm run test:types && npm run test:eslint && jest --watch",
27+
"test:ci": "npm run test:types && npm run test:eslint && jest",
28+
"test:coverage": "yarn test:ci; open coverage/lcov-report/index.html",
29+
"test:types": "tsc",
30+
"test:eslint": "eslint --ext .ts,.tsx ./src",
31+
"build": "yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:types",
32+
"build:commonjs": "rimraf ./lib && cross-env BABEL_ENV=commonjs babel --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir lib",
33+
"build:es": "rimraf ./es && babel --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir es",
34+
"build:umd": "rimraf ./dist && cross-env NODE_ENV=production rollup -c && rollup-plugin-visualizer stats-react.json",
35+
"build:types": "rimraf ./types && tsc --project ./tsconfig.types.json && replace 'import type' 'import' ./types -r --silent && replace 'export type' 'export' ./types -r --silent",
36+
"watch": "yarn watch:commonjs & yarn watch:es & yarn watch:umd & yarn watch:types",
37+
"watch:commonjs": "rimraf ./lib && cross-env BABEL_ENV=commonjs babel --watch --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir lib",
38+
"watch:es": "rimraf ./es && babel --watch --extensions .ts,.tsx --ignore ./src/**/tests/**/* ./src --out-dir es",
39+
"watch:umd": "rimraf ./dist && cross-env NODE_ENV=production rollup -w -c && rollup-plugin-visualizer stats-react.json",
40+
"watch:types": "rimraf ./types && tsc --watch --project ./tsconfig.types.json && replace 'import type' 'import' ./types -r --silent && replace 'export type' 'export' ./types -r --silent",
41+
"now-build": "yarn && cd www && yarn && yarn build",
42+
"start": "yarn watch",
43+
"format": "prettier {.,src,src/**,example/src,example/src/**,types}/*.{md,js,jsx,tsx,json} --write",
44+
"stats": "open ./stats.html",
3045
"typedoc": "typedoc"
3146
},
3247
"peerDependencies": {
@@ -54,55 +69,73 @@
5469
"pre-commit": "tsdx lint"
5570
}
5671
},
57-
"size-limit": [
58-
{
59-
"path": "dist/react-charts-1.cjs.production.min.js",
60-
"limit": "10 KB"
61-
},
62-
{
63-
"path": "dist/react-charts-1.esm.js",
64-
"limit": "10 KB"
65-
}
66-
],
6772
"devDependencies": {
68-
"@babel/core": "^7.14.6",
69-
"@size-limit/preset-small-lib": "^5.0.1",
70-
"@trivago/prettier-plugin-sort-imports": "^2.0.2",
71-
"@types/d3-shape": "^3.0.1",
72-
"@types/react": "^17.0.14",
73-
"@types/react-dom": "^17.0.9",
74-
"@typescript-eslint/eslint-plugin": "^4.28.2",
75-
"@typescript-eslint/parser": "^4.28.2",
76-
"babel-loader": "^8.2.2",
77-
"eslint": "^7.30.0",
73+
"@babel/cli": "^7.11.6",
74+
"@babel/core": "^7.11.6",
75+
"@babel/plugin-transform-runtime": "^7.11.5",
76+
"@babel/preset-env": "^7.11.5",
77+
"@babel/preset-react": "^7.10.4",
78+
"@babel/preset-typescript": "^7.10.4",
79+
"@rollup/plugin-replace": "^2.3.3",
80+
"@svgr/rollup": "^5.4.0",
81+
"@testing-library/react": "^12.0.0",
82+
"@types/jest": "^26.0.4",
83+
"@typescript-eslint/eslint-plugin": "^4.8.1",
84+
"@typescript-eslint/parser": "^4.8.1",
85+
"babel-eslint": "^10.1.0",
86+
"babel-jest": "^27.0.6",
87+
"babel-plugin-const-enum": "^1.0.1",
88+
"babel-plugin-transform-async-to-promises": "^0.8.15",
89+
"cross-env": "^7.0.2",
90+
"eslint": "7.x",
7891
"eslint-config-prettier": "^8.3.0",
79-
"eslint-plugin-react-hooks": "^4.2.0",
80-
"husky": "^6.0.0",
92+
"eslint-config-react-app": "^6.0.0",
93+
"eslint-config-standard": "^16.0.3",
94+
"eslint-config-standard-react": "^11.0.1",
95+
"eslint-plugin-flowtype": "5.x",
96+
"eslint-plugin-import": "^2.22.1",
97+
"eslint-plugin-jsx-a11y": "6.x",
98+
"eslint-plugin-node": "^11.1.0",
99+
"eslint-plugin-prettier": "^3.1.3",
100+
"eslint-plugin-promise": "^5.1.0",
101+
"eslint-plugin-react": "7.24.0",
102+
"eslint-plugin-react-hooks": "4.2.0",
103+
"eslint-plugin-standard": "^5.0.0",
104+
"is-ci-cli": "^2.1.1",
105+
"jest": "^27.0.6",
106+
"prettier": "2.3.2",
81107
"react": "^17.0.2",
82108
"react-dom": "^17.0.2",
83-
"react-is": "^17.0.2",
109+
"react-error-boundary": "^3.1.3",
110+
"replace": "^1.2.0",
111+
"rimraf": "^3.0.2",
112+
"rollup": "^2.16.1",
84113
"rollup-plugin-babel": "^4.4.0",
114+
"rollup-plugin-commonjs": "^10.1.0",
115+
"rollup-plugin-jscc": "^2.0.0",
85116
"rollup-plugin-node-resolve": "^5.2.0",
86-
"size-limit": "^5.0.1",
87-
"tsdx": "^0.14.1",
88-
"tslib": "^2.3.0",
89-
"typedoc": "^0.21.2",
117+
"rollup-plugin-peer-deps-external": "^2.2.2",
118+
"rollup-plugin-prettier": "^2.1.0",
119+
"rollup-plugin-size": "^0.2.2",
120+
"rollup-plugin-terser": "^7.0.2",
121+
"rollup-plugin-visualizer": "^5.5.2",
90122
"typescript": "^4.3.5"
91123
},
92124
"dependencies": {
125+
"@babel/runtime": "^7.14.6",
126+
"@reach/observe-rect": "^1.2.0",
127+
"@react-spring/web": "^9.2.3",
93128
"@types/d3-array": "^3.0.1",
94129
"@types/d3-scale": "^4.0.1",
130+
"@types/d3-shape": "^3.0.1",
95131
"@types/raf": "^3.4.0",
96-
"@reach/observe-rect": "^1.2.0",
97-
"@react-spring/web": "^9.2.3",
98-
"d3-array": "^3.0.1",
99-
"d3-scale": "^4.0.0",
100-
"d3-shape": "^3.0.1",
101-
"d3-time": "^3.0.0",
102-
"jotai": "^1.1.2",
132+
"@types/react": "^17.0.14",
133+
"@types/react-dom": "^17.0.9",
134+
"d3-array": "^2.12.1",
135+
"d3-scale": "^3.3.0",
136+
"d3-shape": "^2.1.0",
137+
"d3-time": "^2.1.1",
138+
"jotai": "^1.1.3",
103139
"ts-toolbelt": "^9.6.0"
104-
},
105-
"resolutions": {
106-
"typescript": "^4.3.2"
107140
}
108141
}

rollup.config.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import babel from 'rollup-plugin-babel'
2+
import commonJS from 'rollup-plugin-commonjs'
3+
import resolve from 'rollup-plugin-node-resolve'
4+
import externalDeps from 'rollup-plugin-peer-deps-external'
5+
import size from 'rollup-plugin-size'
6+
import { terser } from 'rollup-plugin-terser'
7+
import visualizer from 'rollup-plugin-visualizer'
8+
9+
import replace from '@rollup/plugin-replace'
10+
11+
const external = ['react', 'react-dom', 'react-charts']
12+
13+
const globals = {
14+
react: 'React',
15+
'react-dom': 'ReactDOM',
16+
'react-charts': 'ReactCharts',
17+
}
18+
19+
const inputSrcs = [['src/index.ts', 'ReactCharts', 'react-charts']]
20+
21+
const extensions = ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx']
22+
const babelConfig = { extensions, runtimeHelpers: true }
23+
const resolveConfig = { extensions }
24+
25+
export default inputSrcs
26+
.map(([input, name, file]) => {
27+
return [
28+
{
29+
input: input,
30+
output: {
31+
name,
32+
file: `dist/${file}.development.js`,
33+
format: 'umd',
34+
sourcemap: true,
35+
globals,
36+
},
37+
external,
38+
plugins: [
39+
resolve(resolveConfig),
40+
babel(babelConfig),
41+
commonJS(),
42+
externalDeps(),
43+
],
44+
},
45+
{
46+
input: input,
47+
output: {
48+
name,
49+
file: `dist/${file}.production.min.js`,
50+
format: 'umd',
51+
sourcemap: true,
52+
globals,
53+
},
54+
external,
55+
plugins: [
56+
replace({
57+
'process.env.NODE_ENV': `"production"`,
58+
delimiters: ['', ''],
59+
}),
60+
resolve(resolveConfig),
61+
babel(babelConfig),
62+
commonJS(),
63+
externalDeps(),
64+
terser(),
65+
size(),
66+
visualizer({
67+
filename: 'stats-react.json',
68+
json: true,
69+
}),
70+
],
71+
},
72+
]
73+
})
74+
.flat()

0 commit comments

Comments
 (0)