diff --git a/README.md b/README.md index 823d86c..d6c58da 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,19 @@ const profile = await typed.get('/me') // profile.data is strongly typed based on your schema/runtime samples ``` +## 🧩 Install & runtime support + +- Published as zero-dependency ESM with an accompanying CommonJS build for straightforward `npm install @catalystlabs/typedfetch` integration across bundlers, Node 16+, and modern browsers. +- Ships type declarations (`dist/index.d.ts`) and a CLI entrypoint (`typedfetch`) out of the box. + +```ts +// ESM / TypeScript +import { tf } from '@catalystlabs/typedfetch' + +// CommonJS +const { tf: tfCjs } = require('@catalystlabs/typedfetch') +``` + ## ✨ Features ### 🔒 Type Safety diff --git a/tests/package-config.test.ts b/tests/package-config.test.ts new file mode 100644 index 0000000..ebbdb28 --- /dev/null +++ b/tests/package-config.test.ts @@ -0,0 +1,34 @@ +import { readFileSync } from 'node:fs' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' + +const __dirname = dirname(fileURLToPath(import.meta.url)) +const pkg = JSON.parse( + readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8') +) + +describe('package metadata', () => { + it('exposes dual-build entrypoints for easy installation', () => { + expect(pkg.main).toBe('./dist/index.js') + expect(pkg.module).toBe('./dist/index.js') + expect(pkg.types).toBe('./dist/index.d.ts') + expect(pkg.exports?.['.']?.import).toBe('./dist/index.js') + expect(pkg.exports?.['.']?.require).toBe('./dist/index.cjs') + expect(pkg.exports?.['.']?.types).toBe('./dist/index.d.ts') + }) + + it('ships distributable files and documentation', () => { + expect(pkg.files).toEqual( + expect.arrayContaining(['dist', 'README.md', 'LICENSE']) + ) + }) + + it('includes the CLI entrypoint', () => { + expect(pkg.bin?.typedfetch).toBe('./dist/cli.js') + }) + + it('is versioned for publishing', () => { + expect(pkg.version).not.toBe('0.0.0') + }) +})