Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
24 changes: 12 additions & 12 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/index.d.cts",
Copy link
Copy Markdown
Member Author

@dstaley dstaley Mar 31, 2026

Choose a reason for hiding this comment

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

I do think it's somewhat strange that tsdown emits both mts and cts files. I would have thought that the CJS files would be js since the package doesn't have "type": "module". After looking into the config for tsdown it does appear that this is to be expected though. When you emit a cjs bundle, tsdown defaults platform to "node", which forces the fixedExtensions config to be true. So it does seem like this is intentional for dual ESM+CJS packages.

"default": "./dist/index.cjs"
}
},
"./internal": {
Expand All @@ -39,8 +39,8 @@
"default": "./dist/internal.mjs"
},
"require": {
"types": "./dist/internal.d.ts",
"default": "./dist/internal.js"
"types": "./dist/internal.d.cts",
"default": "./dist/internal.cjs"
}
},
"./errors": {
Expand All @@ -49,8 +49,8 @@
"default": "./dist/errors.mjs"
},
"require": {
"types": "./dist/errors.d.ts",
"default": "./dist/errors.js"
"types": "./dist/errors.d.cts",
"default": "./dist/errors.cjs"
}
},
"./experimental": {
Expand All @@ -59,8 +59,8 @@
"default": "./dist/experimental.mjs"
},
"require": {
"types": "./dist/experimental.d.ts",
"default": "./dist/experimental.js"
"types": "./dist/experimental.d.cts",
"default": "./dist/experimental.cjs"
}
},
"./legacy": {
Expand All @@ -69,21 +69,21 @@
"default": "./dist/legacy.mjs"
},
"require": {
"types": "./dist/legacy.d.ts",
"default": "./dist/legacy.js"
"types": "./dist/legacy.d.cts",
"default": "./dist/legacy.cjs"
}
},
"./types": {
"import": {
"types": "./dist/types.d.mts"
},
"require": {
"types": "./dist/types.d.ts"
"types": "./dist/types.d.cts"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"files": [
"dist"
],
Expand Down
4 changes: 2 additions & 2 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"importHelpers": true,
"isolatedModules": true,
Expand All @@ -16,7 +15,8 @@
"skipLibCheck": true,
"sourceMap": false,
"strict": true,
"target": "ES2019"
"target": "ES2019",
"rootDir": "./src"
},
"include": ["src"]
}
1 change: 0 additions & 1 deletion packages/react/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"baseUrl": "src",
"jsx": "react",
"noImplicitReturns": false,
"strict": false,
Expand Down
10 changes: 6 additions & 4 deletions packages/react/tsdown.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';

import { parse as parseYaml } from 'yaml';
import { defineConfig } from 'tsdown';
import { defineConfig, type Options } from 'tsdown';

import clerkJsPkgJson from '../clerk-js/package.json' with { type: 'json' };
import pkgJson from './package.json' with { type: 'json' };
Expand Down Expand Up @@ -52,7 +52,7 @@ function getClerkUISupportedReactBounds(): VersionBounds[] {
return bounds;
}

export default defineConfig(overrideOptions => {
export default defineConfig((overrideOptions: Options) => {
const isWatch = !!overrideOptions.watch;
const shouldPublish = !!overrideOptions.env?.publish;
const clerkUISupportedReactBounds = getClerkUISupportedReactBounds();
Expand All @@ -66,13 +66,15 @@ export default defineConfig(overrideOptions => {
legacy: 'src/legacy.ts',
types: 'src/types/index.ts',
},
dts: true,
dts: {
cjsReexport: true,
},
onSuccess: shouldPublish ? 'pkglab pub --ping' : undefined,
format: ['cjs', 'esm'],
clean: true,
minify: false,
sourcemap: true,
external: ['react', 'react-dom'],
external: ['react', 'react-dom', '@clerk/ui/internal'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I built @clerk/react with this branch and checked the output. dist/index.d.mts has import { Theme, Ui } from "@clerk/ui/internal" and the global ClerkAppearanceRegistry augmentation right below it. dist/internal.d.mts has the same for Ui.

Since @clerk/ui is a devDep of @clerk/react, consumers wont have it in their tree. The global augmentation gets pulled in as a side effect (import './types/appearance' in index.ts), so any import from @clerk/react needs @clerk/ui resolvable for type checking. Same for framework SDKs since they all import Ui from @clerk/react/internal.

Making @clerk/ui a full dep isnt viable given its dep tree (emotion, floating-ui, solana, etc). Not sure whats the best path here - maybe keeping it not-external and finding a different fix for the unique symbol duplication?

// Bundle @clerk/ui/register inline at build time so consumers don't need
// @clerk/ui as a dependency. The registration code sets up globalThis.__clerkSharedModules
// to enable @clerk/ui's shared variant to use the host app's React.
Expand Down
85 changes: 39 additions & 46 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,97 +12,97 @@
"exports": {
".": {
"import": {
"types": "./dist/runtime/index.d.mts",
"default": "./dist/runtime/index.mjs"
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/runtime/index.d.ts",
"default": "./dist/runtime/index.js"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./internal/clerk-js/*": {
"import": {
"types": "./dist/runtime/internal/clerk-js/*.d.mts",
"default": "./dist/runtime/internal/clerk-js/*.mjs"
"types": "./dist/internal/clerk-js/*.d.ts",
"default": "./dist/internal/clerk-js/*.mjs"
},
"require": {
"types": "./dist/runtime/internal/clerk-js/*.d.ts",
"default": "./dist/runtime/internal/clerk-js/*.js"
"types": "./dist/internal/clerk-js/*.d.ts",
"default": "./dist/internal/clerk-js/*.js"
}
},
"./*": {
"import": {
"types": "./dist/runtime/*.d.mts",
"default": "./dist/runtime/*.mjs"
"types": "./dist/*.d.ts",
"default": "./dist/*.mjs"
},
"require": {
"types": "./dist/runtime/*.d.ts",
"default": "./dist/runtime/*.js"
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
}
},
"./react": {
"import": {
"types": "./dist/runtime/react/index.d.mts",
"default": "./dist/runtime/react/index.mjs"
"types": "./dist/react/index.d.ts",
"default": "./dist/react/index.mjs"
},
"require": {
"types": "./dist/runtime/react/index.d.ts",
"default": "./dist/runtime/react/index.js"
"types": "./dist/react/index.d.ts",
"default": "./dist/react/index.js"
}
},
"./keyless": {
"import": {
"types": "./dist/runtime/keyless/index.d.mts",
"default": "./dist/runtime/keyless/index.mjs"
"types": "./dist/keyless/index.d.ts",
"default": "./dist/keyless/index.mjs"
},
"require": {
"types": "./dist/runtime/keyless/index.d.ts",
"default": "./dist/runtime/keyless/index.js"
"types": "./dist/keyless/index.d.ts",
"default": "./dist/keyless/index.js"
}
},
"./utils": {
"import": {
"types": "./dist/runtime/utils/index.d.mts",
"default": "./dist/runtime/utils/index.mjs"
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.mjs"
},
"require": {
"types": "./dist/runtime/utils/index.d.ts",
"default": "./dist/runtime/utils/index.js"
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.js"
}
},
"./workerTimers": {
"import": {
"types": "./dist/runtime/workerTimers/index.d.mts",
"default": "./dist/runtime/workerTimers/index.mjs"
"types": "./dist/workerTimers/index.d.ts",
"default": "./dist/workerTimers/index.mjs"
},
"require": {
"types": "./dist/runtime/workerTimers/index.d.ts",
"default": "./dist/runtime/workerTimers/index.js"
"types": "./dist/workerTimers/index.d.ts",
"default": "./dist/workerTimers/index.js"
}
},
"./dom": {
"import": {
"types": "./dist/runtime/dom/index.d.mts",
"default": "./dist/runtime/dom/index.mjs"
"types": "./dist/dom/index.d.ts",
"default": "./dist/dom/index.mjs"
},
"require": {
"types": "./dist/runtime/dom/index.d.ts",
"default": "./dist/runtime/dom/index.js"
"types": "./dist/dom/index.d.ts",
"default": "./dist/dom/index.js"
}
},
"./ui": {
"import": {
"types": "./dist/runtime/ui/index.d.mts",
"default": "./dist/runtime/ui/index.mjs"
"types": "./dist/ui/index.d.ts",
"default": "./dist/ui/index.mjs"
},
"require": {
"types": "./dist/runtime/ui/index.d.ts",
"default": "./dist/runtime/ui/index.js"
"types": "./dist/ui/index.d.ts",
"default": "./dist/ui/index.js"
}
},
"./types": {
"import": {
"types": "./dist/types/index.d.mts",
"types": "./dist/types/index.d.ts",
"default": "./dist/types/index.mjs"
},
"require": {
Expand All @@ -112,20 +112,13 @@
},
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"types": [
"dist/types/index.d.ts"
]
}
},
"files": [
"dist",
"scripts"
],
"scripts": {
"build": "tsdown",
"build:declarations": "tsc -p tsconfig.json",
"build": "tsdown && pnpm build:declarations",
"build:declarations": "tsc -p tsconfig.declarations.json",
"clean": "rimraf ./dist",
"dev": "tsdown --watch src",
"dev:pub": "pnpm dev -- --env.publish",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

import type { SignUpField, SignUpResource } from '@/types';
import type { SignUpField, SignUpResource } from '../../../types';

import { completeSignUpFlow } from '../completeSignUpFlow';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
import type {
PublicKeyCredentialWithAuthenticatorAssertionResponse,
PublicKeyCredentialWithAuthenticatorAttestationResponse,
} from '@/types';
} from '../../../types';

import {
bufferToBase64Url,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';

import { camelToSnake } from '@/underscore';
import { camelToSnake } from '../../../underscore';

import { getQueryParams, stringifyQueryParams } from '../querystring';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, beforeEach, describe, expect, it } from 'vitest';

import type { RedirectOptions } from '@/types';
import { snakeToCamel } from '@/underscore';
import type { RedirectOptions } from '../../../types';
import { snakeToCamel } from '../../../underscore';

import { RedirectUrls } from '../redirectUrls';

Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/internal/clerk-js/__tests__/url.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, beforeEach, describe, expect, it, test, vi } from 'vitest';

import { logger } from '@/logger';
import type { SignUpResource } from '@/types';
import { logger } from '../../../logger';
import type { SignUpResource } from '../../../types';

import {
buildURL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PasswordSettingsData } from '@/types';
import type { PasswordSettingsData } from '../../../types';

export type ComplexityErrors = {
[key in keyof Partial<Omit<PasswordSettingsData, 'disable_hibp' | 'min_zxcvbn_strength' | 'show_zxcvbn'>>]?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/internal/clerk-js/passwords/loadZxcvbn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ModuleManager } from '@/moduleManager';
import type { ZxcvbnResult } from '@/types';
import type { ModuleManager } from '../../../moduleManager';
import type { ZxcvbnResult } from '../../../types';

export type zxcvbnFN = (password: string, userInputs?: (string | number)[]) => ZxcvbnResult;

Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/internal/clerk-js/passwords/password.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PasswordSettingsData, PasswordValidation, ValidatePasswordCallbacks, ZxcvbnResult } from '@/types';
import { noop } from '@/utils';
import type { PasswordSettingsData, PasswordValidation, ValidatePasswordCallbacks, ZxcvbnResult } from '../../../types';
import { noop } from '../../../utils';

import { createValidateComplexity } from './complexity';
import { createValidatePasswordStrength } from './strength';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PasswordSettingsData, ZxcvbnResult } from '@/types';
import type { PasswordSettingsData, ZxcvbnResult } from '../../../types';

type zxcvbnFN = (password: string, userInputs?: (string | number)[]) => ZxcvbnResult;

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/internal/clerk-js/warnings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Serializable } from '@/types';
import type { Serializable } from '../../types';

const formatWarning = (msg: string) => {
return `🔒 Clerk:\n${msg.trim()}\n(This notice only appears in development)`;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/internal/clerk-js/web3.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SolanaWalletAdapterWallet } from '@solana/wallet-standard';

import { buildErrorThrower, ClerkRuntimeError } from '@/error';
import { buildErrorThrower, ClerkRuntimeError } from '../../error';

import type { ModuleManager } from '../../moduleManager';
import type { GenerateSignature, Web3Provider } from '../../types';
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/src/loadScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export async function loadScript(src = '', opts: LoadScriptOptions): Promise<HTM
});

script.src = src;
script.nonce = nonce;
if (nonce) {
script.nonce = nonce;
}
beforeLoad?.(script);
document.body.appendChild(script);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { act, renderHook, waitFor } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import type { ClerkResource } from '@/types';
import type { ClerkResource } from '../../../types';

import type { ResourceCacheStableKey } from '../../stable-keys';
import { createBillingPaginatedHook } from '../createBillingPaginatedHook';
Expand Down
Loading
Loading