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

Crash when importing files from the export "./dist/esm/*.js" #1194

Open
GorenDaniel opened this issue Jan 31, 2024 · 0 comments
Open

Crash when importing files from the export "./dist/esm/*.js" #1194

GorenDaniel opened this issue Jan 31, 2024 · 0 comments
Labels
bug Something isn't working needs assessment This needs to be looked at by a team member

Comments

@GorenDaniel
Copy link

Reproduction example

.

Prerequisites

  1. Use the latest version of 14.5.2 of user-event in an esm node module project
  2. try to import an esm file into your project - import { FOCUSABLE_SELECTOR } from '@testing-library/user-event/dist/esm/utils/index.js'
  3. 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"
    }
@GorenDaniel GorenDaniel added bug Something isn't working needs assessment This needs to be looked at by a team member labels Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs assessment This needs to be looked at by a team member
Projects
None yet
Development

No branches or pull requests

1 participant