Conversation
build/gulp/tasks/dist.ts
Outdated
There was a problem hiding this comment.
I split the clean tasks so I could target cleaning just the es build.
build/gulp/tasks/docs.ts
Outdated
There was a problem hiding this comment.
The corresponding clean task for this is called clean:component-info, the util function is called getComponentInfo, I've then renamed the build task for consistency.
The legacy name docgen through me off when trying to use it.
build/gulp/tasks/stats.ts
Outdated
There was a problem hiding this comment.
We loop over each component info file in docs/src/componentInfo. We keep totals of components, subcomponents, and their max, min, and gzip sizes as we loop through them. These are keyed by package.json version number.
package.json
Outdated
There was a problem hiding this comment.
We build stats on every commit, so that component count and size is updated with each change to the src. This is quite slow, so optimizations to the speed are likely warranted.
package.json
Outdated
There was a problem hiding this comment.
We were not formatting js and json files. Now we are.
Codecov Report
@@ Coverage Diff @@
## master #97 +/- ##
=========================================
Coverage ? 88.17%
=========================================
Files ? 42
Lines ? 1455
Branches ? 187
=========================================
Hits ? 1283
Misses ? 167
Partials ? 5Continue to review full report at Codecov.
|
1683fd0 to
8588707
Compare
docs/src/stats.json
Outdated
There was a problem hiding this comment.
Here's the library-level output we're getting.
docs/src/stats.json
Outdated
There was a problem hiding this comment.
Here's the component-level output we're getting.
I chose to key this by displayName for ease of access later. The displayName is our defacto way of storing values everywhere else. Keeping a flat stats file would require us to construct/deconstruct stats file key names to work with stats effectively.
290eaa7 to
30d6958
Compare
build/gulp/tasks/dist.ts
Outdated
There was a problem hiding this comment.
We were previously including the umd build with ES and CommonJS module types. Now we exclude it.
30d6958 to
d8c8115
Compare
6d48166 to
8d09eaf
Compare
8d09eaf to
882006a
Compare
|
I spent some time trying to find a way to commit&push updated stats from CI back to github but haven't found any reasonably solution.
Instead of hacking a suboptimal solution I would rather merge this and progress to the next step which is an external storage. In the mean time we can:
|
layershifter
left a comment
There was a problem hiding this comment.
I left small comments. My overall opinion: let's ship it.
However, I almost sure that we will need to switch to Rollup in the future, it will give more acurate result and will pass the compilation process much faster.
| const UNRELEASED_VERSION_STRING = 'Unreleased' | ||
| const SEMVER_MATCHER = /(\d+)\.(\d+)\.(\d+)/ | ||
|
|
||
| const semverCmp = (a, b) => { |
There was a problem hiding this comment.
Looks quite confusing that we need to have a custom function to compare semver 🤔
There was a problem hiding this comment.
Yes, we can use a package for that, but then we need to handle UNRELEASED_VERSION_STRING explicitly anyway.
Moreover, this will probably be removed once we implement external storage for bundle size.
There was a problem hiding this comment.
even given this requirement, it seems that the task would reduce to
- filter out versions with UNRELEASED_VERSION_STRING
- put them first
- compare rest entries using logic of dedicated package
This approach would be much more preferable to my mind.
This PR uses webpack to compute bundle size for individual stardust components as well as for the whole package.
TODO
/libNext, we'll make a stats page in the docs for visualizing and advertising this to users. We will extend the stats to include API surface area and render performance later as well.
Implementation details
Computing the statistics
yarn build:statsruns webpack withwebpack.config.stats.tsconfiguration which builds bundles for:All build are run in series to avoid memory issues.
Then
Unreleasedsection ofdocs/src/bundleStats.jsonfile is updated:{ "Unreleased": { "bundles": [ ... { "name": "component-Animation.js", "size": 262818 }, ... ] }, "0.12.0": { /* the same "bundles" structure */ } }Order of all items in the JSON is deterministic so that only change in size (or a new version or package removed/added) results in this file being changed.
Storing the results
New Store bundle statistics step was added to CircleCI config. This script, if run in PR build, checks that the file changed and if so, it commits it back to GIT (see this commit).
Limitations
Every change which results in changed
bundleStats.jsontriggers two buildStore bundle statistics commits a
bundleStats.jsonback to Github if it has changed. This causes several problems in CI workflow:Developers have to deal with mid-air collisions
Every commit on a branch results in a commit from CI - Developers will have to
git pull --rebasebefore pushing, will have to be more careful when force-pushing.