test: introduce build tests
We should test for the following aspects.
- The product of the build does not contain unintended files (as a result of tree shaking).
- The file size has not increased unintentionally.
As for the file size check, information could be added as a comment to each pull request (like coverage) in the future, but this pull request does not go that far.
This pull request will enable the following outputs to be obtained.
vitest -c .vitest.config/build.ts --run
✓ build_tests/build.test.ts (5)
✓ app-jsx (1)
✓ should not be included /jsx/dom/ in sources
✓ app-simple (2)
✓ should not be included http-exception in sources
✓ should not be included /jsx/ in sources
✓ jsx-dom-all (1)
✓ should not be included /helper/html in sources
✓ jsx-dom-simple (1)
✓ should not be included /jsx/base in sources
tsx ./build_tests/report.ts
app-jsx: 8.9 KiB
app-simple: 7.5 KiB
jsx-dom-all: 5.2 KiB
jsx-dom-simple: 3.5 KiB
The author should do the following, if applicable
Codecov Report
Attention: Patch coverage is 0% with 118 lines in your changes missing coverage. Please review.
Project coverage is 93.90%. Comparing base (
614dff0) to head (9483d22).
Additional details and impacted files
@@ Coverage Diff @@
## main #2975 +/- ##
==========================================
- Coverage 94.73% 93.90% -0.84%
==========================================
Files 136 142 +6
Lines 13335 13453 +118
Branches 2251 2284 +33
==========================================
Hits 12633 12633
- Misses 702 820 +118
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Errors in the test have been fixed. The content added by this pull request is excluded from the coverage measurement.
Hi @usualoma
I also thought we had to have a measuring bundle/file size like yours. This seems great, but I have another idea. Please wait a bit until I show you it. Thanks!
Hey @usualoma
Regarding this matter, I think we should first monitor bundle sizes. Ideally, the CI will tell us the current bundle sizes and how they have increased from the main branch.
To do it, I found 3rd party library instead of implementing it by myself. There are several libraries, but the Size Limit seems to be best:
https://github.com/ai/size-limit
I've tried a little with CLI in my machine:
At first glance, I couldn't find a good way to integrate with GitHub Actions, though it has integrations with CircleCI, TravisCI, etc (perhaps we may have to use them to store the results?).
Anyway, we can use it or refer to it.
@yusukebe Regarding github action, I think this is what you are looking for : https://github.com/andresz1/size-limit-action
@Jayllyz
Ohh, thanks. Can this compare the result of PR with the main's?
I don't think so. A workaround would be to update the size limit during the release workflow. (I don't know if this is the best solution).
EDIT : This one compare with the base branch. https://github.com/preactjs/compressed-size-action
@yusukebe Thank you! I too think "ai/size-limit" is cool.
Bundle size is certainly the most important.
I was hoping in addition to that to be able to check that 'certain modules are not included', as achieved in the pull request https://github.com/honojs/hono/pull/2885. I think "a module is included that shouldn't be included" could be considered an obvious "bug".
However, it is expensive to keep track of 'modules that should not be included' in detail, and at the moment it would be fine to just use 'ai/size-limit'.