voxpelli / pony-cause

Ponyfill and helpers for the standardized Error Causes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add an ESM variant + make tree shakeable

voxpelli opened this issue · comments

Benefits those with client side js who only use some of the helpers or just the ponyfill.

Will probably be implemented like in async-htm-to-string, using the very same linemod tool.

Done as of 6174b7b / v2.0.0

When compiling the following:

import { ErrorWithCause } from 'pony-cause';

console.log(new ErrorWithCause('Foobar'));

With npx esbuild foo.mjs --bundle --minify it becomes:

(()=>{var t=class extends Error{constructor(s,{cause:e}={}){super(s),this.name=t.name,e&&(this.cause=e),this.message=s}};console.log(new t("Foobar"));})();