Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-lobsters-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/shared": patch
---

Bump target/lib for `@clerk/shared` to ES2022
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ export default tseslint.config([
'jsdoc/require-description-complete-sentence': 'warn',
'jsdoc/require-param': ['warn', { ignoreWhenAllParamsMissing: true }],
'jsdoc/require-param-description': 'warn',
'jsdoc/require-description-complete-sentence': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/tag-lines': [
'warn',
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default defineConfig({
},
test: {
coverage: {
enabled: true,
enabled: false,
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**/*.{ts,tsx}'],
Expand Down
34 changes: 32 additions & 2 deletions packages/clerk-js/vitest.setup.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,40 @@ import * as crypto from 'node:crypto';
import { TextDecoder, TextEncoder } from 'node:util';

import { cleanup, configure } from '@testing-library/react';
import { afterAll, afterEach, beforeAll, vi } from 'vitest';
import { afterAll, afterEach, beforeAll, beforeEach, vi } from 'vitest';

configure({});

afterEach(cleanup);
// Track all timers created during tests to clean them up
const activeTimers = new Set<ReturnType<typeof setTimeout>>();
const originalSetTimeout = global.setTimeout;
const originalClearTimeout = global.clearTimeout;

// Wrap setTimeout to track all timers
global.setTimeout = ((callback: any, delay?: any, ...args: any[]) => {
const timerId = originalSetTimeout(callback, delay, ...args);
activeTimers.add(timerId);
return timerId;
}) as typeof setTimeout;

// Wrap clearTimeout to remove from tracking
global.clearTimeout = ((timerId?: ReturnType<typeof setTimeout>) => {
if (timerId) {
activeTimers.delete(timerId);
originalClearTimeout(timerId);
}
}) as typeof clearTimeout;

beforeEach(() => {
activeTimers.clear();
});

afterEach(() => {
cleanup();
// Clear all tracked timers to prevent post-test execution
activeTimers.forEach(timerId => originalClearTimeout(timerId));
activeTimers.clear();
});

// Store the original method
// eslint-disable-next-line @typescript-eslint/unbound-method
Expand Down Expand Up @@ -43,6 +72,7 @@ if (typeof window !== 'undefined') {
TextEncoder: { value: TextEncoder },
Response: { value: FakeResponse },
crypto: { value: crypto.webcrypto },
isSecureContext: { value: true, writable: true },
});

// Mock ResizeObserver
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/src/__tests__/deprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => {

test('deprecate class property shows warning', () => {
class Example {
someProp: string;
declare someProp: string;
constructor(someProp: string) {
this.someProp = someProp;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => {

test('deprecate class readonly property shows warning', () => {
class Example {
readonly someReadOnlyProp: string;
declare readonly someReadOnlyProp: string;
constructor(someReadOnlyProp: string) {
this.someReadOnlyProp = someReadOnlyProp;
}
Expand Down Expand Up @@ -265,7 +265,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => {

test('deprecate class readonly property does not show warning', () => {
class Example {
readonly someReadOnlyPropInProd: string;
declare readonly someReadOnlyPropInProd: string;
constructor(someReadOnlyPropInProd: string) {
this.someReadOnlyPropInProd = someReadOnlyPropInProd;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => {

test('deprecate class readonly property does not show warning', () => {
class Example {
readonly someReadOnlyPropInProd: string;
declare readonly someReadOnlyPropInProd: string;
constructor(someReadOnlyPropInProd: string) {
this.someReadOnlyPropInProd = someReadOnlyPropInProd;
}
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/react/hooks/useOrganization.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jsdoc/require-description-complete-sentence */
import type {
ClerkPaginatedResponse,
GetDomainsParams,
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/react/hooks/useOrganizationList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jsdoc/require-description-complete-sentence */
import type {
ClerkPaginatedResponse,
CreateOrganizationParams,
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2019",
"target": "ES2022",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Mismatch with changeset/PR title: ES2022 here vs ES2020 in release note

tsconfig sets target/lib to ES2022, but the changeset and PR title say ES2020. Please align them before merge.

Two ways to resolve:

Option A — Keep ES2022 (update changeset/PR messaging):

- Bump target/lib for `@clerk/shared` to ES2020
+ Bump target/lib for `@clerk/shared` to ES2022

Option B — Actually target ES2020 (update tsconfig):

-    "target": "ES2022",
+    "target": "ES2020",
-    "lib": ["ES2022", "DOM", "WebWorker"],
+    "lib": ["ES2020", "DOM", "WebWorker"],

Also applies to: 15-15

🤖 Prompt for AI Agents
In packages/shared/tsconfig.json around line 3, the compiler target is set to
"ES2022" but the changeset/PR title and release notes state "ES2020"; align them
before merge by either (A) keeping ES2022 — update the changeset and PR
title/release note to reference ES2022 and adjust any docs that mention ES2020,
or (B) truly target ES2020 — change the "target" (and corresponding "lib"
entries if present) to "ES2020" in tsconfig.json and run a quick build/test to
ensure no APIs require ES2022; pick one option and apply the matching edits
consistently across the repo and release metadata.

"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
Expand All @@ -12,7 +12,7 @@
"outDir": "dist",
"resolveJsonModule": true,
"jsx": "react",
"lib": ["ES6", "DOM", "WebWorker"],
"lib": ["ES2022", "DOM", "WebWorker"],
"allowJs": true
},
"exclude": ["node_modules"],
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig(overrideOptions => {
minify: false,
sourcemap: true,
dts: true,
target: 'es2020',
target: 'es2022',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Confirm runtime/browser support for ES2022 across consumers.

Bumping target to ES2022 tightens the minimum runtime. Please verify:

  • Node engines in all package.json files (ideally >= 18).
  • Browserslist targets (if published to web) match ES2022.

Run:


🏁 Script executed:

#!/usr/bin/env bash
# Verify engines and browserslist across the repo
jq -r '.name, .engines // empty, .browserslist // empty' **/package.json 2>/dev/null | sed '/^{\|}$/d' | paste - - - | column -t -s $'\t'

Length of output: 88


Below is a revised script to reliably list engines.node and browserslist across all package.json files. Please run it and share the output.


🏁 Script executed:

#!/usr/bin/env bash
find . -name package.json -print0 | while IFS= read -r -d '' file; do
  node_ver=$(jq -r '.engines.node // "<none>"' "$file")
  browsers=$(jq -r '.browserslist // "<none>"' "$file")
  printf "%s: engines.node=%s, browserslist=%s\n" "$file" "$node_ver" "$browsers"
done

Length of output: 7610


Enforce Node ≥18.17.0 and appropriate browserslist for ES2022

  • Numerous packages lack an engines.node field and could be installed on pre-ES2022 runtimes; add "engines": { "node": ">=18.17.0" } to every package.json.
  • Any package published for browsers must declare a browserslist target that only includes browsers supporting ES2022.
🤖 Prompt for AI Agents
In packages/shared/tsup.config.ts around line 27, the build target is ES2022 but
many packages lack an engines field and some browser-published packages lack a
browserslist limiting to ES2022-capable browsers; add "engines": { "node":
">=18.17.0" } to every package.json in the monorepo (root and all packages) and,
for any package that is published for browsers, add or tighten a browserslist
entry that only includes browsers with ES2022 support (or align it with the tsup
target), then ensure package lock/publish tooling and CI validate these fields
so installs on older Node versions or non-ES2022 browsers are prevented.

external: ['react', 'react-dom'],
esbuildPlugins: [WebWorkerMinifyPlugin as any],
define: {
Expand Down
Loading