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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

build --release should generate JS without white-space #1373

Open
Rudxain opened this issue Mar 6, 2024 · 1 comment
Open

build --release should generate JS without white-space #1373

Rudxain opened this issue Mar 6, 2024 · 1 comment

Comments

@Rudxain
Copy link

Rudxain commented Mar 6, 2024

馃挕 Feature description

The JS-wrappers generated with other build-artifacts are formatted in a way that makes them easier to debug, which is a must if using --dev. But this makes no sense for --release.

I understand that this "gives freedom to devs" to choose whatever minifier they need/want. But why not simply strip white-space?

@ErikSom
Copy link

ErikSom commented Mar 24, 2024

I've just created a build script for myself, but would be nice if wasm-pack did this:

#!/usr/bin/env bash

# Set default build type to 'dev' if not specified
BUILD_TYPE=${1:-dev}

# Common flags
COMMON_FLAGS="--target web --out-dir ./dist"

# Development build flags
DEV_FLAGS="--dev"

# Production build flags
PROD_FLAGS="--release"

# Select flags based on build type
if [ "$BUILD_TYPE" = "dev" ]; then
    FLAGS="$COMMON_FLAGS $DEV_FLAGS"
    echo "Building Development Version"
else
    FLAGS="$COMMON_FLAGS $PROD_FLAGS"
    echo "Building Production Version"
fi

# Web

# build ES6
echo "Building ES6"
wasm-pack build $FLAGS

# Remove .gitignore file from dist
rm ./dist/.gitignore

# check if terser is installed
if ! command -v terser &> /dev/null
then
	echo "terser could not be found, installing terser"
	npm install terser
fi

# minify the js file
echo "Minifying JS"
npx terser ./dist/simplify_rs.js --compress --output ./dist/simplify_rs.js

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

2 participants