Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The released @taplo/lib is too big, seems RELEASE is not used in CI #660

Open
duskmoon314 opened this issue Aug 27, 2024 · 0 comments
Open

Comments

@duskmoon314
Copy link

duskmoon314 commented Aug 27, 2024

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.

image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant