Skip to content

Commit

Permalink
feat(client): improve compatibility with Bun (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and RobertCraigie committed Aug 23, 2023
1 parent 79303f9 commit fe4f5d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/_shims/formdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
*/

exports.FormData = FormData;
exports.File = File;
exports.Blob = Blob;
exports.File =
typeof File !== 'undefined' ? File : (
// Bun doesn't implement File yet, so just make a shim that throws a helpful error message
class File extends Blob {
constructor() {
throw new Error(`file uploads aren't supported in this environment yet as 'File' is not defined`);
}
}
);

exports.isPolyfilled = false;
11 changes: 10 additions & 1 deletion src/_shims/formdata.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
*/

const _FormData = FormData;
const _File = File;
const _Blob = Blob;

const _File =
typeof File !== 'undefined' ? File : (
// Bun doesn't implement File yet, so just make a shim that throws a helpful error message
class File extends Blob {
constructor() {
throw new Error(`file uploads aren't supported in this environment yet as 'File' is not defined`);
}
}
);

export { _FormData as FormData, _File as File, _Blob as Blob };

export const isPolyfilled = false;

0 comments on commit fe4f5d5

Please sign in to comment.