UNPKG

@sleekio/sdk

Version:

Modern A/B Testing SDK for JavaScript Applications - Production-ready with graceful fallbacks

66 lines (47 loc) 1.41 kB
# Sleek SDK Build Instructions ## Building the SDK The SDK is built using Rollup to generate multiple formats: ```bash pnpm build ``` This creates: - `dist/sleek.esm.js` - ES Module format - `dist/sleek.cjs.js` - CommonJS format - `dist/sleek.umd.js` - UMD format for browsers ## React Integration For React projects, import the hooks directly from the source: ```javascript // Main SDK import { createAnonymousSleek } from 'sleek-sdk'; // React hooks (import from source to avoid JSX build issues) import { useSleekExperiment, SleekProvider } from 'sleek-sdk/react'; ``` ## Why React Hooks aren't built? The React hooks contain JSX syntax which requires additional Babel configuration to build properly. Since most React projects already have JSX transpilation set up, we distribute the React hooks as source files. ## Usage in Different Environments ### ES Modules (Modern bundlers) ```javascript import { createAnonymousSleek } from 'sleek-sdk'; ``` ### CommonJS (Node.js) ```javascript const { createAnonymousSleek } = require('sleek-sdk'); ``` ### UMD (Browser script tag) ```html <script src="https://unpkg.com/sleek-sdk/dist/sleek.umd.js"></script> <script> const sleek = Sleek.createAnonymousSleek('https://api.example.com'); </script> ``` ## Development ```bash # Install dependencies pnpm install # Run tests pnpm test # Build for production pnpm build # Run demo pnpm demo ```