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

v3.0.1 compatibility with React 17.0.2 (Reproducible) #135

Closed
SalahHamza opened this issue Mar 24, 2024 · 5 comments
Closed

v3.0.1 compatibility with React 17.0.2 (Reproducible) #135

SalahHamza opened this issue Mar 24, 2024 · 5 comments
Labels
bug Something isn't working has workaround Issue has a viable workaround

Comments

@SalahHamza
Copy link

SalahHamza commented Mar 24, 2024

Hey! Seems like the react-compare-slider isn't compatible with react 17.0.2.

Error:

Module not found: Error: Can't resolve 'react/jsx-runtime' in '.../react-compare-slider/dist'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

Here's the code to the issue:
https://github.com/SalahHamza/react-compare-slider-repro

@nerdyman
Copy link
Owner

Thanks for opening this @SalahHamza! I'll take a look

@nerdyman nerdyman added the bug Something isn't working label Mar 25, 2024
@nerdyman
Copy link
Owner

@SalahHamza Can you provide your node.js and OS version too? I haven't tried it locally yet but it works as expected on CodeSandbox https://codesandbox.io/p/sandbox/github/SalahHamza/react-compare-slider-repro/tree/main/

@SalahHamza
Copy link
Author

@nerdyman thanks for the quick reply. Here you go:

  • OS: macOS Sonoma 14.0
  • Node Version: v18.17.1 (using nvm)
  • npm Version: 9.6.7

Additional note: I think the main cause of the issue is this:

"moduleResolution": "Bundler",

@SalahHamza
Copy link
Author

I haven't tried it locally yet but it works as expected on CodeSandbox https://codesandbox.io/p/sandbox/github/SalahHamza/react-compare-slider-repro/tree/main/

@nerdyman I think the main reason why this is working, is because in the Sandbox it uses Vite, while the repro uses CRA.

@nerdyman
Copy link
Owner

nerdyman commented Apr 16, 2024

@SalahHamza Thanks for raising this issue. It looks like the error is due to the JSX config used by this lib but I can't change it now as it might break other things. You can use a tool such as CRACO as a workaround.

You'll need to do the following to get it working:

Install craco:

yarn add --dev @craco/craco

Create craco.config.js in the root of your repo:

// craco.config.js in the same directory as your package.json
module.exports = {
  webpack: {
    alias: {
      'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
      'react/jsx-runtime': 'react/jsx-runtime.js',
    },
  }
}

Change the react-scripts references in your package.json to use craco:

- "start": "react-scripts start",
- "build": "react-scripts build",
- "test": "react-scripts test",
+ "start": "craco start",
+ "build": "craco build",
+ "test": "craco test",

The error looks to be isolated to ES modules and Webpack 5, you can check out facebook/react#20235 for more info.

@nerdyman nerdyman added the has workaround Issue has a viable workaround label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has workaround Issue has a viable workaround
Projects
None yet
Development

No branches or pull requests

2 participants