diff --git a/docs/guide/build-config.md b/docs/guide/build-config.md index a73cf5db..89e103f1 100644 --- a/docs/guide/build-config.md +++ b/docs/guide/build-config.md @@ -2,19 +2,20 @@ Build and publish related options are configured in `.csproj` file via MSBuild properties. -| Property | Default | Description | -|-----------------------------|------------|--------------------------------------------------------------| -| BootsharpName | bootsharp | Name of the generated JavaScript module. | -| BootsharpEmbedBinaries | true | Whether to embed binaries to the JavaScript module file. | -| BootsharpAggressiveTrimming | false | Whether to disable some .NET features to reduce binary size. | -| BootsharpLLVM | false | Enable experimental [NativeAOT-LLVM](/guide/llvm) backend. | -| BootsharpBundleCommand | npx rollup | The command to bundle generated JavaScrip solution. | -| BootsharpPublishDirectory | /bin | Directory to publish generated JavaScript module. | -| BootsharpTypesDirectory | /types | Directory to publish type declarations. | -| BootsharpBinariesDirectory | /bin | Directory to publish binaries when `EmbedBinaries` disabled. | -| BootsharpPackageDirectory | / | Directory to publish `package.json` file. | +| Property | Default | Description | +|-----------------------------|------------|----------------------------------------------------------------------------------------------------------------------------------| +| BootsharpName | bootsharp | Name of the generated JavaScript module. | +| BootsharpEmbedBinaries | true | Whether to embed binaries to the JavaScript module file. | +| BootsharpAggressiveTrimming | false | Whether to disable some .NET features to reduce binary size. | +| BootsharpOptimize | none | Whether to optimize the WASM for `speed` or `size`. Requires [Binaryen](https://github.com/WebAssembly/binaryen) in system path. | +| BootsharpLLVM | false | Enable experimental [NativeAOT-LLVM](/guide/llvm) backend. | +| BootsharpBundleCommand | npx rollup | The command to bundle generated JavaScrip solution. | +| BootsharpPublishDirectory | /bin | Directory to publish generated JavaScript module. | +| BootsharpTypesDirectory | /types | Directory to publish type declarations. | +| BootsharpBinariesDirectory | /bin | Directory to publish binaries when `EmbedBinaries` disabled. | +| BootsharpPackageDirectory | / | Directory to publish `package.json` file. | -Below is an example configuration, which will make Bootsharp name compiled module "backend" (instead of the default "bootsharp"), publish the module under solution directory root (instead of "/bin"), disable binaries embedding and instead publish them under "public/bin" directory one level above the solution root and enable aggressive assembly trimming to reduce build size: +Below is an example configuration, which will make Bootsharp name compiled module "backend" (instead of the default "bootsharp"), publish the module under solution directory root (instead of "/bin"), disable binaries embedding and instead publish them under "public/bin" directory one level above the solution root and enable aggressive assembly trimming and WASM optimization to reduce the build size: ```xml @@ -27,6 +28,7 @@ Below is an example configuration, which will make Bootsharp name compiled modul false $(SolutionDir)../public/bin true + size diff --git a/docs/guide/llvm.md b/docs/guide/llvm.md index 6183c4bc..2df8645a 100644 --- a/docs/guide/llvm.md +++ b/docs/guide/llvm.md @@ -58,8 +58,8 @@ Use following `.csproj` as a reference for enabling NativeAOT-LLVM with Bootshar ## Binaryen -Optionally, after publishing with NativeAOT-LLVM, you can further optimize the produced WASM using Binaryen: +Optionally, you can further optimize the produced WASM using Binaryen: 1. Install the tool https://github.com/WebAssembly/binaryen -2. Run `wasm-opt bin/bootsharp/bin/dotnet.native.wasm -O3 -o bin/bootsharp/bin/dotnet.native.wasm --all-features --strip-dwarf --strip-debug --vacuum` -3. To optimize for size instead of speed, replace `-O3` with `-Oz` +2. Make sure `wasm-opt` is in the system path +3. Add `speed` to the project config to optimize for speed; replace `speed` with `size` to instead optimize for size diff --git a/src/cs/Bootsharp/Build/Bootsharp.props b/src/cs/Bootsharp/Build/Bootsharp.props index 6f6876ed..947902b0 100644 --- a/src/cs/Bootsharp/Build/Bootsharp.props +++ b/src/cs/Bootsharp/Build/Bootsharp.props @@ -18,6 +18,8 @@ true false + + none false diff --git a/src/cs/Bootsharp/Build/Bootsharp.targets b/src/cs/Bootsharp/Build/Bootsharp.targets index de8c0eb7..0e2498a4 100644 --- a/src/cs/Bootsharp/Build/Bootsharp.targets +++ b/src/cs/Bootsharp/Build/Bootsharp.targets @@ -109,6 +109,8 @@ true false false + -O3 + -Oz @@ -117,6 +119,12 @@ + + + - 0.6.2 + 0.6.3 Elringus javascript typescript ts js wasm node deno bun interop codegen https://bootsharp.com