From 3283108fe0d7d4e7dc020aa63f6443822acfea90 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sun, 11 May 2025 12:55:13 +0300
Subject: [PATCH 1/3] add opt
---
src/cs/Bootsharp/Build/Bootsharp.props | 2 ++
src/cs/Bootsharp/Build/Bootsharp.targets | 8 ++++++++
2 files changed, 10 insertions(+)
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 @@
+
+
+
Date: Sun, 11 May 2025 12:55:20 +0300
Subject: [PATCH 2/3] update docs
---
docs/guide/build-config.md | 26 ++++++++++++++------------
docs/guide/llvm.md | 6 +++---
2 files changed, 17 insertions(+), 15 deletions(-)
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
From 9076871bb15b6206d19afcc1e9d16e792913e7e4 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sun, 11 May 2025 12:55:24 +0300
Subject: [PATCH 3/3] bump package version
---
src/cs/Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cs/Directory.Build.props b/src/cs/Directory.Build.props
index e3217f8d..ae82ea68 100644
--- a/src/cs/Directory.Build.props
+++ b/src/cs/Directory.Build.props
@@ -1,7 +1,7 @@
- 0.6.2
+ 0.6.3
Elringus
javascript typescript ts js wasm node deno bun interop codegen
https://bootsharp.com