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 incoming = new Message('{not valid json');
console.log('type', incoming.type);
console.error('error', incoming.data.err);
console.log('envelope', incoming.toJSON());What to inspect
- The resulting type is
error. data.errremains anErrorin memory.- The JSON form retains its error name and message when the response is JSON-safe.