js-message works with bundlers and without a bundler.
Bundlers resolve the bare js-message import normally. Native browser ESM resolves it through a standard import map, with no build or transpilation step.
Complete source
import Message from 'js-message';
const message = new Message({
type: 'job.ready',
data: { id: 'job_8' }
});
message.transport = 'local only';
console.log('instance', message);
console.log('wire', message.JSON);What to inspect
- The live instance includes
transport. - The wire JSON contains only
typeanddata. toJSON()enforces the same boundary for native serialization.