No dummy payloads
{ type: 'ping' } is a valid signal. Missing fields remain undefined; applications choose whether they are required.
Why js-message
Use one small boundary primitive when your application needs a predictable convention—not another transport framework, schema engine, or dependency tree.
js-message works with bundlers and without a bundler. Bundlers resolve bare imports normally; native browser ESM uses a standard import map with no build or transpilation step.
The practical case
A message can be complete, partial, incoming as JSON, or already an object. js-message copies the fields that exist and stays out of the payload.
{ type: 'ping' } is a valid signal. Missing fields remain undefined; applications choose whether they are required.
Node 22.13+ loads the same synchronous Message.js constructor through ESM and CommonJS. There is no duplicate build to drift.
A failed parse becomes a normal type: 'error' message with the original response and useful error details.
No transpiler, generated runtime, framework binding, install hook, timer, listener, or hidden network request.
Use it when
Choose something else when
Review the measured path, then run the real module before choosing it.