Polyfill Node APIs for compatibility with Webpack 5 and Create React App 5 #264
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new version of Webpack – and by extension the new version of Create React App – no longer includes polyfills for Node APIs by default. This means that if your browser-based app requires modules like
assert
andstream
, Webpack will fail to find them and fail to build.In this PR, we alias the modules that the wallet adapter depends upon to their related browser polyfills.
I've also followed up with each repository to let them know that they might like to eliminate or polyfill these modules in their own browser builds.
assert
in favor of simply throwingErrors
to ensure compatibility with Webpack 5 ethereumjs/ethereumjs-monorepo#1638stream
API to ensure compatibility with Webpack 5 browserify/cipher-base#16If you're having trouble using the Solana wallet adapter with Create React App 5, can you patch this PR in and report back? I might have missed some polyfills.
Fixes #241.