Skip to content

Commit 904dcca

Browse files
committed
improve build, simplify export interface
1 parent a03ed8d commit 904dcca

File tree

6 files changed

+844
-24
lines changed

6 files changed

+844
-24
lines changed

packages/react-contextual-analytics/package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-contextual-analytics",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "React Contextual Analytics (RCA) is a framework for collecting and emitting rich contextual analytics events to various analytics providers.",
55
"homepage": "https://github.com/0xdeafcafe/react-contextual-analytics#readme",
66
"bugs": {
@@ -13,13 +13,12 @@
1313
"license": "MIT",
1414
"author": "0xdeafcafe <git@alex.forbes.red>",
1515
"type": "module",
16-
"main": "dist/index.js",
16+
"main": "dist/index.cjs",
17+
"module": "dist/index.js",
1718
"types": "dist/index.d.ts",
1819
"scripts": {
1920
"clean": "rm -rf dist",
20-
"build": "pnpm run clean && pnpm run build:js && pnpm run build:types",
21-
"build:js": "esbuild src/index.ts src/providers/index.ts --bundle --outdir=dist --outbase=src --sourcemap --minify --format=esm --platform=neutral --target=es2020 --external:react --external:react-dom --external:react/jsx-runtime",
22-
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationMap --outDir dist",
21+
"build": "pnpm run clean && tsup",
2322
"prepublishOnly": "cp ../../README.md ./README.md",
2423
"typecheck": "tsgo --noEmit",
2524
"test": "vitest",
@@ -28,6 +27,7 @@
2827
"test:ui": "vitest --ui"
2928
},
3029
"devDependencies": {
30+
"@tsconfig/recommended": "^1.0.8",
3131
"@testing-library/dom": "^10.4.1",
3232
"@testing-library/jest-dom": "^6.1.4",
3333
"@testing-library/react": "^16.3.0",
@@ -39,6 +39,7 @@
3939
"esbuild": "^0.25.9",
4040
"jsdom": "^26.1.0",
4141
"react-dom": "^19.1.1",
42+
"tsup": "^8.5.0",
4243
"typescript": "^5.3.3",
4344
"vitest": "^3.2.4"
4445
},
@@ -51,12 +52,9 @@
5152
],
5253
"exports": {
5354
".": {
55+
"types": "./dist/index.d.ts",
5456
"import": "./dist/index.js",
55-
"types": "./dist/index.d.ts"
56-
},
57-
"./providers": {
58-
"import": "./dist/providers/index.js",
59-
"types": "./dist/providers/index.d.ts"
57+
"require": "./dist/index.cjs"
6058
}
6159
}
6260
}

packages/react-contextual-analytics/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * as providers from "./providers";
12
export { useAnalytics, type AnalyticsEmitter } from './use-analytics';
23
export type { Map, PropsWithEmitterChild, Provider } from "./types";
34
export { AnalyticsBoundary } from './boundary-provider';

packages/react-contextual-analytics/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"resolveJsonModule": true,
2121
"isolatedModules": true,
2222
"noEmit": false,
23+
"incremental": false,
24+
"composite": false,
2325
"paths": {
2426
"@/*": ["./src/*"]
2527
},
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig } from 'tsup';
2+
3+
export default defineConfig({
4+
entry: [
5+
'src/index.ts'
6+
],
7+
format: ['esm', 'cjs'],
8+
dts: true,
9+
sourcemap: true,
10+
minify: true,
11+
clean: true,
12+
target: 'es2020',
13+
platform: 'browser',
14+
splitting: false,
15+
external: ['react', 'react-dom', 'react/jsx-runtime'],
16+
});
17+
18+

0 commit comments

Comments
 (0)