Skip to content

Remove wasm-pack#57304

Closed
probakowski wants to merge 14 commits intomasterfrom
probakowski/remove-webpack
Closed

Remove wasm-pack#57304
probakowski wants to merge 14 commits intomasterfrom
probakowski/remove-webpack

Conversation

@probakowski
Copy link
Copy Markdown
Contributor

This change switches our build process to use wasm-bindgen directly so wasm-pack is no longer needed

@probakowski probakowski added the no-changelog Indicates that a PR does not require a changelog entry label Jul 30, 2025
@probakowski probakowski changed the title Remove webpack Remove wasm-pack Jul 30, 2025
@probakowski probakowski changed the title Remove wasm-pack Remove wasm-pack Jul 30, 2025
Copy link
Copy Markdown
Collaborator

@zmb3 zmb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have a hard-coded wasm-bindgen-cli version in build.assets/windows/build.ps1 - can we update that too?

@probakowski
Copy link
Copy Markdown
Contributor Author

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Jul 31, 2025

Note: this adds about 74KB to the WASM module because we're no longer stripping function names (this is something wasm-opt was doing).

We can reclaim this space by re-adding wasm-opt, by having cargo strip symbols, or by using llvm-strip or wasm-strip.

@probakowski
Copy link
Copy Markdown
Contributor Author

Comment on lines -231 to -234
ARG WASM_PACK_VERSION
# Install wasm-pack for targeting WebAssembly from Rust.
RUN cargo install wasm-pack --locked --version ${WASM_PACK_VERSION}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some cache warming step here? How bad is it to compile wasm-bindgen-cli every time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine it takes 25s for wasm-bindgen-cli to be ready. Priming it is a bit tricky because cargo-bin-run depends on data from Cargo.toml and during docker image creation we don't check out code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing what @zmb3 said, we should enable symbol stripping for release builds here (if they're not needed for wasm-bindgen).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbol stripping (as in strip=true in Cargo.toml) gives no improvement in size.
I've added wasm-strip step and it gets some size back. On my machine it shows up as:

wasm-opt (size from current master):
../../../webassets/teleport/app/ironrdp_bg.wasm                                   436.05 kB │ gzip:   152.91 kB
No wasm-stip (with or without strip in Cargo.toml):
../../../webassets/teleport/app/ironrdp_bg.wasm                                   558.33 kB │ gzip:   173.94 kB
wasm-strip:
../../../webassets/teleport/app/ironrdp_bg.wasm                                   483.49 kB │ gzip:   152.40 kB

@probakowski probakowski force-pushed the probakowski/remove-webpack branch from 0b1cef0 to 33c4f4b Compare August 7, 2025 15:37
Copy link
Copy Markdown
Contributor

@fheinecke fheinecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM provided that you test by cutting a dev release after your final set of changes

#>

$TempDirectoryPath = Join-Path -Path "$([System.IO.Path]::GetTempPath())" -ChildPath "$([guid]::newguid().Guid)"
$TempDirectoryPath = Join-Path -Path "$([System.IO.Path]::GetTempPath() )" -ChildPath "$( [guid]::newguid().Guid )"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional (here and elsewhere)?

$Env:CARGO_HOME = "$ToolchainDir/cargo"
& "$ToolchainDir\rustup-init.exe" --profile minimal -y --default-toolchain "$RustVersion-x86_64-pc-windows-gnu"
Enable-Rust -ToolchainDir $ToolchainDir
& rustup target add wasm32-unknown-unknown
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
& rustup target add wasm32-unknown-unknown
rustup target add wasm32-unknown-unknown

The call operator (&) is not needed here


# Dockerized builds generate .pnpm-store in the root, so ignore it
.pnpm-store
.bin/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added to .gitignore? Can you add a comment as to why this is here and separate it from .pnmp-store as that description does not seem to apply?

},
"scripts": {
"build-wasm": "node ../../scripts/clean-up-ironrdp-artifacts.mjs && RUST_MIN_STACK=16777216 wasm-pack build ./libs/ironrdp --target web"
"build-wasm": "node ../../scripts/clean-up-ironrdp-artifacts.mjs && cd ./libs/ironrdp && cargo build --target wasm32-unknown-unknown --release && cp ../../../../../target/wasm32-unknown-unknown/release/ironrdp.* pkg/ && cargo bin wasm-bindgen pkg/ironrdp.wasm --out-dir pkg --typescript --target web && cargo bin wasm-strip pkg/ironrdp_bg.wasm"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty unwieldy - it is hard to see what is being run and if one part of it fails, it will be hard to tell which of the commands have failed. Is there a way to simplify this with node? If not, can we add a make target and call that?

As someone who has to chase down build failures, long run-on commands like this make life harder.

.PHONY: build-ironrdp-wasm
build-ironrdp-wasm: ironrdp = web/packages/shared/libs/ironrdp
build-ironrdp-wasm:
        node web/scripts/clean-up-ironrdp-artifacts.mjs
        cd $(ironrdp) && cargo build --target wasm32-unknown-unknown --release
        cp target/wasm32-unknown-unknown/release/ironrdp.* $(ironrdp)/pkg
        cargo bin wasm-bindgen $(ironrdp)/pkg/ironrdp.wasm --out-dir $(ironrdp)/pkg --typescript --target web
        cargo bin wasm-strip $(ironrdp)/pkg/ironrdp_bg.wasm

That will at least print out each commands as it runs so we can see what any failures would be related to. But I don't know if it makes sense to be mixing node package stuff with make stuff like this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this tool belongs in the top-level tool/ directory - that is for the programs we build and release. As a build tool, this belongs in build.assets/tooling or similar.

Can we also have some docs about what this is? It is simply to support the cargo bin ... command as used later? And does it just run a binary that has been put in .bin/?

If so, why do we need a tool for this - can't we just run the tool directly out of .bin/?

@rosstimothy
Copy link
Copy Markdown
Contributor

@probakowski was this superseded by #58618?

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Sep 17, 2025

Yes.

@zmb3 zmb3 closed this Sep 17, 2025
@zmb3 zmb3 deleted the probakowski/remove-webpack branch October 29, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/sm ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants