mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* fix lint span location `feature(proc_macro_span)` has been partially stabilized in 1.89 (currently nightly) so use it without feature config now. * fix various other small lints that got added over time * use build-examples binary in size-cmp to unify build process * adjust optimization flags to newer nightly compiler
44 lines
963 B
Python
44 lines
963 B
Python
from typing import Dict, List, Optional
|
|
from pathlib import Path
|
|
|
|
import glob
|
|
import os
|
|
import json
|
|
|
|
|
|
def find_example_sizes(parent_dir: Path) -> Dict[str, int]:
|
|
example_sizes: Dict[str, int] = {}
|
|
|
|
for example_dist_dir in (parent_dir / "dist").iterdir():
|
|
|
|
total_size = 0
|
|
|
|
# For examples with multiple bundles, we add them together.
|
|
for bundle in example_dist_dir.glob(f"*.wasm"):
|
|
size = bundle.stat().st_size
|
|
|
|
print(f"{bundle} has a size of {size}.")
|
|
|
|
total_size += size
|
|
|
|
if total_size > 0:
|
|
example_sizes[example_dist_dir.name] = total_size
|
|
|
|
return example_sizes
|
|
|
|
|
|
def main() -> None:
|
|
sizes = find_example_sizes(Path.cwd())
|
|
|
|
size_cmp_info = {
|
|
"sizes": sizes,
|
|
"issue_number": os.environ["ISSUE_NUMBER"],
|
|
}
|
|
|
|
with open(".SIZE_CMP_INFO", "w+") as f:
|
|
f.write(json.dumps(size_cmp_info, indent=4))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|