Skip to content

Commit 70b368d

Browse files
ndbroadbentclaude
andcommitted
Add lightweight types entry point for SSR/web workers
Adds 'chat-to-map/types' entry point that exports only: - Type definitions - Lightweight utility functions (formatLocation, isMappable, etc.) This allows web workers to import types without bundling heavy dependencies like chrono-node, AI SDKs, or export libraries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a72ab68 commit 70b368d

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"import": "./dist/index.js",
3939
"default": "./dist/index.js"
4040
},
41+
"./types": {
42+
"types": "./dist/types-entry.d.ts",
43+
"import": "./dist/types-entry.js",
44+
"default": "./dist/types-entry.js"
45+
},
4146
"./costs": {
4247
"types": "./dist/costs/index.d.ts",
4348
"import": "./dist/costs/index.js",
@@ -52,7 +57,7 @@
5257
"scripts": {
5358
"cli": "bun run src/cli.ts",
5459
"dev": "bun run --watch src/cli.ts",
55-
"build": "bun build src/index.ts --outdir dist --target node && bun build src/costs/index.ts --outdir dist/costs --target node && bun build src/cli.ts --outdir dist --target node && tsc -p tsconfig.types.json",
60+
"build": "bun build src/index.ts --outdir dist --target node && bun build src/types-entry.ts --outdir dist --target node && bun build src/costs/index.ts --outdir dist/costs --target node && bun build src/cli.ts --outdir dist --target node && tsc -p tsconfig.types.json",
5661
"build:types": "tsc -p tsconfig.types.json",
5762
"build:types:watch": "tsc -p tsconfig.types.json --watch",
5863
"build:binary": "bun build src/cli.ts --compile --outfile chat-to-map",

src/types-entry.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Lightweight Types Entry Point
3+
*
4+
* This entry point exports ONLY types and lightweight utilities.
5+
* It does NOT export heavy processing functions like classifyMessages,
6+
* parseChatWithStats, RealChatProcessor, or export functions (PDF, Excel).
7+
*
8+
* Use this entry point in web workers / SSR to avoid bundling heavy deps.
9+
* Use the main entry point in workflows where heavy processing is needed.
10+
*
11+
* @example
12+
* // In SSR/web worker code:
13+
* import { type GeocodedActivity, formatLocation, isMappable } from 'chat-to-map/types'
14+
*
15+
* // In workflow code:
16+
* import { classifyMessages, RealChatProcessor } from 'chat-to-map'
17+
*/
18+
19+
// Valid categories constant
20+
export { VALID_CATEGORIES } from './categories'
21+
22+
// Processor types (interface only, no implementation)
23+
export type {
24+
ChatProcessor,
25+
ProcessingStageResults,
26+
ProcessorCandidateResult,
27+
ProcessorClassifyResult,
28+
ProcessorConfig,
29+
ProcessorGeocodeResult,
30+
ProcessorParseResult
31+
} from './processor'
32+
33+
// All types from types/index.ts - re-export everything
34+
export * from './types'
35+
36+
// Lightweight utilities from types/classifier.ts
37+
export { CATEGORY_EMOJI, formatLocation, isMappable } from './types/classifier'

0 commit comments

Comments
 (0)