-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from Govrn-HQ/fix/polyfill-buffer
polyfill buffer for WalletConnect on RainbowKit
- Loading branch information
Showing
5 changed files
with
710 additions
and
699 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
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
/** | ||
* Polyfill stable language features. These imports will be optimized by `@babel/preset-env`. | ||
* | ||
* See: https://github.com/zloirock/core-js#babel | ||
*/ | ||
import { Buffer } from 'buffer'; | ||
|
||
window.Buffer = window.Buffer ?? Buffer; | ||
window.process = window.process ?? { env: {} }; // Minimal process polyfill | ||
|
||
export {}; | ||
|
||
/* | ||
// If we see issues with 'regenerator-runtime', add back these imports | ||
import 'core-js/stable'; | ||
import 'regenerator-runtime/runtime'; | ||
*/ |
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 |
---|---|---|
@@ -1,47 +1,33 @@ | ||
import GlobalPolyFill from '@esbuild-plugins/node-globals-polyfill'; | ||
import { defineConfig } from 'vite'; | ||
import { resolve } from 'path'; | ||
import tsconfigPaths from 'vite-tsconfig-paths'; | ||
import { viteExternalsPlugin } from 'vite-plugin-externals'; | ||
|
||
const externalPlugin = viteExternalsPlugin({ | ||
...{ | ||
electron: 'electron', | ||
'electron-fetch': 'electron-fetch', | ||
}, | ||
}); | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
tsconfigPaths({ | ||
root: '../..', | ||
}), | ||
externalPlugin, | ||
], | ||
resolve: { | ||
alias: { | ||
stream: 'stream-browserify', | ||
url: 'url-browserify', | ||
http: 'http-browserify', | ||
https: 'http-browserify', | ||
process: 'process-es6', | ||
'~~': resolve(__dirname, 'src'), | ||
}, | ||
}, | ||
build: { | ||
target: 'esnext', | ||
commonjsOptions: { | ||
transformMixedEsModules: true, | ||
}, | ||
}, | ||
optimizeDeps: { | ||
esbuildOptions: { | ||
// Node.js global to browser globalThis | ||
define: { | ||
global: 'globalThis', | ||
// my fix | ||
'globalThis.process.env.NODE_ENV': 'development', | ||
}, | ||
plugins: [ | ||
GlobalPolyFill({ | ||
process: true, | ||
buffer: true, | ||
}), | ||
], | ||
}, | ||
}, | ||
resolve: { | ||
alias: { | ||
process: 'process/browser', | ||
stream: 'stream-browserify', | ||
zlib: 'browserify-zlib', | ||
util: 'util', | ||
}, | ||
}, | ||
}); |
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
Oops, something went wrong.