Jest 28.0.0 and jest-environment-jsdom fails to import use-debounce in tests
Glup3 opened this issue · comments
Describe the bug
Importing the package does not work since the Jest 28.0.0 update in combination with jest-environment-jsdom
.
To Reproduce
- update jest to 28.0.0
- use jest-environment-jsdom (28.0.0)
- create a test that uses use-debounce
- run the test
Expected behavior
The test should run successfully.
use-debounce version: 8.0.0
Additional Information
This problem is also in other packages (described in their docs) https://jestjs.io/docs/upgrading-to-jest28#packagejson-exports
Here is the analysis of the problem and their workaround, which works:
microsoft/accessibility-insights-web#5421 (comment)
microsoft/accessibility-insights-web@9ad4e61
this is breaking our server side rendering with webpack as well
removing
"exports": {
".": {
"browser": "./dist/index.module.js",
"umd": "./dist/index.umd.js",
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.module.js"
}
},
from package.json solved the problem
patch-package for now
diff --git a/package.json b/package.json
index 43ccad5..1cb6bf2 100644
--- a/node_modules/use-debounce/package.json
+++ b/node_modules/use-debounce/package.json
@@ -7,15 +7,6 @@
"module": "dist/index.module.js",
"esmodule": "dist/index.modern.js",
"umd:main": "dist/index.umd.js",
- "exports": {
- ".": {
- "browser": "./dist/index.module.js",
- "umd": "./dist/index.umd.js",
- "import": "./dist/index.mjs",
- "require": "./dist/index.js",
- "default": "./dist/index.module.js"
- }
- },
"sideEffects": false,
"scripts": {
"size": "yarn build-only && size-limit",
Sorry, for the long response, and huge thanks to both of you!
I updated the exports section dd377cb and tested on the local project with jest@28
and jest-environment-jsdom
, so the new version should work properly.
I've published use-debounce@8.0.1
, you can update to this version.
Let me know if everything is okay for you
it is working well for me, tks
Great, thanks for the info