diff --git a/.changeset/blue-jeans-lick.md b/.changeset/blue-jeans-lick.md new file mode 100644 index 00000000..40993d39 --- /dev/null +++ b/.changeset/blue-jeans-lick.md @@ -0,0 +1,6 @@ +--- +'@sei-js/react': patch +'@sei-js/core': patch +--- + +Fixed an issue with polyfilling on Node environments be excluding environments that don't have self (non-browser environments) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index b303bc8e..16904cfb 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,11 +1,14 @@ -import * as process from 'process'; -import { Buffer } from 'buffer'; +// Check if in browser environment +if (typeof self !== 'undefined') { + const process = require('process'); + const Buffer = require('buffer').Buffer; -// Polyfill process and buffer for browser -Object.assign(self, { - process, - global: self, - Buffer -}); + // Polyfill process and buffer environment variables + Object.assign(self, { + process, + global: self, + Buffer + }); +} export * from './lib'; diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index b303bc8e..f41a696f 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -1,11 +1 @@ -import * as process from 'process'; -import { Buffer } from 'buffer'; - -// Polyfill process and buffer for browser -Object.assign(self, { - process, - global: self, - Buffer -}); - export * from './lib';