Skip to content

Commit 24ad679

Browse files
authored
enhance: Reduce bundle size by removing bloated polyfills (#3384)
1 parent af372b4 commit 24ad679

25 files changed

+75
-54
lines changed

.changeset/smooth-seals-shake.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@data-client/use-enhanced-reducer': patch
3+
'@data-client/normalizr': patch
4+
'@data-client/endpoint': patch
5+
'@data-client/graphql': patch
6+
'@data-client/react': patch
7+
'@data-client/core': patch
8+
'@data-client/rest': patch
9+
'@data-client/test': patch
10+
'@data-client/img': patch
11+
---
12+
13+
Reduce bundle sizes by 30% by removing unneeded polyfills

babel.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ module.exports = function (api) {
99
process.env.BROWSERSLIST_ENV +
1010
process.env.COMPILE_TARGET +
1111
process.env.POLYFILL_TARGETS +
12-
'0',
12+
'1',
1313
);
1414
return {
1515
presets: [
1616
[
1717
'@anansi',
1818
{
19+
polyfillMethod: false,
1920
hasJsxRuntime: true,
2021
loose: true,
2122
resolver: {

packages/core/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@
124124
"url": "https://github.com/reactive/data-client/issues"
125125
},
126126
"dependencies": {
127-
"@babel/runtime-corejs3": "^7.26.0",
127+
"@babel/runtime": "^7.20.0",
128128
"@data-client/normalizr": "^0.14.20",
129-
"core-js-pure": "^3.40.0",
130129
"flux-standard-action": "^2.1.1"
131130
},
132131
"devDependencies": {

packages/core/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import pkg from './package.json' with { type: 'json' };
1515

1616
const dependencies = Object.keys(pkg.dependencies)
1717
//.concat(Object.keys(pkg.peerDependencies))
18-
.filter(dep => ![].includes(dep));
18+
.filter(dep => !['@babel/runtime'].includes(dep));
1919

2020
const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node', '.jsx'];
2121
const nativeExtensions = ['.native.ts', ...extensions];

packages/endpoint/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@
133133
"url": "https://github.com/reactive/data-client/issues"
134134
},
135135
"dependencies": {
136-
"@babel/runtime-corejs3": "^7.26.0",
137-
"core-js-pure": "^3.40.0"
136+
"@babel/runtime": "^7.20.0"
138137
},
139138
"devDependencies": {
140139
"@anansi/browserslist-config": "^1.4.2",

packages/endpoint/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import pkg from './package.json' with { type: 'json' };
1515

1616
const dependencies = Object.keys(pkg.dependencies).filter(
17-
dep => ![].includes(dep),
17+
dep => !['@babel/runtime'].includes(dep),
1818
);
1919

2020
const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node'];

packages/endpoint/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Object.hasOwn =
2+
Object.hasOwn ||
3+
/* istanbul ignore next */ function hasOwn(it, key) {
4+
return Object.prototype.hasOwnProperty.call(it, key);
5+
};
16
export type {
27
EndpointOptions,
38
EndpointInstance,

packages/graphql/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@
106106
"funding": "https://github.com/sponsors/ntucker",
107107
"license": "Apache-2.0",
108108
"dependencies": {
109-
"@babel/runtime-corejs3": "^7.26.0",
110-
"@data-client/endpoint": "^0.14.20",
111-
"core-js-pure": "^3.40.0"
109+
"@babel/runtime": "^7.20.0",
110+
"@data-client/endpoint": "^0.14.20"
112111
},
113112
"devDependencies": {
114113
"@anansi/browserslist-config": "^1.4.2",

packages/graphql/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import pkg from './package.json' with { type: 'json' };
1414

1515
const dependencies = Object.keys(pkg.dependencies).filter(
16-
dep => ![].includes(dep),
16+
dep => !['@babel/runtime'].includes(dep),
1717
);
1818

1919
const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node'];

packages/img/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@
7474
"funding": "https://github.com/sponsors/ntucker",
7575
"license": "Apache-2.0",
7676
"dependencies": {
77-
"@babel/runtime-corejs3": "^7.26.0",
78-
"@data-client/endpoint": "^0.14.20",
79-
"core-js-pure": "^3.40.0"
77+
"@babel/runtime": "^7.20.0",
78+
"@data-client/endpoint": "^0.14.20"
8079
},
8180
"peerDependencies": {
8281
"@data-client/react": "^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0",

0 commit comments

Comments
 (0)