-
-
Notifications
You must be signed in to change notification settings - Fork 153
Description
TL;DR
The released @taplo/lib
contains a 35.6MB index.js
, which is too big.
The cause seems to be the config debug: process.env["RELEASE"] !== "true"
is not working as expected in CI.
Details
My friend and I want to use @taplo/lib
in our projects, but 35.6MB is too big. So, I did some simple tests to try to find out why.

Compile taplo-wasm
directly with Cargo
Since @taplo/lib
includes the compiled wasm of taplo-wasm
, I use Cargo to compile the crate directly to see the file size of the wasm. Here are the results:
$ ls target/wasm32-unknown-unknown/debug -alh
-rwxrwxr-x 2 duskmoon duskmoon 30M Aug 27 03:14 taplo_wasm.wasm
$ ls target/wasm32-unknown-unknown/release/ -alh
-rwxrwxr-x 2 duskmoon duskmoon 5.6M Aug 27 03:18 taplo_wasm.wasm
If the wasm is compiled in release mode, it should be about 6MB instead of 35.6MB. So I assume the configuration is incorrect.
Compile @taplo/lib
with modified config
I modified rollup.config.mjs
to set debug
to false
. This ensures the code is built in release mode. And here is the output:
$ ls dist -alh
total 6.6M
drwxrwxr-x 2 duskmoon duskmoon 4.0K Aug 27 03:14 .
drwxrwxr-x 4 duskmoon duskmoon 4.0K Aug 27 03:17 ..
-rw-rw-r-- 1 duskmoon duskmoon 4.8K Aug 27 03:18 index.d.ts
-rw-rw-r-- 1 duskmoon duskmoon 6.5M Aug 27 03:18 index.js
The output index.js
is only 6.5MB.
The CI config
In the releases.yaml
, the step to build and publish is:
- name: Publish to NPM
uses: nick-fields/retry@v3
if: github.event_name == 'push'
with:
max_attempts: 3
retry_wait_seconds: 300
timeout_minutes: 60
command: cd js/lib && yarn install && yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
We might need to add RELEASE: true
to the env section to use the release mode.