Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfill Node APIs for compatibility with Webpack 5 and Create React App 5 #264

Merged
merged 3 commits into from
Jan 20, 2022
Merged

Polyfill Node APIs for compatibility with Webpack 5 and Create React App 5 #264

merged 3 commits into from
Jan 20, 2022

Conversation

steveluscher
Copy link
Collaborator

@steveluscher steveluscher commented Jan 16, 2022

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 and stream, 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.

If 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.

@steveluscher steveluscher changed the title Polyfill Node apis for compatibility with Webpack 5 and Create React App 5 Polyfill Node APIs for compatibility with Webpack 5 and Create React App 5 Jan 16, 2022
@jordaaash
Copy link
Collaborator

I like this. This looks like a pretty clean solution to an annoying problem, and we can gradually phase it out as a nonbreaking change when the dependencies change. I haven't tested this yet, but does it fix our CRA problem?

@steveluscher
Copy link
Collaborator Author

I was able to boot the old CRA-based starter with this PR and CRA5. Still would love a second person to verify that though!

@jordaaash jordaaash merged commit b830c20 into anza-xyz:master Jan 20, 2022
@jordaaash
Copy link
Collaborator

Heroic work, thanks for this.

@steveluscher steveluscher deleted the polyfill-node-apis-for-webpack-5 branch January 20, 2022 03:25
@steveluscher
Copy link
Collaborator Author

🤞🏻

@jordaaash
Copy link
Collaborator

Published:

  • @solana/wallet-adapter-ledger => 0.9.3
  • @solana/wallet-adapter-torus => 0.11.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create React App is broken by lack of default polyfills in Webpack 5
2 participants