feat(cli): Add post-processing steps to optimize the bundle size#91
feat(cli): Add post-processing steps to optimize the bundle size#91ryanking13 wants to merge 2 commits intomainfrom
Conversation
|
A very simple worker that uses before after |
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR adds a post-processing optimization step using wheel-optimizer to reduce python_modules bundle size, with sensible defaults and user-configurable overrides via pyproject.toml.
Issues
-
Unpinned
wheel-optimizerdependency (medium): Every other dependency inpyproject.tomlhas version constraints (e.g.,click>=8.0.0,<9.0.0). Leavingwheel-optimizerunpinned risks breakage if a future release changes theOptimizerConfig/OptimizerPipelineAPI. -
Integration test assumes
py_filesis non-empty (low):py_files[0]will raiseIndexErrorif no.pyfiles exceed 100 bytes, producing a confusing traceback instead of a clear test failure.
| "pyodide-cli", | ||
| "pyjson5>=1.6.0", | ||
| "pyodide-py", | ||
| "wheel-optimizer", |
There was a problem hiding this comment.
All other dependencies specify version bounds. Consider pinning wheel-optimizer to avoid unexpected breakage on a new major release.
| "wheel-optimizer", | |
| "wheel-optimizer>=0.1.0,<1.0.0", |
(Adjust the range to match the version you're currently developing against.)
| for f in vendor.rglob("*.py") | ||
| if f.stat().st_size > min_file_size and f.name != "pyvenv.cfg" | ||
| ] | ||
| content = py_files[0].read_text() |
There was a problem hiding this comment.
If no .py file exceeds 100 bytes (unlikely with six, but possible if the package layout changes), this line raises an IndexError instead of a clear test failure. Adding a guard assertion gives a better diagnostic.
| content = py_files[0].read_text() | |
| assert py_files, "No .py files larger than 100 bytes found in vendor directory" | |
| content = py_files[0].read_text() |
|
Review posted successfully on PR #91 with two inline suggestion comments:
|
This adds a post-processing step after installing python packages that reduces the size of the
python_modulesdirectory by applying several optimizers.By default, following optimizers are on:
while users can addtionally turn on other optimizers if they face size limit issues.
These optimizers can be configured by the pyproject.toml file: