-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add check for node runtime and import from node buffer for Blob (#225)
* add check for node runtime and import from node buffer for Blob * move Blob import to global scope of package * migrate Blob injection to polyfil
- Loading branch information
Bean
authored
Oct 3, 2023
1 parent
6edb733
commit 7036eb7
Showing
3 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// This field will be automatically injected into the ./dist/packages/<package-name>/index.js file | ||
// between the autogen:polyfills:start/end comments | ||
|
||
try { | ||
if (isNode()) { | ||
try { | ||
//@ts-ignore | ||
let { Blob } = import('node:buffer').then((module) => { | ||
globalThis.Blob = module.Blob; | ||
}); | ||
} catch (e) { | ||
log( | ||
'Warn: could not resolve Blob from node api set, perhaps polyfil a Blob implementation of your choice' | ||
); | ||
} | ||
} | ||
} catch (e) { | ||
// swallow | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters