Skip to content

Commit 9b8f086

Browse files
committed
fix: npm ignore and update benchmark docs
1 parent 888406a commit 9b8f086

5 files changed

Lines changed: 132 additions & 4 deletions

File tree

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ node_modules/
88
example/
99
example-v5/
1010
build/
11+
benchmarks/
1112
test/
1213
bin/
1314
CHANGELOG.md
1415
src/
1516
docs/
1617
public/
1718
coverage/
19+
scripts/
1820

1921
// setting files
2022
.babelrc
@@ -31,11 +33,16 @@ rollup-plugins/
3133
bundlesize.config.json
3234
prebuild.js
3335
jest.config.mjs
36+
global.d.ts
37+
tsconfig.jest.json
3438

3539
// bundler - rollup
3640
rollup.config.dev.js
3741
rollup.config.prod.js
3842
rollup.config.types.js
43+
rollup.config.dev.mjs
44+
rollup.config.prod.mjs
45+
rollup.config.types.mjs
3946

4047
// bundler - esbuild
4148
esbuild.config.dev.mjs

CONTRIBUTION.md renamed to CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,3 @@ To this:
3535

3636
OBS: do not commit this change or the docs will broken the deployment and will not be updated.
3737

38-

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ We would gladly accept a new maintainer to help out!
181181

182182
## Contributing
183183

184-
We welcome your contribution! Fork the repo, make some changes, submit a pull-request! Our [contributing](CONTRIBUTION.md) doc has some details.
184+
We welcome your contribution! Fork the repo, make some changes, submit a pull-request! Our [contributing](CONTRIBUTING.md) doc has some details.
185185

186186
## License
187187

docs/src/pages/benchmark.module.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@
172172
}
173173

174174
.tableWrap {
175-
border: 1px solid rgba(15, 23, 42, 0.08);
176-
border-radius: 18px;
177175
display: block;
178176
overflow-x: auto;
179177
overflow-y: hidden;
@@ -187,6 +185,11 @@
187185
width: max-content;
188186
}
189187

188+
.compactTable {
189+
min-width: 100%;
190+
width: 100%;
191+
}
192+
190193
.table thead th {
191194
background: #f8fafc;
192195
border-bottom: 1px solid rgba(15, 23, 42, 0.08);

docs/src/pages/benchmark.tsx

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ function formatDeltaMs(value: number) {
88
return `${sign}${value.toFixed(2)} ms`
99
}
1010

11+
function formatBytes(value: number) {
12+
if (value >= 1024) {
13+
return `${(value / 1024).toFixed(2)} KB`
14+
}
15+
16+
return `${value} B`
17+
}
18+
1119
function formatMemory(value: number) {
1220
const sign = value > 0 ? '+' : ''
1321
const absolute = Math.abs(value)
@@ -23,6 +31,11 @@ function formatPercent(value: number) {
2331
return `${value.toFixed(1)}%`
2432
}
2533

34+
function formatByteDelta(value: number) {
35+
const sign = value > 0 ? '+' : ''
36+
return `${sign}${formatBytes(value)}`
37+
}
38+
2639
function getDeltaClass(value: number) {
2740
if (value < 0) {
2841
return styles.positive
@@ -33,6 +46,64 @@ function getDeltaClass(value: number) {
3346
return styles.muted
3447
}
3548

49+
const bundleSizeRows = [
50+
{
51+
artifact: 'react-tooltip.min.mjs',
52+
v5Raw: 22704,
53+
v6Raw: 20749,
54+
rawDelta: -1955,
55+
rawDeltaPercent: -8.6,
56+
v5Gzip: 7670,
57+
v6Gzip: 7192,
58+
gzipDelta: -478,
59+
gzipDeltaPercent: -6.2,
60+
},
61+
{
62+
artifact: 'react-tooltip.min.cjs',
63+
v5Raw: 23414,
64+
v6Raw: 21067,
65+
rawDelta: -2347,
66+
rawDeltaPercent: -10.0,
67+
v5Gzip: 7733,
68+
v6Gzip: 7167,
69+
gzipDelta: -566,
70+
gzipDeltaPercent: -7.3,
71+
},
72+
{
73+
artifact: 'react-tooltip.umd.min.js',
74+
v5Raw: 23691,
75+
v6Raw: 21357,
76+
rawDelta: -2334,
77+
rawDeltaPercent: -9.9,
78+
v5Gzip: 7824,
79+
v6Gzip: 7259,
80+
gzipDelta: -565,
81+
gzipDeltaPercent: -7.2,
82+
},
83+
{
84+
artifact: 'react-tooltip.min.css',
85+
v5Raw: 2129,
86+
v6Raw: 2129,
87+
rawDelta: 0,
88+
rawDeltaPercent: 0,
89+
v5Gzip: 706,
90+
v6Gzip: 706,
91+
gzipDelta: 0,
92+
gzipDeltaPercent: 0,
93+
},
94+
]
95+
96+
const packageSizeSnapshot = {
97+
v5Tarball: 212464,
98+
v6Tarball: 114179,
99+
tarballDelta: -98285,
100+
tarballDeltaPercent: -46.3,
101+
v5Unpacked: 894316,
102+
v6Unpacked: 483478,
103+
unpackedDelta: -410838,
104+
unpackedDeltaPercent: -45.9,
105+
}
106+
36107
export default function BenchmarkPage(): React.JSX.Element {
37108
const largestRow = benchmarkSnapshot.rows[benchmarkSnapshot.rows.length - 1]
38109
const strongestMountWin = benchmarkSnapshot.rows.reduce((best, row) =>
@@ -282,6 +353,54 @@ export default function BenchmarkPage(): React.JSX.Element {
282353
consequential.
283354
</p>
284355
</div>
356+
<div className={styles.cardBody}>
357+
<h3 className={styles.cardTitle}>Shipped Size</h3>
358+
<p className={styles.cardText} style={{ marginBottom: '1rem' }}>
359+
Runtime bundle size was also reduced. The minified JavaScript artifacts shipped by
360+
v6 are smaller than their v5 equivalents across ESM, CJS, and UMD, while the
361+
published CSS stays unchanged.
362+
</p>
363+
<div className={styles.tableWrap}>
364+
<table className={`${styles.table} ${styles.compactTable}`}>
365+
<thead>
366+
<tr>
367+
<th className={styles.countColumn}>Artifact</th>
368+
<th className={styles.mountGroup}>V5 Raw</th>
369+
<th className={styles.mountGroup}>V6 Raw</th>
370+
<th className={styles.mountGroup}>Raw Delta</th>
371+
<th className={styles.mountGroup}>V5 Gzip</th>
372+
<th className={styles.mountGroup}>V6 Gzip</th>
373+
<th className={styles.mountGroup}>Gzip Delta</th>
374+
</tr>
375+
</thead>
376+
<tbody>
377+
{bundleSizeRows.map((row) => (
378+
<tr key={row.artifact}>
379+
<td className={styles.countCell}>{row.artifact}</td>
380+
<td className={styles.metricCell}>{formatBytes(row.v5Raw)}</td>
381+
<td className={styles.metricCell}>{formatBytes(row.v6Raw)}</td>
382+
<td className={`${styles.metricCell} ${getDeltaClass(row.rawDelta)}`}>
383+
{formatByteDelta(row.rawDelta)} ({formatPercent(row.rawDeltaPercent)})
384+
</td>
385+
<td className={styles.metricCell}>{formatBytes(row.v5Gzip)}</td>
386+
<td className={styles.metricCell}>{formatBytes(row.v6Gzip)}</td>
387+
<td className={`${styles.metricCell} ${getDeltaClass(row.gzipDelta)}`}>
388+
{formatByteDelta(row.gzipDelta)} ({formatPercent(row.gzipDeltaPercent)})
389+
</td>
390+
</tr>
391+
))}
392+
</tbody>
393+
</table>
394+
</div>
395+
<p className={styles.cardText}>
396+
These numbers were measured from the built <b>dist/</b> artifacts and the packed
397+
npm package for each version, so they reflect shipped output rather than source
398+
size.
399+
</p>
400+
<p className={styles.cardText}>
401+
If you like the project, please give the project a GitHub 🌟
402+
</p>
403+
</div>
285404
</section>
286405
</div>
287406
</div>

0 commit comments

Comments
 (0)