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

How to add polyfill using CRA5 with CRACO? #467

Closed
kintz09 opened this issue Nov 8, 2022 · 2 comments
Closed

How to add polyfill using CRA5 with CRACO? #467

kintz09 opened this issue Nov 8, 2022 · 2 comments

Comments

@kintz09
Copy link
Contributor

kintz09 commented Nov 8, 2022

I was so excited to see a release candidate of CRACO with support for Create React App 5 and Webpack 5 has been released. Thank you so much to everyone who supported this important effort!

Now that it's released, could anyone provide some guidance on the proper way to add in the polyfills that were removed in Webpack?

module.exports={
  webpack: {
    configure: {},
  },
};

There's two polyfills I'm trying to add:

  • crypto (crypto-browserify)
  • stream (stream-browserify)
@kintz09
Copy link
Contributor Author

kintz09 commented Nov 8, 2022

Ah, just came across a comment that gave me a great hint! For anyone else looking for a quick fix for the CRA5 polyfill issue, check out the CRACO config file below:

module.exports={
  webpack: {
    configure: {
      resolve: {
        fallback: {
          // Webpack 5, used in react-script v5, dropped support for built in node polyfills.
          // CRACO is being used to add these polyfills back into the webpack config until they are not needed.
          crypto: require.resolve("crypto-browserify"),
          stream: require.resolve("stream-browserify"),
        }
      }
    },
  },
};

If this is wrong, please let me know.

@dilanx
Copy link
Owner

dilanx commented Nov 10, 2022

Looks like this is resolved so I'll close this issue.

@dilanx dilanx closed this as completed Nov 10, 2022
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

No branches or pull requests

2 participants