Skip to content

CJS external facade doesn't account for the default export being a function #20047

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

Open
7 tasks done
jamesopstad opened this issue May 15, 2025 · 0 comments · May be fixed by #20048
Open
7 tasks done

CJS external facade doesn't account for the default export being a function #20047

jamesopstad opened this issue May 15, 2025 · 0 comments · May be fixed by #20048

Comments

@jamesopstad
Copy link
Contributor

jamesopstad commented May 15, 2025

Describe the bug

Some modules, such as node:stream export a function as the default export. When imported in an optimized dependency with the CJS external facade, require_stream should return a function with the named exports as its enumerable properties. This is the source of the error reported here - cloudflare/workers-sdk#9225.

Reproduction

https://github.com/alexanderniebuhr/cf-vite-jsonwebtoken

Steps to reproduce

Run pnpm i followed by pnpm dev.

System Info

System:
    OS: macOS 15.4.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 470.09 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.5.1 - ~/.nvm/versions/node/v22.5.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.5.1/bin/yarn
    npm: 10.8.2 - ~/.nvm/versions/node/v22.5.1/bin/npm
    pnpm: 10.7.0 - ~/.nvm/versions/node/v22.5.1/bin/pnpm
  Browsers:
    Chrome: 136.0.7103.93
    Safari: 18.4

Used Package Manager

pnpm

Logs

TypeError: The "superCtor.prototype" property must be of type object. Received undefined

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant