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

🐞 Module Parse Failed with babel-loader #380

Open
1 task done
prelator opened this issue Dec 21, 2023 · 1 comment
Open
1 task done

🐞 Module Parse Failed with babel-loader #380

prelator opened this issue Dec 21, 2023 · 1 comment
Assignees
Labels
bug A verified and reproducible bug. triage Has not been reviewed yet and should not be worked on.

Comments

@prelator
Copy link

prelator commented Dec 21, 2023

What happened?

It appears the current version of this library is incompatible with babel-loader. Importing it into a React app causes the app to fail to compile with the following error:

./node_modules/react-idle-timer/dist/index.esm.js 239:8
Module parse failed: Unexpected token (239:8)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| var Q = {},
|   Ae = class {
>     name;
|     closed = !1;
|     mc = new MessageChannel();

Reproduction Steps

1. Added package via `yarn add react-idle-timer`.
2. Imported into React app with `import { useIdleTimer } from 'react-idle-timer';`
3. Try to compile the app.
...

Relevant log output

[1] Failed to compile.
[1] 
[1] ./node_modules/react-idle-timer/dist/index.esm.js 239:8
[1] Module parse failed: Unexpected token (239:8)
[1] File was processed with these loaders:
[1]  * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
[1] You may need an additional loader to handle the result of these loaders.
[1] | var Q = {},
[1] |   Ae = class {
[1] >     name;
[1] |     closed = !1;
[1] |     mc = new MessageChannel();

Screenshots or Additional Context

Babel versions from the main package.json file:
"@babel/cli": "^7.23.0", "@babel/core": "^7.23.2", "@babel/preset-env": "^7.23.2",

In the react app's yarn.lock file, babel-loader (required by [email protected]) is:

[email protected]: version "8.1.0" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.1.0.tgz#c611d5112bd5209abe8b9fa84c3e4da25275f1c3" integrity sha512-7q7nC1tYOrqvUrN3LQK4GwSk/TQorZSOlO9C+RZDZpODgyN4ZlCqE5q9cDsyWOliN+aU9B4JX01xK9eJXowJLw== dependencies: find-cache-dir "^2.1.0" loader-utils "^1.4.0" mkdirp "^0.5.3" pify "^4.0.1" schema-utils "^2.6.5"

Module Version

5.7.2

What browsers are you seeing the problem on? Select all that apply.

Chrome

What devices are you seeing the problem on?

Desktop

Verification

  • I have checked for existing closed issues and discussions.
@prelator prelator added bug A verified and reproducible bug. triage Has not been reviewed yet and should not be worked on. labels Dec 21, 2023
@prelator
Copy link
Author

Update: If I use version 5.6.2 I don't see this problem and the plugin works fine. My theory is that this bug was caused by the legacy bundle exports which were added to the package.json file in v 5.7.0. Babel-loader seems not to be able to handle that, or at least the version I'm using can't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A verified and reproducible bug. triage Has not been reviewed yet and should not be worked on.
Projects
None yet
Development

No branches or pull requests

2 participants