Skip to content

Commit 2edc7a4

Browse files
committed
fix(clerk-react): ESM bundle with vite / rollup
1 parent eca1ec9 commit 2edc7a4

File tree

3 files changed

+23
-44
lines changed

3 files changed

+23
-44
lines changed

packages/react/package.json

+12-13
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,27 @@
2222
},
2323
"license": "MIT",
2424
"author": "Clerk",
25-
"sideEffects": [
26-
"./dist/cjs/index.js",
27-
"./dist/cjs/polyfills.js",
28-
"./dist/esm/index.js",
29-
"./dist/esm/polyfills.js"
30-
],
3125
"exports": {
26+
"./package.json": "./package.json",
3227
".": {
33-
"types": "./dist/types/index.d.ts",
34-
"import": "./dist/esm/index.js",
35-
"require": "./dist/cjs/index.js"
28+
"import": {
29+
"types": "./dist/index.d.mts",
30+
"default": "./dist/index.mjs"
31+
},
32+
"require": {
33+
"types": "./dist/index.d.ts",
34+
"default": "./dist/index.js"
35+
}
3636
}
3737
},
38-
"main": "./dist/cjs/index.js",
39-
"module": "./dist/esm/index.js",
40-
"types": "./dist/types/index.d.ts",
38+
"main": "./dist/index.js",
39+
"module": "./dist/index.mjs",
40+
"types": "./dist/index.d.ts",
4141
"files": [
4242
"dist"
4343
],
4444
"scripts": {
4545
"build": "tsup",
46-
"build:declarations": "tsc -p tsconfig.declarations.json",
4746
"clean": "rimraf ./dist",
4847
"dev": "tsup --watch",
4948
"dev:publish": "npm run dev -- --env.publish",

packages/react/tsconfig.declarations.json

-12
This file was deleted.

packages/react/tsup.config.ts

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
1-
import type { Options } from 'tsup';
21
import { defineConfig } from 'tsup';
32

4-
import { runAfterLast } from '../../scripts/utils';
3+
// @ts-expect-error for `import module with '.json' extension`
54
import { version as clerkJsVersion } from '../clerk-js/package.json';
5+
// @ts-expect-error for `import module with '.json' extension`
66
import { name, version } from './package.json';
77

88
export default defineConfig(overrideOptions => {
99
const isWatch = !!overrideOptions.watch;
1010
const shouldPublish = !!overrideOptions.env?.publish;
1111

12-
const common: Options = {
13-
entry: ['./src/**/*.{ts,tsx,js,jsx}', '!./src/**/*.test.{ts,tsx}'],
14-
bundle: false,
12+
return {
13+
entry: {
14+
index: 'src/index.ts',
15+
},
16+
onSuccess: shouldPublish ? 'npm run publish:local' : undefined,
17+
format: ['cjs', 'esm'],
18+
bundle: true,
1519
clean: true,
1620
minify: false,
1721
sourcemap: true,
18-
legacyOutput: true,
22+
dts: true,
23+
external: ['react', 'react-dom'],
1924
define: {
2025
PACKAGE_NAME: `"${name}"`,
2126
PACKAGE_VERSION: `"${version}"`,
2227
JS_PACKAGE_VERSION: `"${clerkJsVersion}"`,
2328
__DEV__: `${isWatch}`,
2429
},
2530
};
26-
27-
const esm: Options = {
28-
...common,
29-
format: 'esm',
30-
};
31-
32-
const cjs: Options = {
33-
...common,
34-
format: 'cjs',
35-
outDir: './dist/cjs',
36-
};
37-
38-
return runAfterLast(['npm run build:declarations', shouldPublish && 'npm run publish:local'])(esm, cjs);
3931
});

0 commit comments

Comments
 (0)