Skip to content

[@clerk/fastify] Static imports fail with tsx #6977

@markjanzer

Description

@markjanzer

Preliminary Checks

Reproduction

https://github.com/markjanzer/clerk-fastify-tsx-issue

Publishable key

pk_test_a25vd2luZy1sZW11ci0zMC5jbGVyay5hY2NvdW50cy5kZXYk

Description

@clerk/fastify cannot be imported using static imports when running TypeScript files with tsx.

Note: This issue appears to have been introduced in v2.0 - v1.0 worked fine with tsx.

Steps to reproduce:

  1. Clone repo: https://github.com/[your-username]/clerk-fastify-tsx-issue
  2. Run npm install && npm test

Expected behavior:

Static imports should work with tsx (like they do with Node.js and with @clerk/backend)

Actual behavior:

npx tsx test-file.ts
# Error: SyntaxError: The requested module '@clerk/fastify' does not provide an export named 'clerkPlugin'

Root cause:

The ESM bundle is minified (export{S as clerkPlugin}), which breaks tsx's static import analysis. @clerk/backend ships non-minified ESM and works fine.

Environment

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 298.63 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.18.0 - /opt/homebrew/opt/node@22/bin/node
    Yarn: 1.22.22 - /Users/markjanzer/.yarn/bin/yarn
    npm: 10.9.3 - /opt/homebrew/opt/node@22/bin/npm
    pnpm: 10.15.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 141.0.7390.76
    Safari: 17.6
  npmPackages:
    @clerk/backend: ^1.0.0 => 1.34.0 
    @clerk/fastify: ^2.0.0 => 2.4.37 
    @types/node: ^20.10.0 => 20.19.21 
    fastify: ^5.6.1 => 5.6.1 
    tsx: ^4.7.0 => 4.20.6 
    typescript: ^5.3.3 => 5.9.3

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions