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

Change in the way React is imported by the UMD module in 11.17.3 #1527

Closed
glondu opened this issue Jun 30, 2022 · 6 comments
Closed

Change in the way React is imported by the UMD module in 11.17.3 #1527

glondu opened this issue Jun 30, 2022 · 6 comments

Comments

@glondu
Copy link

glondu commented Jun 30, 2022

💥 Regression Report

dist/umd/react-i18next.min.js expects React to be available as react whereas umd/react.production.js exports React.

Last working version

Worked up to version: 11.17.2

Stopped working in version: 11.17.3

To Reproduce

Steps to reproduce the behavior:

Create a file index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Bugreport</title>
  </head>
  <body>
    <script src="node_modules/react/umd/react.production.min.js"></script>
    <script src="node_modules/i18next/dist/umd/i18next.min.js"></script>
    <script src="node_modules/react-i18next/dist/umd/react-i18next.min.js"></script>
  </body>
</html>

Create a file package.json:

{
  "name": "bugreport-testcase",
  "version": "0.0.0",
  "description": "Bugreport test case",
  "author": "Stéphane Glondu",
  "license": "AGPL-3.0",
  "dependencies": {
    "i18next": "^19.7.0",
    "react": "^16.13.1",
    "react-i18next": "^11.7.3"
  }
}

Run:

npm install
python3 -m http.server

Browse to http://0.0.0.0:8000/, and open the JS console. There is an error Uncaught TypeError: n is undefined.

Expected behavior

No error.

Adding:

<script>var react = React;</script>

before loading react-i18next fixes the issue.

Your Environment

  • runtime version: Firefox 91.10.0esr
  • i18next version: 19.9.2
  • os: Linux
@adrai
Copy link
Member

adrai commented Jun 30, 2022

fyi: #1525 @jy95
info: rollup/rollup#3130

adrai added a commit that referenced this issue Jun 30, 2022
@adrai
Copy link
Member

adrai commented Jun 30, 2022

@glondu can you check if this works for you? => #1528

@glondu
Copy link
Author

glondu commented Jun 30, 2022

When I run npm install from a fresh git checkout of the fix-build branch, I get:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: react-test-renderer@17.0.2
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR!   dev react@"^16.10.2" from the root project
npm ERR!   peer react@"*" from @testing-library/react@11.2.7
npm ERR!   node_modules/@testing-library/react
npm ERR!     dev @testing-library/react@"^11.2.7" from the root project
npm ERR!   3 more (@testing-library/react-hooks, react-dom, react-shallow-renderer)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-test-renderer@17.0.2
npm ERR! node_modules/react-test-renderer
npm ERR!   dev react-test-renderer@"^17.0.1" from the root project
npm ERR!   peer react-test-renderer@">=16.9.0" from @testing-library/react-hooks@3.7.0
npm ERR!   node_modules/@testing-library/react-hooks
npm ERR!     dev @testing-library/react-hooks@"^3.4.2" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"17.0.2" from react-test-renderer@17.0.2
npm ERR!   node_modules/react-test-renderer
npm ERR!     dev react-test-renderer@"^17.0.1" from the root project
npm ERR!     peer react-test-renderer@">=16.9.0" from @testing-library/react-hooks@3.7.0
npm ERR!     node_modules/@testing-library/react-hooks
npm ERR!       dev @testing-library/react-hooks@"^3.4.2" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Am I missing something?

Anyway, if I use the react-i18next.min.js that is committed in the git, I do no longer get an error.

adrai added a commit that referenced this issue Jun 30, 2022
@adrai
Copy link
Member

adrai commented Jun 30, 2022

v11.17.4 has just been published

@adrai adrai closed this as completed Jun 30, 2022
@glondu
Copy link
Author

glondu commented Jul 1, 2022

Thank you for the prompt reaction!

@adrai
Copy link
Member

adrai commented Jul 1, 2022

If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project.

There are many ways to help this project 🙏

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