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.
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"));})();
See live example of the above: https://bundlejs.com/?q=(import)pony-cause&treeshake=[{+ErrorWithCause+}]&text="console.log(new+ErrorWithCause('Foobar'));"