fix(nuxt): read correct env vars at build time for tests#7382
fix(nuxt): read correct env vars at build time for tests#7382wobsoriano wants to merge 3 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 7187e75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds environment variable fallback support for Clerk JS configuration in the Nuxt module. When Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
| // Unfortunately, Nuxt's runtime config nests these under `clerk`, so the env var | ||
| // for `clerkJSUrl` would need to be NUXT_PUBLIC_CLERK_CLERK_JS_URL (double CLERK). | ||
| // To avoid this awkward naming, we read NUXT_PUBLIC_CLERK_JS_* directly via process.env | ||
| // at build/dev time, which is consistent with other Clerk packages. | ||
| // For both build and runtime overrides in production, use NUXT_PUBLIC_CLERK_CLERK_JS_* instead. | ||
| clerkJSUrl: options.clerkJSUrl || process.env.NUXT_PUBLIC_CLERK_JS_URL, | ||
| clerkJSVariant: options.clerkJSVariant || process.env.NUXT_PUBLIC_CLERK_JS_VARIANT, | ||
| clerkJSVersion: options.clerkJSVersion || process.env.NUXT_PUBLIC_CLERK_JS_VERSION, |
There was a problem hiding this comment.
More info on nuxt runtime config https://nuxt.com/docs/4.x/guide/going-further/runtime-config#environment-variables
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/nuxt/src/module.ts (2)
67-74: Env var fallback looks correct; consider small clarity tweaksThe fallback logic (
options.* || process.env.NUXT_PUBLIC_CLERK_JS_*) aligns with the goal of honoringNUXT_PUBLIC_CLERK_JS_*at build/dev time while still allowing Nuxt’s runtime config to handle theNUXT_PUBLIC_CLERK_CLERK_JS_*pattern.Two optional nits you may want to consider:
- If an explicitly empty string should ever be a valid override,
??would be slightly safer than||to avoid treating''as “unset”:clerkJSUrl: options.clerkJSUrl ?? process.env.NUXT_PUBLIC_CLERK_JS_URL,- The comment about “For both build and runtime overrides in production, use
NUXT_PUBLIC_CLERK_CLERK_JS_*instead” could be misread, since this block only reads the non‑nestedNUXT_PUBLIC_CLERK_JS_*viaprocess.env. You might want to explicitly state which naming pattern affects build‑time defaults (single‑CLERK) vs Nuxt runtime overrides (double‑CLERK) so users know when they may need to set both.
1-1: Prefer@clerk/shared/typesover@clerk/typesfor new workPer the current guidelines,
@clerk/typesis a deprecated alias. When convenient, consider updating this import to pullWithoutfrom@clerk/shared/typesinstead:-import type { Without } from '@clerk/types'; +import type { Without } from '@clerk/shared/types';This is a non‑blocking, nice‑to‑have cleanup and can also be done in a follow‑up sweep.
📜 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.
📒 Files selected for processing (2)
.changeset/smooth-files-join.md(1 hunks)packages/nuxt/src/module.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/nuxt/src/module.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/nuxt/src/module.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/nuxt/src/module.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Prefer importing types from
@clerk/shared/typesinstead of the deprecated@clerk/typesalias
Files:
packages/nuxt/src/module.ts
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
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
Implement proper logging with different levels
Files:
packages/nuxt/src/module.ts
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
packages/nuxt/src/module.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
packages/nuxt/src/module.ts
⏰ 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). (9)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Unit Tests (22, **)
- GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
- GitHub Check: Static analysis
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/smooth-files-join.md (1)
1-5: Changeset accurately documents the behavioural changeScope, bump type, and description match the new build‑time support for
NUXT_PUBLIC_CLERK_JS_*in the Nuxt module. No changes needed here.
|
closed in favor of eefdea2 |
Description
process.envfallbacks forclerkJSUrl,clerkJSVariant, andclerkJSVersionoptions in the Nuxt moduleProblem
Nuxt's runtime config nests options under
clerk, so the env var forclerkJSUrlneeds to beNUXT_PUBLIC_CLERK_CLERK_JS_URL(double CLERK). However, the E2E test framework setsNUXT_PUBLIC_CLERK_JS_URL, which wasn't being read.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.