diff --git a/.changeset/itchy-avocados-push.md b/.changeset/itchy-avocados-push.md new file mode 100644 index 00000000000..c53bb4bd365 --- /dev/null +++ b/.changeset/itchy-avocados-push.md @@ -0,0 +1,7 @@ +--- +'@clerk/shared': patch +'@clerk/clerk-react': patch +'@clerk/types': patch +--- + +Internal change on how the TypeScript types are generated. If you run into type issues, please open an issue. diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index f11d7b36ca9..38f85bab2bc 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -2,8 +2,6 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "baseUrl": ".", - "declaration": true, - "declarationMap": false, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "importHelpers": true, diff --git a/packages/nextjs/tsconfig.json b/packages/nextjs/tsconfig.json index 11f92d1c109..3e6c40dc969 100644 --- a/packages/nextjs/tsconfig.json +++ b/packages/nextjs/tsconfig.json @@ -2,8 +2,6 @@ "compilerOptions": { "allowJs": true, "baseUrl": ".", - "declaration": true, - "declarationMap": true, "esModuleInterop": true, "importHelpers": true, "isolatedModules": true, diff --git a/packages/react/package.json b/packages/react/package.json index 772c74cf2c1..fd86e2e6f86 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -25,7 +25,7 @@ "exports": { ".": { "import": { - "types": "./dist/index.d.mts", + "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }, "require": { @@ -35,7 +35,7 @@ }, "./internal": { "import": { - "types": "./dist/internal.d.mts", + "types": "./dist/internal.d.ts", "default": "./dist/internal.mjs" }, "require": { @@ -45,7 +45,7 @@ }, "./errors": { "import": { - "types": "./dist/errors.d.mts", + "types": "./dist/errors.d.ts", "default": "./dist/errors.mjs" }, "require": { @@ -64,11 +64,11 @@ "scripts": { "build": "tsup", "postbuild": "node ../../scripts/subpath-workaround.mjs react", - "clean": "rimraf ./dist", + "build:declarations": "tsc -p tsconfig.declarations.json", "dev": "tsup --watch", "dev:publish": "pnpm dev --env.publish", "lint": "eslint src", - "lint:attw": "attw --pack .", + "lint:attw": "attw --pack . --ignore-rules false-cjs", "lint:publint": "publint", "publish:local": "pnpm yalc push --replace --sig", "test": "vitest run", diff --git a/packages/react/tsconfig.declarations.json b/packages/react/tsconfig.declarations.json new file mode 100644 index 00000000000..b97a0330a47 --- /dev/null +++ b/packages/react/tsconfig.declarations.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "./dist", + "declarationMap": true, + "emitDeclarationOnly": true, + "skipLibCheck": true + }, + "exclude": ["**/__tests__/**/*"] +} diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 90e5d8cc9b4..fe00399fb13 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -1,10 +1,7 @@ { "compilerOptions": { "baseUrl": ".", - "declaration": true, - "declarationMap": false, "esModuleInterop": true, - "emitDeclarationOnly": true, "importHelpers": true, "isolatedModules": true, "jsx": "react", diff --git a/packages/react/tsup.config.ts b/packages/react/tsup.config.ts index d0290c0e12a..9af1b89dbc6 100644 --- a/packages/react/tsup.config.ts +++ b/packages/react/tsup.config.ts @@ -1,5 +1,7 @@ +import type { Options } from 'tsup'; import { defineConfig } from 'tsup'; +import { runAfterLast } from '../../scripts/utils'; import { version as clerkJsVersion } from '../clerk-js/package.json'; import { name, version } from './package.json'; @@ -7,14 +9,12 @@ export default defineConfig(overrideOptions => { const isWatch = !!overrideOptions.watch; const shouldPublish = !!overrideOptions.env?.publish; - return { + const options: Options = { entry: { index: 'src/index.ts', internal: 'src/internal.ts', errors: 'src/errors.ts', }, - dts: true, - onSuccess: shouldPublish ? 'pnpm publish:local' : undefined, format: ['cjs', 'esm'], bundle: true, clean: true, @@ -28,4 +28,6 @@ export default defineConfig(overrideOptions => { __DEV__: `${isWatch}`, }, }; + + return runAfterLast(['pnpm build:declarations', shouldPublish && 'pnpm publish:local'])(options); }); diff --git a/packages/shared/package.json b/packages/shared/package.json index 58ea863e8d6..2dc8c3cc0a2 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -12,7 +12,7 @@ "exports": { ".": { "import": { - "types": "./dist/index.d.mts", + "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }, "require": { @@ -22,7 +22,7 @@ }, "./*": { "import": { - "types": "./dist/*.d.mts", + "types": "./dist/*.d.ts", "default": "./dist/*.mjs" }, "require": { @@ -32,7 +32,7 @@ }, "./react": { "import": { - "types": "./dist/react/index.d.mts", + "types": "./dist/react/index.d.ts", "default": "./dist/react/index.mjs" }, "require": { @@ -42,7 +42,7 @@ }, "./utils": { "import": { - "types": "./dist/utils/index.d.mts", + "types": "./dist/utils/index.d.ts", "default": "./dist/utils/index.mjs" }, "require": { @@ -52,7 +52,7 @@ }, "./workerTimers": { "import": { - "types": "./dist/workerTimers/index.d.mts", + "types": "./dist/workerTimers/index.d.ts", "default": "./dist/workerTimers/index.mjs" }, "require": { @@ -62,7 +62,7 @@ }, "./dom": { "import": { - "types": "./dist/dom/index.d.mts", + "types": "./dist/dom/index.d.ts", "default": "./dist/dom/index.mjs" }, "require": { @@ -121,12 +121,12 @@ "scripts": { "build": "tsup", "postbuild": "node ../../scripts/subpath-workaround.mjs shared", - "clean": "rimraf ./dist", + "build:declarations": "tsc -p tsconfig.declarations.json", "dev": "tsup --watch", "dev:publish": "pnpm dev -- --env.publish", "postinstall": "node ./scripts/postinstall.mjs", "lint": "eslint src", - "lint:attw": "attw --pack .", + "lint:attw": "attw --pack . --ignore-rules false-cjs", "lint:publint": "publint", "publish:local": "pnpm yalc push --replace --sig", "test": "jest", diff --git a/packages/shared/tsconfig.declarations.json b/packages/shared/tsconfig.declarations.json new file mode 100644 index 00000000000..b97a0330a47 --- /dev/null +++ b/packages/shared/tsconfig.declarations.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "./dist", + "declarationMap": true, + "emitDeclarationOnly": true, + "skipLibCheck": true + }, + "exclude": ["**/__tests__/**/*"] +} diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json index f120c796cd0..c791a8f0a33 100644 --- a/packages/shared/tsconfig.json +++ b/packages/shared/tsconfig.json @@ -9,12 +9,8 @@ "preserveWatchOutput": true, "skipLibCheck": true, "strict": true, - "emitDeclarationOnly": true, - "declaration": true, - "declarationMap": true, "outDir": "dist", "resolveJsonModule": true, - "declarationDir": "dist/types", "jsx": "react", "lib": ["ES6", "DOM", "WebWorker"], "allowJs": true diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index 6515b9da11d..0750e7b17b9 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -23,7 +23,7 @@ export default defineConfig(overrideOptions => { clean: true, minify: false, sourcemap: true, - dts: true, + onSuccess: 'pnpm build:declarations', target: 'es2020', external: ['react', 'react-dom'], esbuildPlugins: [WebWorkerMinifyPlugin as any], diff --git a/packages/types/package.json b/packages/types/package.json index b447b8ef779..acf57f127fa 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -25,18 +25,19 @@ "author": "Clerk", "main": "dist/index.js", "module": "dist/esm/index.js", - "types": "dist/index.d.ts", + "types": "dist/types/index.d.ts", "files": [ "dist" ], "scripts": { "build": "tsup --env.NODE_ENV production", - "clean": "rimraf ./dist", + "build:declarations": "tsc -p tsconfig.declarations.json", "dev": "tsup --watch", - "lint": "eslint src" + "lint": "eslint src/", + "lint:attw": "attw --pack ." }, "dependencies": { - "csstype": "3.1.3" + "csstype": "3.1.1" }, "devDependencies": {}, "engines": { diff --git a/packages/types/tsconfig.declarations.json b/packages/types/tsconfig.declarations.json new file mode 100644 index 00000000000..c574ff8d83a --- /dev/null +++ b/packages/types/tsconfig.declarations.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationDir": "./dist/types", + "declarationMap": true, + "emitDeclarationOnly": true, + "skipLibCheck": true + }, + "exclude": ["**/__tests__/**/*"] +} diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index b4cd2de77f2..cfe6e3bf749 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -3,8 +3,8 @@ "outDir": "./dist", "baseUrl": "./src", "lib": ["es6", "dom"], - "module": "commonjs", - "moduleResolution": "node", + "module": "nodenext", + "moduleResolution": "nodenext", "declaration": true, "declarationMap": true, "noImplicitReturns": true, diff --git a/packages/types/tsup.config.ts b/packages/types/tsup.config.ts index 992fe31fd0f..9c324339b5b 100644 --- a/packages/types/tsup.config.ts +++ b/packages/types/tsup.config.ts @@ -10,6 +10,6 @@ export default defineConfig(() => { sourcemap: true, format: ['cjs', 'esm'], legacyOutput: true, - dts: true, + onSuccess: 'pnpm build:declarations', }; }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f58ebff3d5..8d71548f4b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -983,8 +983,8 @@ importers: packages/types: dependencies: csstype: - specifier: 3.1.3 - version: 3.1.3 + specifier: 3.1.1 + version: 3.1.1 packages/ui: dependencies: @@ -7402,6 +7402,9 @@ packages: resolution: {integrity: sha512-h66W1URKpBS5YMI/V8PyXvTMFT8SupJ1IzoIV8IeBC/ji8WVmrO8dGlTi+2dh6whmdk6BiKJLD/ZBkhWbcg6nA==} engines: {node: '>=18'} + csstype@3.1.1: + resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==} + csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} @@ -16557,7 +16560,7 @@ snapshots: '@emotion/memoize': 0.8.1 '@emotion/unitless': 0.8.1 '@emotion/utils': 1.2.1 - csstype: 3.1.3 + csstype: 3.1.1 '@emotion/sheet@1.2.2': {} @@ -21495,7 +21498,7 @@ snapshots: '@types/react@18.3.12': dependencies: '@types/prop-types': 15.7.5 - csstype: 3.1.3 + csstype: 3.1.1 '@types/resolve@1.20.2': {} @@ -23905,6 +23908,8 @@ snapshots: dependencies: rrweb-cssom: 0.7.1 + csstype@3.1.1: {} + csstype@3.1.3: {} cva@1.0.0-beta.3(typescript@5.6.3):