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

The requested module does not provide an export when using barrel export with Prisma #12764

Closed
7 tasks done
ryanjchr opened this issue Apr 6, 2023 · 2 comments · Fixed by #12799
Closed
7 tasks done
Assignees
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@ryanjchr
Copy link

ryanjchr commented Apr 6, 2023

Describe the bug

What I am doing

Importing from a barrel export of @prisma/client causes a syntax error at runtime: "The requested module x does not provide an export y"

e.g.

// bug.ts
export * from '@prisma/client'
// App.tsx
import { UserRole } from './bug.ts' 
// Syntax error on runtime "The requested module bug.ts does not provide an export UserRole"

Notably, just importing directly from @prisma/client works perfectly fine.

// App.tsx
import { UserRole } from '@prisma/client' // Works fine

I have no reason to suspect this is a Prisma-specific issue as the same usage in create-react-app has no issues.

Reproduction

https:/ryanjchr/vite-prisma-incompatibility

Steps to reproduce

yarn install
yarn dev

System Info

System:
    OS: macOS 13.2
    CPU: (10) arm64 Apple M2 Pro
    Memory: 121.80 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.6.0 - ~/.nvm/versions/node/v19.6.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v19.6.0/bin/yarn
    npm: 9.4.0 - ~/.nvm/versions/node/v19.6.0/bin/npm
  Browsers:
    Brave Browser: 111.1.49.120
    Firefox: 111.0.1
    Firefox Developer Edition: 112.0
    Safari: 16.3
  npmPackages:
    @vitejs/plugin-react: ^3.0.0 => 3.1.0 
    vite: ^4.0.0 => 4.2.1

Used Package Manager

yarn

Logs

No response

Validations

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Apr 7, 2023
@bluwy
Copy link
Member

bluwy commented Apr 7, 2023

Looks like our interop code needs to handle star re-exports:

export function transformCjsImport(
importExp: string,
url: string,
rawUrl: string,
importIndex: number,
): string | undefined {

@sun0day
Copy link
Member

sun0day commented Apr 9, 2023

It seems impossible that re-export * from a cjs module cause we don't know what cjs module contains after esbuild prebundle. Maybe we should directly throw an error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants