Skip to content
Closed
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
7 changes: 7 additions & 0 deletions .changeset/itchy-avocados-push.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 0 additions & 2 deletions packages/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was already defined in the declarations tsconfig so I removed this duplicate

"declarationMap": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
Expand Down
2 changes: 0 additions & 2 deletions packages/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"declaration": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was already defined in the declarations tsconfig so I removed this duplicate

"declarationMap": true,
"esModuleInterop": true,
"importHelpers": true,
"isolatedModules": true,
Expand Down
10 changes: 5 additions & 5 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"types": "./dist/index.d.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Core of the problem, tsc can't dual emit .d.ts as CJS and .d.mts as ESM so it's only .d.ts for both

"default": "./dist/index.mjs"
},
"require": {
Expand All @@ -35,7 +35,7 @@
},
"./internal": {
"import": {
"types": "./dist/internal.d.mts",
"types": "./dist/internal.d.ts",
"default": "./dist/internal.mjs"
},
"require": {
Expand All @@ -45,7 +45,7 @@
},
"./errors": {
"import": {
"types": "./dist/errors.d.mts",
"types": "./dist/errors.d.ts",
"default": "./dist/errors.mjs"
},
"require": {
Expand All @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions packages/react/tsconfig.declarations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist",
"declarationMap": true,
"emitDeclarationOnly": true,
"skipLibCheck": true
},
"exclude": ["**/__tests__/**/*"]
}
3 changes: 0 additions & 3 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"declarationMap": false,
"esModuleInterop": true,
"emitDeclarationOnly": true,
"importHelpers": true,
"isolatedModules": true,
"jsx": "react",
Expand Down
8 changes: 5 additions & 3 deletions packages/react/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
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';

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,
Expand All @@ -28,4 +28,6 @@ export default defineConfig(overrideOptions => {
__DEV__: `${isWatch}`,
},
};

return runAfterLast(['pnpm build:declarations', shouldPublish && 'pnpm publish:local'])(options);
});
16 changes: 8 additions & 8 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
Expand All @@ -22,7 +22,7 @@
},
"./*": {
"import": {
"types": "./dist/*.d.mts",
"types": "./dist/*.d.ts",
"default": "./dist/*.mjs"
},
"require": {
Expand All @@ -32,7 +32,7 @@
},
"./react": {
"import": {
"types": "./dist/react/index.d.mts",
"types": "./dist/react/index.d.ts",
"default": "./dist/react/index.mjs"
},
"require": {
Expand All @@ -42,7 +42,7 @@
},
"./utils": {
"import": {
"types": "./dist/utils/index.d.mts",
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.mjs"
},
"require": {
Expand All @@ -52,7 +52,7 @@
},
"./workerTimers": {
"import": {
"types": "./dist/workerTimers/index.d.mts",
"types": "./dist/workerTimers/index.d.ts",
"default": "./dist/workerTimers/index.mjs"
},
"require": {
Expand All @@ -62,7 +62,7 @@
},
"./dom": {
"import": {
"types": "./dist/dom/index.d.mts",
"types": "./dist/dom/index.d.ts",
"default": "./dist/dom/index.mjs"
},
"require": {
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions packages/shared/tsconfig.declarations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist",
"declarationMap": true,
"emitDeclarationOnly": true,
"skipLibCheck": true
},
"exclude": ["**/__tests__/**/*"]
}
4 changes: 0 additions & 4 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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],
Expand Down
9 changes: 5 additions & 4 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
11 changes: 11 additions & 0 deletions packages/types/tsconfig.declarations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist/types",
"declarationMap": true,
"emitDeclarationOnly": true,
"skipLibCheck": true
},
"exclude": ["**/__tests__/**/*"]
}
4 changes: 2 additions & 2 deletions packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/types/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export default defineConfig(() => {
sourcemap: true,
format: ['cjs', 'esm'],
legacyOutput: true,
dts: true,
onSuccess: 'pnpm build:declarations',
};
});
13 changes: 9 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.