fix(rvf-wasm): publish as ESM-only to resolve #415#431
Open
Conversation
The published 0.1.6 tarball was unloadable: pkg/rvf_wasm.js used `import.meta.url` and `export default` while package.json had no `"type": "module"`, so Node parsed it as CJS and threw `SyntaxError: Cannot use 'import.meta' outside a module` before any runtime guard could execute. The .mjs entry just re-imported the same broken .js, so the ESM path crashed identically. Fix: - Add `"type": "module"` and switch `main` to `pkg/rvf_wasm.mjs`. - Drop the `require`/`default` exports that pointed at the broken CJS-classified .js. Node 22.12+ supports `require(ESM)` natively, so the single ESM entry covers both consumers. - Add `tests/smoke.mjs` as a regression guard (also wired into `prepublishOnly`) that imports the package, calls `init()`, asserts real WASM memory, and confirms idempotency. - Bump 0.1.5 → 0.1.7 (skip the broken 0.1.6). Verified end-to-end against a packed tarball installed into /tmp: ESM import works (1.1 MB memory allocated), CJS require also works on Node 22.22.2. Closes #415 Co-Authored-By: claude-flow <ruv@ruv.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@ruvector/rvf-wasm@0.1.6was unloadable becausepkg/rvf_wasm.jsusedimport.meta.urlandexport defaultwhilepackage.jsonhad no"type": "module", so Node parsed it as CJS and threwSyntaxError: Cannot use 'import.meta' outside a modulebefore any runtime guard could execute.agentdb/@claude-flow/memory/ruflooperation that touches the RVF backend (memory init,hooks pretrain,status, …).Fix
"type": "module"and switchmain→pkg/rvf_wasm.mjs.require/defaultexports that pointed at the broken CJS-classified.js. Node 22.12+ supportsrequire(ESM)natively, so a single ESM entry covers both consumers.tests/smoke.mjsregression guard (also wired intoprepublishOnly) that imports the package, callsinit(), asserts real WASM memory, and confirms idempotency.Proof
End-to-end against a packed tarball installed into
/tmpon Node 22.22.2:Test plan
npm packsucceeds; tarball contents unchanged (6 files, 21 KB).await import('@ruvector/rvf-wasm')resolves anddefault()returns real WASM exports.require('@ruvector/rvf-wasm')works on Node 22.12+ (noSyntaxError).npm testpasses (tests/smoke.mjs).prepublishOnlyruns the smoke test before any future publish.ruflo memory initagainst a stack pinning@ruvector/rvf-wasm@0.1.7once published.Notes
@ruvector/rvf^0.1.5,@ruvector/rvlite>=0.1.0) are unchanged — both already useawait import('@ruvector/rvf-wasm'), which now works.sed-patching installedpackage.json) is no longer needed once 0.1.7 is published.npm publish.🤖 Generated with claude-flow