Skip to content

impl(031): the WebAssembly npm package ships its entry points - #352

Merged
bartekus merged 1 commit into
mainfrom
impl/031-wasm-entry-points
Oct 28, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/031-wasm-entry-points

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Summary

The published @rustev/[email protected] tarball declares exports targets ./{web,bundler,node}/index.{js,d.ts} but contains none of them: artifacts.sh pack ran wasm-bindgen and wasm-opt and never staged the wrappers. The npm declaration comparison caught it (missing or external declaration entry @rustev/rustev-wasm ./bundler: ./bundler/index.d.ts).

  • tools/rustev-release/artifacts.sh: pack runs node tools/rustev-conformance/js/wrap-wasm.mjs integrations/rustev-wasm after the wasm-bindgen loop, as make bindings does. The generated index.js inlines the wrapper factory and index.d.ts re-exports ./rustev_wasm, so files needs no change.
  • tools/rustev-release/src/artifacts.rs: npm_audit (031 3.9.2) now refuses a tarball missing a file named by main, types, typings, or any string leaf of exports under every condition (package/<target>). It also refuses targets that are external (.., absolute) or name a directory, and refuses wildcards, as npm-api-diff.mjs does.
  • tools/rustev-release/tests/artifacts.rs: the wasm manifest passes with all of its entry points; dropping bundler/index.d.ts (the types condition) or web/index.js (the import condition) each gives exactly one problem naming the target; a wildcard and an external main are refused. The existing fixtures now pack the node package's declared files.
  • Spec 031 Implementation record: a 2026-10-28 paragraph. No status changes.

Verification

  • lane1 cargo test -p rustev-release --locked: every suite ok, tests/artifacts.rs test result: ok. 10 passed; 0 failed, including npm_audit_refuses_a_tarball_missing_a_declared_entry_point ... ok
  • lane1 cargo clippy -p rustev-release --all-targets --locked -- -D warnings: clean
  • lane1 cargo fmt --check: clean
  • sh -n tools/rustev-release/artifacts.sh: ok
  • make refresh then make gate: exit 0
  • spec-spine couple --base origin/main --head HEAD: OK: 4 path(s) checked, no drift.
  • bash scripts/check-authored-content.sh: 2180 authored file(s) clean (U+2014, session links)
  • lane1 make bindings (wasm-bindgen 0.2.129, wasm-opt 116): exit 0, conformance native: 192 case(s), 0 failure(s); target/bindings/rustev-wasm/{web,bundler,node}/index.{js,d.ts} all present
  • Pack layout: wrap-wasm.mjs on a copy of integrations/rustev-wasm followed by npm pack --dry-run lists web/, bundler/, node/ index.js and index.d.ts

The 0.1.0 wasm tarball named web, bundler and node index.js and index.d.ts
in its exports but packed none of them: artifacts.sh pack never ran
wrap-wasm.mjs. The pack now stages them as make bindings does, and
npm-audit refuses a tarball missing any file its main, types, typings or
exports name, or naming a wildcard.
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the four changed files for bugs, security issues, and inconsistencies.

specs/031-public-api-and-release-family/spec.md
Progress note added under the existing notes section. Consistent with the code changes described; no issues.

tools/rustev-release/artifacts.sh

node tools/rustev-conformance/js/wrap-wasm.mjs integrations/rustev-wasm

Inserted after the package.json per-target loop and before the node addon copies, so the wasm wrapper script runs after target package.json files are written. Both paths are hardcoded; no injection surface. Order is correct.

tools/rustev-release/src/artifacts.rs — audit_entry_points

Path traversal protection: the combination of path.starts_with('/'), path.is_empty(), path.ends_with('/'), and the component-level ".." / "." check is sound. target = "../index.js" hits the component check; target = "./" hits is_empty after strip; target = "./foo/./bar" hits "." in the component check. The test covers "../index.js" via the p["main"] mutation.

walk key generation: subpath export keys (starting with .) replace the context string, while condition keys (not starting with .) append #{k}. For real npm package.json structures, this is correct — condition keys never start with . in valid npm exports maps.

Wildcard check: target.contains('*') covers wildcard target values. A wildcard in the export key (e.g. "./extra/*") with a non-wildcard target would fall through to the file-presence check, which would likely also fail since no literal file exists for a glob pattern path. This is indirect but not a concrete defect given the test covers the wildcard-target case and the file-missing path catches the rest.

tools/rustev-release/tests/artifacts.rs

Option::as_slice() (stabilized in Rust 1.75) correctly converts None → &[] and Some(x) → &[x]; the bridging tar function is correct.

MAIN_FILES was added to provide the additional entry points (index.d.ts, types/rustev-documents.d.ts) that audit_entry_points now checks and that the original single-file fixture wouldn't satisfy. The two test updates (npm_audit_accepts_family_and_rejects_each_dependency_rule and candidate_npm_version_optional_dependencies_and_sbom) are consistent with the new check being wired in.

The npm_audit_refuses_a_tarball_missing_a_declared_entry_point test: the loop overwrites wasm.tgz each iteration, then the wildcard/traversal assertion overwrites it one final time. The any(...) assertion handles any extra errors from audit_manifest without masking the intended signal.

No defects found.

{"head": "2a197700fde66b29ee9e85fa451750dca917a4d4", "verdict": "no-findings", "findings": []}

Subject: 70410fb...2a19770, diff digest d283530dc1b714b5ae59046cbb8da57061f1e73c22b3e2b8853e1c74fdd205c9, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit e981af3 Oct 28, 2026
30 checks passed
@bartekus
bartekus deleted the impl/031-wasm-entry-points branch October 28, 2026 04:25
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

Successfully merging this pull request may close these issues.

1 participant