Skip to content

Commit

Permalink
Merge pull request #82 from sei-protocol/hotfix/polyfills
Browse files Browse the repository at this point in the history
Node polyfill hotfix
  • Loading branch information
codebycarson authored Sep 18, 2023
2 parents 020bcda + 96138f7 commit 1b90eb1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .changeset/blue-jeans-lick.md
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 11 additions & 8 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
10 changes: 0 additions & 10 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 1b90eb1

Please sign in to comment.