-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
.size-limit.cjs
80 lines (78 loc) · 1.8 KB
/
.size-limit.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const limits = require("./.size-limits.json");
const checks = [
{
path: "dist/apollo-client.min.cjs",
},
{
path: "dist/main.cjs",
import: "{ ApolloClient, InMemoryCache, HttpLink }",
},
{
path: "dist/index.js",
import: "{ ApolloClient, InMemoryCache, HttpLink }",
},
...[
"ApolloProvider",
"useQuery",
"useLazyQuery",
"useMutation",
"useSubscription",
"useSuspenseQuery",
"useBackgroundQuery",
"useLoadableQuery",
"useReadQuery",
"useFragment",
].map((name) => ({ path: "dist/react/index.js", import: `{ ${name} }` })),
]
.map((config) => ({
...config,
name:
config.name || config.import ?
`import ${config.import} from "${config.path}"`
: config.path,
// newer versions of size-limit changed to brotli as a default
// we'll stay on gzip for now, so results are easier to compare
gzip: true,
ignore: [
...(config.ignore || []),
"rehackt",
"react",
"react-dom",
"@graphql-typed-document-node/core",
"@wry/caches",
"@wry/context",
"@wry/equality",
"@wry/trie",
"graphql-tag",
"hoist-non-react-statics",
"optimism",
"prop-types",
"response-iterator",
"symbol-observable",
"ts-invariant",
"tslib",
"zen-observable-ts",
],
}))
.flatMap((value) =>
value.path == "dist/apollo-client.min.cjs" ?
value
: [
value,
{
...value,
name: `${value.name} (production)`,
modifyEsbuildConfig(config) {
config.define = {
"globalThis.__DEV__": `false`,
};
return config;
},
},
]
)
.map((value) => {
value.limit = limits[value.name];
return value;
});
module.exports = checks;