diff options
author | 2023-06-01 21:16:47 -0400 | |
---|---|---|
committer | 2023-06-01 18:16:47 -0700 | |
commit | 4df1d37ddc54242c339765f22fb90ba2e9e3a99a (patch) | |
tree | d63ede76463e7ecba78a4d4b31e5e8158193552f /src/js/shared.ts | |
parent | 03ffd1c732aaaa30b5481f197221ce96da559e63 (diff) | |
download | bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.gz bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.zst bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.zip |
Bundle and minify `.exports.js` files. (#3036)
* move all exports.js into src/js
* finalize the sort of this
* and it works
* add test.ts to gitignore
* okay
* convert some to ts just to show
* finish up
* fixup makefile
* minify syntax in dev
* finish rebase
* dont minify all modules
* merge
* finish rebase merge
* flaky test that hangs
Diffstat (limited to 'src/js/shared.ts')
-rw-r--r-- | src/js/shared.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/js/shared.ts b/src/js/shared.ts new file mode 100644 index 000000000..1e3da7d51 --- /dev/null +++ b/src/js/shared.ts @@ -0,0 +1,30 @@ +export class NotImplementedError extends Error { + code: string; + constructor(feature: string, issue?: number) { + super( + feature + + " is not yet implemented in Bun." + + (issue ? " Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/" + issue : ""), + ); + this.name = "NotImplementedError"; + this.code = "ERR_NOT_IMPLEMENTED"; + + // in the definition so that it isn't bundled unless used + hideFromStack(NotImplementedError); + } +} + +export function throwNotImplemented(feature: string, issue?: number): never { + // in the definition so that it isn't bundled unless used + hideFromStack(throwNotImplemented); + + throw new NotImplementedError(feature, issue); +} + +export function hideFromStack(...fns) { + for (const fn of fns) { + Object.defineProperty(fn, "name", { + value: "::bunternal::", + }); + } +} |