react-focus-lock: ESM compatibility breaks WebPack build
https://github.com/theKashey/react-focus-lock/releases/tag/v2.12.0
Unfortunately the ESM compatibility update broke our WebPack build … I am investigating, but we have a pretty standard setup.
ERROR in ./node_modules/react-focus-lock/dist/es2015/index.js 1:0-38
Module not found: Error: Can't resolve './Combination' in '/PATH_TO_PROJECT/node_modules/react-focus-lock/dist/es2015'
Did you mean 'Combination.js'?
BREAKING CHANGE: The request './Combination' 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.
resolve './Combination' in '/PATH_TO_PROJECT/node_modules/react-focus-lock/dist/es2015'
using description file: /PATH_TO_PROJECT/node_modules/react-focus-lock/package.json (relative path: ./dist/es2015)
Field 'browser' doesn't contain a valid alias configuration
using description file: /PATH_TO_PROJECT/node_modules/react-focus-lock/package.json (relative path: ./dist/es2015/Combination)
Field 'browser' doesn't contain a valid alias configuration
/PATH_TO_PROJECT/node_modules/react-focus-lock/dist/es2015/Combination doesn't exist
ERROR in ./node_modules/react-focus-lock/dist/es2015/index.js 2:0-21
Module not found: Error: Can't resolve './UI' in '/PATH_TO_PROJECT/node_modules/react-focus-lock/dist/es2015'
Did you mean 'UI.js'?
BREAKING CHANGE: The request './UI' 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.
resolve './UI' in '/PATH_TO_PROJECT/node_modules/react-focus-lock/dist/es2015'
using description file: /PATH_TO_PROJECT/node_modules/react-focus-lock/package.json (relative path: ./dist/es2015)
Field 'browser' doesn't contain a valid alias configuration
using description file: /PATH_TO_PROJECT/node_modules/react-focus-lock/package.json (relative path: ./dist/es2015/UI)
Field 'browser' doesn't contain a valid alias configuration
/PATH_TO_PROJECT/node_modules/react-focus-lock/dist/es2015/UI doesn't exist
About this issue
- Original URL
- State: open
- Created 2 months ago
- Reactions: 13
- Comments: 16 (3 by maintainers)
Commits related to this issue
- fix: correct ESM implemenation, fixes #301 — committed to theKashey/react-focus-lock by theKashey 2 months ago
- fix error originating from react-focus-lock within chakra due to package breaking ESM breaking WebPack build https://github.com/theKashey/react-focus-lock/issues/301 — committed to henrybabbage/pukauae by henrybabbage 2 months ago
I’m facing the same issue
@Harsh7wardhan in your
package.json, add the following:Looks like same problem here. I have
NextJSproject, which usesesbuild, and once I ran updates today, trying to start project gives following error:Looks like that it is
@chakra-ui/react@2.8.2that brings react-focus-lock to my project. After I downgrade toreact-focus-lock@2.11.0project seems to be working once again.i’m also facing the same issue, though im using
@chakra-ui/react@2.5.5which usesreact-focus-lock@2.9.4, the issue still persists.UPDATE: Works with overriding react-focus-lock version in package.json
Wondering if just removing
type: "module"from package.json would solve the problem.Anyway 2.12.1 has been published.
Working on a resolution:
2.11.3as2.12.1Due to semantic versioning, I think you might have to publish a new version that hot-fixes or reverts the breaking changes introduced in
2.12.In my
package.jsonI locked the version:instead of:
Version 2.12.0 has been deprecated, please use 2.11.3
@likegs9 The bug seems to be fixed. After installing the new verison, there’s no error.
Getting same error. The package is broken and unusable. Author doesn’t know how to properly publish npm packages.
Workaround:
yarn add react-focus-lock@2.11.3.Do not update the package version, or your app will break.
I am not using react-focus-lock directly in my project but its getting installed as a dependency for chakra-ui version 2.8.2 , how can i fix the above issue the issue in this case ?
“node_modules/@chakra-ui/focus-lock”: { “version”: “2.1.0”, “license”: “MIT”, “dependencies”: { “@chakra-ui/dom-utils”: “2.1.0”, “react-focus-lock”: “^2.9.4” }, “peerDependencies”: { “react”: “>=18” } },