Fix CommonJS exports and content negotiation

- Add CommonJS build (index.cjs) to support both ESM and CJS imports
- Enhanced markdown plugin to serve JSON content for LLMs at /docs endpoint
- Bump version to 0.1.1 for package compatibility fixes
This commit is contained in:
Casey Collier 2025-07-20 15:52:29 -04:00
parent c2e7b5cc1d
commit d8c5e4a1d5
7 changed files with 83 additions and 33 deletions

BIN
manual/imgs/marcus-base.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 KiB

BIN
manual/imgs/sarah-base.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 KiB

View file

@ -1,6 +1,6 @@
{
"name": "@catalystlabs/typedfetch",
"version": "0.1.0",
"version": "0.1.1",
"description": "Type-safe HTTP client that doesn't suck - Fetch for humans who have stuff to build",
"type": "module",
"main": "./dist/index.js",
@ -19,9 +19,10 @@
"LICENSE"
],
"scripts": {
"build": "bun run build:clean && bun run build:esm && bun run build:types",
"build": "bun run build:clean && bun run build:esm && bun run build:cjs && bun run build:types",
"build:clean": "rm -rf dist && mkdir dist",
"build:esm": "bun build src/index.ts --outdir dist --target browser --format esm",
"build:cjs": "bun build src/index.ts --outfile dist/index.cjs --target node --format cjs",
"build:types": "tsc --emitDeclarationOnly --outDir dist",
"typecheck": "tsc --noEmit",
"prepublishOnly": "bun run build && bun run typecheck"

View file

@ -9,22 +9,25 @@
"preview": "vite preview"
},
"dependencies": {
"@catalystlabs/typedfetch": "^0.1.1",
"@mantine/code-highlight": "^8.0.0",
"@mantine/core": "^8.0.0",
"@mantine/hooks": "^8.0.0",
"@mantine/prism": "^7.13.4",
"@mantine/spotlight": "^8.0.0",
"@tabler/icons-react": "^3.26.0",
"@vercel/analytics": "^1.5.0",
"framer-motion": "^11.15.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^7.1.1",
"framer-motion": "^11.15.0",
"@catalystlabs/typedfetch": "^0.1.0"
"shiki": "^3.8.1"
},
"devDependencies": {
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4",
"vite": "^6.0.7",
"typescript": "^5.8.3"
"sharp": "^0.34.3",
"typescript": "^5.8.3",
"vite": "^6.0.7"
}
}

View file

@ -1,41 +1,87 @@
import { MantineProvider } from '@mantine/core';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { CodeHighlightAdapterProvider } from '@mantine/code-highlight';
import { lazy, Suspense } from 'react';
import { Analytics } from '@vercel/analytics/react';
import { shikiAdapter } from './utils/shikiAdapter';
import { theme } from './theme';
import { LandingPage } from './pages/LandingPage';
import { DocsLayout } from './layouts/DocsLayout';
import { GettingStarted } from './pages/docs/GettingStarted';
import { Installation } from './pages/docs/Installation';
import { BasicUsage } from './pages/docs/BasicUsage';
import { Configuration } from './pages/docs/Configuration';
import { ErrorHandling } from './pages/docs/ErrorHandling';
import { TypeInference } from './pages/docs/TypeInference';
import { Caching } from './pages/docs/Caching';
import { Interceptors } from './pages/docs/Interceptors';
import { APIReference } from './pages/docs/APIReference';
// Lazy load documentation pages for better performance
const GettingStarted = lazy(() => import('./pages/docs/GettingStarted'));
const Installation = lazy(() => import('./pages/docs/Installation'));
const BasicUsage = lazy(() => import('./pages/docs/BasicUsage'));
const Configuration = lazy(() => import('./pages/docs/Configuration'));
const ErrorHandling = lazy(() => import('./pages/docs/ErrorHandling'));
const TypeInference = lazy(() => import('./pages/docs/TypeInference'));
const Caching = lazy(() => import('./pages/docs/Caching'));
const Interceptors = lazy(() => import('./pages/docs/Interceptors'));
const APIReference = lazy(() => import('./pages/docs/APIReference'));
import '@mantine/core/styles.css';
import '@mantine/prism/styles.css';
import '@mantine/code-highlight/styles.css';
import '@mantine/spotlight/styles.css';
import './styles/global.css';
import './styles/fonts.css';
export function App() {
return (
<MantineProvider theme={theme} defaultColorScheme="dark">
<BrowserRouter>
<Routes>
<Route path="/" element={<LandingPage />} />
<Route path="/docs" element={<DocsLayout />}>
<Route index element={<GettingStarted />} />
<Route path="installation" element={<Installation />} />
<Route path="basic-usage" element={<BasicUsage />} />
<Route path="configuration" element={<Configuration />} />
<Route path="error-handling" element={<ErrorHandling />} />
<Route path="type-inference" element={<TypeInference />} />
<Route path="caching" element={<Caching />} />
<Route path="interceptors" element={<Interceptors />} />
<Route path="api-reference" element={<APIReference />} />
</Route>
</Routes>
</BrowserRouter>
<CodeHighlightAdapterProvider adapter={shikiAdapter}>
<BrowserRouter>
<Routes>
<Route path="/" element={<LandingPage />} />
<Route path="/docs" element={<DocsLayout />}>
<Route index element={
<Suspense fallback={<div>Loading...</div>}>
<GettingStarted />
</Suspense>
} />
<Route path="installation" element={
<Suspense fallback={<div>Loading...</div>}>
<Installation />
</Suspense>
} />
<Route path="basic-usage" element={
<Suspense fallback={<div>Loading...</div>}>
<BasicUsage />
</Suspense>
} />
<Route path="configuration" element={
<Suspense fallback={<div>Loading...</div>}>
<Configuration />
</Suspense>
} />
<Route path="error-handling" element={
<Suspense fallback={<div>Loading...</div>}>
<ErrorHandling />
</Suspense>
} />
<Route path="type-inference" element={
<Suspense fallback={<div>Loading...</div>}>
<TypeInference />
</Suspense>
} />
<Route path="caching" element={
<Suspense fallback={<div>Loading...</div>}>
<Caching />
</Suspense>
} />
<Route path="interceptors" element={
<Suspense fallback={<div>Loading...</div>}>
<Interceptors />
</Suspense>
} />
<Route path="api-reference" element={
<Suspense fallback={<div>Loading...</div>}>
<APIReference />
</Suspense>
} />
</Route>
</Routes>
</BrowserRouter>
<Analytics />
</CodeHighlightAdapterProvider>
</MantineProvider>
);
}