Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Webpack v5/Create-React-App v5 compatibility #190

Open
zavan opened this issue Feb 14, 2022 · 5 comments
Open

Webpack v5/Create-React-App v5 compatibility #190

zavan opened this issue Feb 14, 2022 · 5 comments

Comments

@zavan
Copy link

zavan commented Feb 14, 2022

Trying to import this on a webpack v5 project is giving me the following error:

ERROR in ./node_modules/client-oauth2/src/client-oauth2.js 3:18-40

Module not found: Error: Can't resolve 'querystring' in '/myproject/node_modules/client-oauth2/src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
	- install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "querystring": false }
@uip-robot-zz
Copy link

Git2Gus App is installed but the .git2gus/config.json doesn't exist.

@zavan
Copy link
Author

zavan commented Feb 14, 2022

Installing querystring-es3 (npm i querystring-es3) and adding this to my webpack config fixes it:

      resolve: {
        fallback: {
          // SEE: https://github.com/mulesoft-labs/js-client-oauth2/issues/190
          querystring: require.resolve('querystring-es3'),
        }
      }

@cedriclevarlet
Copy link

Installing querystring-es3 (npm i querystring-es3) and adding this to my webpack config fixes it:

      resolve: {
        fallback: {
          // SEE: https://github.com/mulesoft-labs/js-client-oauth2/issues/190
          querystring: require.resolve('querystring-es3'),
        }
      }

The webpack config is not accessible unless you eject. This unfortunately makes this solution only use-able for certain setups.

@dpankros
Copy link

dpankros commented Jun 9, 2022

@cedriclevarlet You can try @craco/craco version 7.0.0-alpha.3 to access webpack without ejecting CRA

@didair
Copy link

didair commented Sep 12, 2023

For anyone using Vite:

resolve: {
  alias: {
    // SEE: https://github.com/mulesoft-labs/js-client-oauth2/issues/190
    querystring: resolve(__dirname, 'node_modules/querystring-es3'),
  },
},

Add the querystring fallback/alias in the resolve.alias option in your vite.config.ts file

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

No branches or pull requests

5 participants