ai / size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
MIT License
6.52k stars 1.82k forks source link

How to include wasm blobs in size calculation? #299

Closed fryorcraken closed 1 year ago

fryorcraken commented 1 year ago

My project https://github.com/waku-org/js-rln uses wasm blobs that are dynamically imported.

When running size-limit with the following config:

module.exports = [
  {
    name: "RLN Instance",
    path: "bundle/index.js",
    import: "{ create }",
  },
];

The wasm blobs are not included:

✔ Adding to empty webpack project
✔ Running JS in headless Chrome

  Size:         1.35 kB with all dependencies, minified and gzipped
  Loading time: 27 ms   on slow 3G
  Running time: 51 ms   on Snapdragon 410
  Total time:   78 ms
▶ ls -lh bundle/assets
total 5.1M
-rw-r--r--. 1 fryorcraken fryorcraken 1.2M Sep 27 14:22 rln-fb4d7b4b.wasm
-rw-r--r--. 1 fryorcraken fryorcraken 3.1M Sep 27 14:22 rln_final-a641c06e.zkey
-rw-r--r--. 1 fryorcraken fryorcraken 839K Sep 27 14:22 rln_wasm_bg-0185b546.wasm
ai commented 1 year ago

Can you show bundle/ content?

fryorcraken commented 1 year ago

Can you show bundle/ content?

waku-org/js-rln/bundle  feat/verify-no-root ✔                                                                                                                                                                                                                     29d11h  ⍉
▶ tree 
.
├── 02bce7e5f3bcf834.wasm
├── 20ff36861f56116ae72f.module.wasm
├── 939.index.js
├── assets
│   ├── rln-fb4d7b4b.wasm
│   ├── rln_final-a641c06e.zkey
│   ├── rln_wasm_bg-0185b546.wasm
│   ├── rln_wasm_bg-72ac39a3.wasm
│   └── rln_wasm_bg-a7027f94.wasm
├── index.js
├── rln-0e12a076.js
├── rln-4592cf99.js
├── rln-78416578.js
├── rln-79a18618.js
├── rln-a1a9aa71.js
├── rln-ae2fde2f.js
└── rln-affbe9d4.js

1 directory, 16 files
ai commented 1 year ago

Something like this will work

module.exports = [
  {
    name: "RLN Instance",
    path: "bundle/index.js",
    import: "{ create }",
  },
  {
    name: "RLN WASM addons",
    path: "bundle/assets/*.wasm"
  },
];