Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 7c9b24b

Browse files
authored
chore: Updated bundle size debugging documantation & datastore limits (aws-amplify#10890)
1 parent feaa44c commit 7c9b24b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CONTRIBUTING.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,15 @@ The configuration for each category can be found in the associated package's `pa
196196

197197
##### Local Invocation & Regression Debugging
198198

199-
The bundle size test can be performed locally (after building) by invoking the `test:size` build target in each package or in the mono-repo package. Bundle size regressions associated with a given change can be debugged by specifying the `--why` flag, e.g. `yarn test:size --why`, which will open a Statoscope instance to permit analysis of the generated bundle.
199+
The bundle size test can be performed locally (after building) by invoking the `test:size` build target from either a specific category or from the mono-repo package. Bundle size regressions associated with a given change can be debugged by specifying the `--why` flag, e.g. `yarn test:size --why`, which will open a Statoscope instance to permit analysis of the generated bundle. Some specific techniques for digging into regressions are outlined below.
200200

201-
To dump the generated `stats.json` for analysis in different tools: `yarn test:size --save-bundle test_bundle` (bundle will be saved to `test_bundle` directory)
201+
**Compare yarn.lock files**
202+
Comparing `yarn.lock` files for each build can be a useful way to determine if your dependency graph has changed (which may have trickle down effect on Amplify's bundle size). The easiest way to do this is to download the `yarn.lock` files from the `build` step in CircleCI (under the "Artifacts" tab) for the failing build and an older passing build. These files can then be diffed locally to see if your dependency graph has changed: `diff yarn-passing.lock yarn-failing.lock`.
202203

203-
To compare & diff one build with another: `yarn test:size --why --compare-with test_bundle/stats.json`
204+
**Compare `stats.json` files**
205+
The Webpack `stats.json` file contains a [static analysis](https://webpack.js.org/api/stats/) for a particular bundle. To generate these files locally, checkout & build the failing change, navigate to the category that's failing, and execute the following command: `yarn test:size --save-bundle test_bundle`. The generated `stats.json` file can be found in the new `test_bundle` directory. Make sure to copy this file somewhere safe for analysis. Next rebuild your parent branch (typically `main`) and compare bundles using the following command: `yarn test:size --why --compare-with stats-failing.json`. This will open a Statoscope instance in your browser. The "Choose stats" & "Diff" buttons on the top right can be used to inspect & compare your bundles.
206+
207+
`stats.json` files can also be plugged into other popular bundle analysis tools if desired.
204208

205209
## Bug Reports
206210

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@size-limit/dual-publish": "^8.1.0",
6868
"@size-limit/file": "^8.1.0",
6969
"@size-limit/webpack": "^8.1.0",
70+
"@size-limit/webpack-why": "^8.1.0",
7071
"@types/jest": "^24.0.18",
7172
"@types/lodash": "4.14.182",
7273
"@types/node": "^8.9.5",

packages/datastore/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"name": "DataStore (top-level class)",
7272
"path": "./lib-esm/index.js",
7373
"import": "{ Amplify, DataStore }",
74-
"limit": "152.5 kB"
74+
"limit": "153 kB"
7575
}
7676
],
7777
"jest": {

0 commit comments

Comments
 (0)