elements icon indicating copy to clipboard operation
elements copied to clipboard

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

Open meotimdihia opened this issue 5 months ago • 1 comments

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

meotimdihia avatar Sep 26 '25 10:09 meotimdihia