rocicorp / repc

The canonical Replicache client, implemented in Rust.
Other
31 stars 7 forks source link

Only use console_error_panic_hook in debug/dev builds? #358

Closed arv closed 3 years ago

arv commented 3 years ago

We are currently always using the console_error_panic_hook which according https://github.com/cloudflare/rustwasm-worker-template/blob/4a4ca5230fe0bbc6dd68958be32c823eb5d85a66/Cargo.toml#L17-L20 adds a lot of extra code.

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.

We are pretty careful not to ever panic so we should be good not doing this.

We should compare size with and without this.

arv commented 3 years ago

Enabled:

-rw-r--r--  1 arv  staff  713054 May 20 11:27 replicache_client_bg.wasm
-rw-r--r--  1 arv  staff  193722 May 20 11:27 replicache_client_bg.wasm.br

Disabled:

-rw-r--r--  1 arv  staff  713054 May 22 11:26 replicache_client_bg.wasm
-rw-r--r--  1 arv  staff  193722 May 22 11:26 replicache_client_bg.wasm.br

I guess we pull in all those things in other places.