Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Oct 21, 2025

Description

This PR disables minification in tsup config (this is the only SDK that is minified somehow) to ensure readable exports for libraries like tsx, and also removed the legacyOutput option.

Fixes #6977

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Chores
    • Updated package export metadata to improve compatibility with modern import styles and both ESM/CJS consumers.
    • Adjusted TypeScript and bundler settings to standardize type declaration output and produce both CJS and ESM builds.
    • Simplified build behavior (watch/dev flags, minification) and enabled sourcemaps for clearer debugging and maintainability.

@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: 8fbe205

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/fastify Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Skipped Skipped Oct 21, 2025 6:50pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

Package build and exports for @clerk/fastify were flattened: ESM/CJS output and type locations moved from dist/esm and dist/types into dist/*.(mjs|d.mts|d.ts). tsconfig declarationDir was removed and tsup build config switched to bundled cjs/esm outputs, DTS generation, sourcemaps, and disabled minification.

Changes

Cohort / File(s) Change Summary
Package exports & metadata
packages/fastify/package.json
Updated exports for . and ./webhooks: import paths now point to ./dist/*.mjs and ./dist/*.d.mts; require paths use ./dist/*.js and ./dist/*.d.ts. Updated top-level module to ./dist/index.mjs and types to ./dist/index.d.ts. Removed --ignore-rules unexpected-module-syntax from lint script.
TypeScript config
packages/fastify/tsconfig.json
Removed emitDeclarationOnly: true and declarationDir: "dist/types"; declaration: true and outDir: "dist" remain. JSON module resolution unchanged.
Bundler (tsup) config
packages/fastify/tsup.config.ts
Switched dev flag: __DEV__ now reflects isWatch. Explicit entry files ./src/index.ts and ./src/webhooks.ts. Enabled bundle, outputs ['cjs','esm'], enabled dts: true, enabled sourcemap, clean: true, removed legacyOutput and onSuccess, and set minify: false.
Changeset
.changeset/famous-paws-reply.md
Added changeset marking @clerk/fastify as minor and noting minification disabled to preserve static import compatibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through folders, loose and spry,
Flattened paths beneath the sky,
No minified exports to confound,
Types and builds now homeward bound,
A tidy bundle — hop, hop, hi!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix(fastify): Disable minification for static import compatibility" clearly and concisely summarizes the primary change in the changeset. The title directly reflects the core modification: disabling minification in the build configuration to resolve the static import analysis issue with tsx. It is specific enough to convey the main purpose without being verbose, and it aligns with the actual changes made to the tsup configuration file.
Linked Issues Check ✅ Passed The pull request directly addresses the requirements from issue #6977 by disabling minification in the tsup configuration, which resolves the root cause preventing tsx from correctly analyzing static imports. The code changes set minify: false unconditionally in tsup.config.ts and reorganize the build output paths in package.json and tsconfig.json to align with the non-minified output structure. The removal of legacyOutput and simplification of the declaration configuration further support the stated goal of ensuring readable ESM exports that tsx can statically analyze, matching the expected behavior described in the linked issue.
Out of Scope Changes Check ✅ Passed All changes in the pull request appear to be within scope and directly support the objective of disabling minification for static import compatibility. The tsup.config.ts changes disable minification and reorganize build output formats and entry paths; the package.json updates redirect exports to the non-minified output locations; the tsconfig.json simplifications align with the new build structure; and the removal of legacyOutput is explicitly mentioned in the PR objectives. These modifications work together as a cohesive refactoring of the build system to ensure tsx can resolve named exports from the non-minified ESM bundle.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/fastify-unminify

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 911ccbb and 21e05a2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/fastify/package.json (2 hunks)
  • packages/fastify/tsconfig.json (1 hunks)
  • packages/fastify/tsup.config.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/fastify/tsup.config.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/fastify/tsup.config.ts
  • packages/fastify/tsconfig.json
  • packages/fastify/package.json
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/fastify/tsup.config.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/fastify/tsup.config.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/fastify/tsup.config.ts
packages/*/tsup.config.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

TypeScript compilation and bundling must use tsup.

Files:

  • packages/fastify/tsup.config.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/fastify/tsup.config.ts
packages/*/tsconfig.json

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Type checking must be performed with TypeScript and publint.

Files:

  • packages/fastify/tsconfig.json
packages/*/package.json

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

All publishable packages should be placed under the packages/ directory

packages/*/package.json: All publishable packages must be located in the 'packages/' directory.
All packages must be published under the @clerk namespace on npm.
Semantic versioning must be used across all packages.

Files:

  • packages/fastify/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
packages/fastify/tsconfig.json (1)

1-18: Configuration aligns with new flat output structure.

The removal of declarationDir is consistent with the updated export paths in package.json, where type declarations now reside directly in dist/ (e.g., ./dist/index.d.ts) instead of dist/types/.

packages/fastify/tsup.config.ts (3)

13-13: Correctly addresses the PR objective.

Setting minify: false ensures compatibility with static imports, as stated in the PR title. This is the core fix for the reported issue.


9-10: Output format and entry points align with package.json exports.

The explicit entry points and dual format (['cjs', 'esm']) correctly support the updated export structure in package.json, producing both .mjs (ESM) and .js (CJS) outputs.


6-6: Inconsistent DEV flag definition across monorepo requires verification.

The change to isWatch for the __DEV__ flag in packages/fastify is inconsistent with other packages in the monorepo. The DEV flag is actively used in runtime code (e.g., packages/shared/src/errors/clerkError.ts:69 for conditional documentation rendering), making this a behavioral change that affects multiple packages.

Issue: Different packages define __DEV__ differently:

  • Using isWatch: fastify, backend, remix, react, shared, react-router, expo, express, expo-passkeys, chrome-extension
  • Using !isProd: testing, elements, nextjs, tanstack-react-start, agent-toolkit

Since packages/shared (which uses isWatch) is a shared dependency imported by other packages, this inconsistency means packages may have divergent __DEV__ values. Regular dev builds (without watch) will now have __DEV__ = false, differing from the previous !isProd behavior.

Confirm this change is intentional and align the __DEV__ logic across all packages.

packages/fastify/package.json (2)

25-49: Export paths correctly follow Node.js dual-package conventions.

The updated export paths properly distinguish between ESM (.d.mts/.mjs) and CommonJS (.d.ts/.js) with correct type declaration extensions. The flat dist/ structure aligns with the updated build configuration.


61-61: Manual verification required: Confirm lint:attw passes with the new export configuration.

The sandbox environment cannot complete dependency installation due to a failing git-hosted package. Verify locally that pnpm lint:attw passes in packages/fastify/ with the --ignore-rules unexpected-module-syntax flag removed. This confirms the new build configuration correctly resolves previous module syntax issues.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 21, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7043

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7043

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7043

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7043

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7043

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7043

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7043

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7043

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7043

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7043

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7043

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7043

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7043

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7043

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7043

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7043

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7043

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7043

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7043

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7043

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7043

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7043

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7043

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7043

commit: 8fbe205

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted the exports since we removed the legacyOutput in tsup config. It should not be breaking since it only affects the internal build process, not the final output structure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using the dts option in tsup config now

@wobsoriano wobsoriano merged commit 3f72fa0 into main Oct 23, 2025
51 checks passed
@wobsoriano wobsoriano deleted the rob/fastify-unminify branch October 23, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@clerk/fastify] Static imports fail with tsx

4 participants