chore(wasm): move dm2-wasm's distribution from crates.io to npm #323
No reviewers
Labels
No labels
area/ci-release
area/cli
area/docs
area/dungeon
area/ftl
area/graphics
area/gui
area/music
area/saves
area/tooling
port/amiga
port/dos
port/fm-towns
port/mac
port/pc98
port/sega-cd
priority/high
priority/low
priority/medium
type/bug
type/chore
type/docs
type/feature
type/research
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jqueuniet/dm2-tools!323
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "chore/unpublish-wasm"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
dm2-wasm0.2.0 has been deleted from crates.io. This makes the workspacematch that, and prepares the npm package that replaces it.
Why crates.io was the wrong channel
The published page documented nothing. docs.rs builds for x86-64, where every
#[wasm_bindgen]export is compiled out, so it listed exactly one item —WasmError. The audience for these bindings is JavaScript, which reaches themthrough wasm-pack output rather than cargo.
publish = falsematters beyond tidiness: the key was absent and thereforedefaulted to publishable, so the next
cargo publish --workspacewould haveput the crate straight back on crates.io. The unused
[workspace.dependencies]entry is dropped too — nothing declared
dm2-wasm.workspace = true, and itcarried a version requirement for a crate no longer on the registry.
The npm package
crates/dm2-wasm/build-npm.shwraps wasm-pack and patches the two things itcannot express:
dm2-tools, matching the PyPI distribution, while the cratestays
dm2-wasm(wasm-pack names the package after the crate)repository.directoryset, so npm links to the crate rather than theworkspace root
It builds
--target bundler— an ES module Vite and webpack import with noexplicit init call.
--target web, which needsawait init(), remains theright choice for a checkout with no bundler; the README documents both.
Licenses are copied into the crate because wasm-pack only bundles
LICENSE*files sitting beside
Cargo.toml— the same constraint that put copies inbindings/python. Thecmpguard moves from thepythonjob tostableandnow covers both.
wasm-optswitches to-Oz. Honest number: 887,123 bytes against 912,172 withthe default
-O, so 2.7% — free, but not transformative.CI
New
wasm32-unknown-unknowncheck.cargo check --workspacebuilds this cratefor the host, where the
#[wasm_bindgen]layer is inert, so a break in the JSmarshalling layer could previously only surface when someone built the package
by hand.
Verification
The package was built in the CI image (
rust:1-trixie+ wasm-pack 0.15.0):the wasm32 check passes,
build-npm.shproducespkg/with the patched nameand
repository.directory, and both licenses land in the package.cargo fmtand
cargo clippy --workspace --all-targets -D warningsare clean; no Rustsource changed, only manifests.
Publishing stays manual — there is no npm token in CI, so a release is
npm publish crates/dm2-wasm/pkgafter the tag.