feat(codec): Node-runnable published artifact (dual-target exports)#38
Merged
Conversation
- Move @void-layer/types to devDependencies (import type only, zero runtime presence) - Add src/index.node.ts: ESM wrapper using createRequire to load pkg-node CJS glue + brotli-wasm index.node.js (require condition, fs-based, no fetch) - Wire `node` export condition → dist/index.node.js in package.json#exports - Add pkg-node/ to package.json#files - Update build script to run wasm-pack --target nodejs + rm pkg-node/.gitignore - Add test:pack script (scripts/test-pack.mjs): pnpm-pack → tmp-install → Node ESM import - Exclude src/index.node.ts from vitest coverage (exercised by test:pack, not vitest) Bundler path (pkg/ via `import` condition) retained alongside node path. WASM gzip: 79,264 bytes (cap 81,920; headroom ~2.7 KB). Smoke test: pnpm test:pack
….mjs P2 — de-duplication: - Extract src/wire.ts: single source for COMPRESSED_FLAG, MAX_DECOMPRESSED_BYTES, decompressBounded (DoS guard from d83cef9), encodeWire, decodeWire - Both index.ts (bundler) and index.node.ts (Node) import from wire.ts; the only per-entry difference is the brotli-wasm loader (ESM import() vs require) - Remove no-explicit-any eslint-disable directives (as{} cast satisfies the rule) P1 — ESLint: - scripts/test-pack.mjs: remove unused rmSync import, use bare catch{} for intentional empty cleanup handlers, fix unused err catch param - eslint.config.mjs: add scripts/**/*.mjs override declaring Node globals (console/process/URL) so no-undef does not fire on tooling scripts
…ion:bundler index.node.ts uses createRequire from 'module' and import.meta.url — both require @types/node to resolve under moduleResolution:"bundler". TS6 enforces this more strictly. @types/node is already in devDependencies.
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
Part of #17
Wires the Node-runnable published artifact for
@void-layer/codec:exports["."]["node"]→dist/index.node.js;exports["."]["import"]→dist/index.js(bundler). Consumers get the right entry automatically via export conditions.wire.tssingle source: encode/decode wire logic extracted intowire.ts, shared by bothindex.ts(bundler) andindex.node.ts(Node ESM). No duplication.pkg-node/in published files:wasm-pack --target nodejsoutput included in the tarball so Node consumers get fs-based WASM loading without fetch.buildruns both targets:wasm-pack bundler + wasm-pack nodejs + tscin onepnpm build.test:packsmoke: pack → install → Node ESM import → canonical + wire round-trip, all green.@void-layer/typesmoved to devDependencies: codec must not ship types as a runtime dep; types is a peer/dev concern only.TS6 / vitest4 toolchain fix
tsconfig.jsongains"types": ["node"]. UndermoduleResolution: "bundler"(correct for bundler consumers), TS6 does not auto-include Node built-in types.index.node.tsusescreateRequirefrom'module'andimport.meta.url— both require@types/nodeto resolve.@types/nodewas already in devDependencies; this just activates it for tsc.Validation (TS 6.0.3 / vitest 4.1.8 / @vitest/coverage-v8 4.1.8)
pnpm build(bundler + nodejs wasm-pack + tsc)pnpm test(vitest run)pnpm test:pack(Node ESM smoke)pnpm lint(clippy + rustfmt + eslint)Coverage parse warnings for
.rsfiles are non-fatal (coverage-v8 excludes them gracefully) — pre-existing behavior unchanged from vitest3.