ory / ory/elements

@ory/elements-react’s ESM build imports an internal file without an extension

Open
#573 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
187
Forks
80
PR merge metrics
No merged PRs in 30d

Description

Preflight checklist
Ory Network Project

No response

Describe the bug
## Error Type
Runtime Error

## Error Message
Failed to load external module @ory/elements-react/theme: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/meotimdihia/Sources/myproject/node_modules/@ory/elements-react/dist/client/session-provider' imported from /Users/meotimdihia/Sources/myproject/node_modules/@ory/elements-react/dist/client/index.mjs


    at async (.next/server/chunks/ssr/[root-of-the-server]__52545ad9._.js:7:13)

Next.js version: 15.5.4 (Turbopack)

e.g. the code:

import { frontendClient } from "./frontendClient";

doesn't work, it need to change to

import { frontendClient } from "./frontendClient.mjs";
Reproducing the bug

npm run dev in next.js project.

in package.json the project is using ESM "type": "module"

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["DOM.Iterable", "ESNext", "DOM", "WebWorker"],
    "sourceMap": true,
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "baseUrl": "./",
    "paths": {
      "@/*": ["./*"]
    },
    "plugins": [
      {
        "name": "next"
      }
    ]
  },
  "include": [
    "types.d.ts",
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts",
    "**/*.d.ts"
  ],
  "exclude": ["node_modules", ".next/types/validator.ts"]
}

Relevant log output

Relevant configuration

Version
"@ory/elements-react": "^1.0.0",     "@ory/nextjs": "^1.0.0-rc.0",
On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker Compose

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated dist/client/index.mjs and its import of session-provider, then trace the corresponding source import such as ./frontendClient. Reproduce with npm run dev in an ESM Next.js project; done means @ory/elements-react loads without ERR_MODULE_NOT_FOUND.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, react, typescript
Domain
build-system, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.