Skip to content

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

@meotimdihia

Description

@meotimdihia

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions