user-event
user-event copied to clipboard
Crash when importing files from the export "./dist/esm/*.js"
Reproduction example
.
Prerequisites
- Use the latest version of 14.5.2 of user-event in an esm node module project
- try to import an esm file into your project -
import { FOCUSABLE_SELECTOR } from '@testing-library/user-event/dist/esm/utils/index.js' - Get the following error on build:
Module not found: Error: Default condition should be last one
Expected behavior
The code should be imported successfully
Actual behavior
Get the following error on build: Module not found: Error: Default condition should be last one
User-event version
14.5.2
Environment
Testing Library framework: "@testing-library/jest-dom": "^6.4.0", "@testing-library/react": "^14.2.0", "@testing-library/user-event": "^14.5.2",
JS framework: node v18.17.1 "module": "es6"
Test environment: "vitest": "^1.2.2"
DOM implementation: "jsdom": "^24.0.0"
Additional context
The error is originated in the package.json found in dist. It has this export:
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"default": "./dist/esm/index.js"
},
"./dist/cjs/*.js": {
"types": "./dist/types/*.d.ts",
"import": "./dist/esm/*.js",
"default": "./dist/cjs/*.js"
},
"./dist/esm/*.js": {
"types": "./dist/types/*.d.ts",
"default": "./dist/esm/*.js",
"require": "./dist/cjs/*.js"
}
},
and can be fixed by switching the order of the export:
"./dist/esm/*.js": {
"types": "./dist/types/*.d.ts",
"require": "./dist/cjs/*.js",
"default": "./dist/esm/*.js"
}