UNPKG

humanbehavior-js

Version:

SDK for HumanBehavior session and event recording

422 lines (407 loc) 9.1 kB
import typescript from '@rollup/plugin-typescript'; import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import terser from '@rollup/plugin-terser'; import dts from 'rollup-plugin-dts'; import json from '@rollup/plugin-json'; // External dependencies that shouldn't be bundled const external = ['react', 'react-dom', 'react/jsx-runtime']; const nodeExternal = ['fs', 'path', 'child_process', 'readline', '@clack/prompts']; // Global variables for UMD build const globals = { react: 'React', 'react-dom': 'ReactDOM', fs: 'fs', path: 'path' }; export default [ // Main SDK bundle { input: 'src/index.ts', output: [ { file: 'dist/cjs/index.cjs', format: 'cjs', name: 'HumanBehaviorTracker', globals, exports: 'named', sourcemap: true }, { file: 'dist/esm/index.js', format: 'es', sourcemap: true }, { file: 'dist/index.min.js', format: 'umd', name: 'HumanBehaviorTracker', globals, exports: 'auto', sourcemap: true, plugins: [terser()] } ], plugins: [ resolve({ preferBuiltins: false }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: [...external, ...nodeExternal] }, // React component bundle { input: './src/react/index.tsx', output: [ { file: 'dist/cjs/react/index.cjs', format: 'cjs', name: 'HumanBehaviorReact', globals: { ...globals, '../index': 'HumanBehaviorTracker' }, exports: 'named', sourcemap: true }, { file: 'dist/esm/react/index.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: false }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: [...external] // Only externalize React, bundle the main SDK }, // Svelte bundle { input: './src/svelte/index.ts', output: [ { file: 'dist/cjs/svelte/index.cjs', format: 'cjs', name: 'HumanBehaviorSvelte', globals: { ...globals, '../index': 'HumanBehaviorTracker' }, exports: 'named', sourcemap: true }, { file: 'dist/esm/svelte/index.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: false }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: [...external, '../index', ...nodeExternal] // Externalize the main SDK }, // Vue bundle { input: './src/vue/index.ts', output: [ { file: 'dist/cjs/vue/index.cjs', format: 'cjs', name: 'HumanBehaviorVue', globals: { ...globals, '../index': 'HumanBehaviorTracker', 'vue': 'Vue' }, exports: 'named', sourcemap: true }, { file: 'dist/esm/vue/index.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: false }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: [...external, '../index', 'vue', ...nodeExternal] // Externalize Vue and the main SDK }, // Remix bundle { input: './src/remix/index.ts', output: [ { file: 'dist/cjs/remix/index.cjs', format: 'cjs', name: 'HumanBehaviorRemix', globals: { ...globals, '../index': 'HumanBehaviorTracker', '../react': 'HumanBehaviorReact', '@remix-run/node': 'RemixNode' }, exports: 'named', sourcemap: true }, { file: 'dist/esm/remix/index.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: false }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: [...external, '../index', '../react', '@remix-run/node', ...nodeExternal] // Externalize dependencies }, // Angular bundle { input: './src/angular/index.ts', output: [ { file: 'dist/cjs/angular/index.cjs', format: 'cjs', name: 'HumanBehaviorAngular', globals: { ...globals, '../index': 'HumanBehaviorTracker' }, exports: 'named', sourcemap: true }, { file: 'dist/esm/angular/index.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: false }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: [...external, '../index', ...nodeExternal] // Externalize the main SDK }, // Type definition bundles - generate these separately { input: 'src/index.ts', output: { file: 'dist/types/index.d.ts', format: 'es' }, plugins: [dts()], external: [...external, ...nodeExternal] }, { input: 'src/react/index.tsx', output: { file: 'dist/types/react/index.d.ts', format: 'es' }, plugins: [dts()], external: [...external, '..', ...nodeExternal] }, { input: 'src/svelte/index.ts', output: { file: 'dist/types/svelte/index.d.ts', format: 'es' }, plugins: [dts()], external: [...external, '..', ...nodeExternal] }, { input: 'src/vue/index.ts', output: { file: 'dist/types/vue/index.d.ts', format: 'es' }, plugins: [dts()], external: [...external, '..', 'vue', ...nodeExternal] }, { input: 'src/remix/index.ts', output: { file: 'dist/types/remix/index.d.ts', format: 'es' }, plugins: [dts()], external: [...external, '..', '../react', '@remix-run/node', ...nodeExternal] }, { input: 'src/angular/index.ts', output: { file: 'dist/types/angular/index.d.ts', format: 'es' }, plugins: [dts()], external: [...external, '..', ...nodeExternal] }, // CLI bundle { input: 'src/wizard/cli/auto-install.ts', output: { file: 'dist/cli/auto-install.js', format: 'es', sourcemap: true }, plugins: [ resolve({ preferBuiltins: true }), commonjs(), json(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: nodeExternal }, // AI CLI bundle { input: 'src/wizard/cli/ai-auto-install.ts', output: { file: 'dist/cli/ai-auto-install.js', format: 'es', sourcemap: true }, plugins: [ resolve({ preferBuiltins: true }), commonjs(), json(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: nodeExternal }, // Install wizard bundle { input: 'src/wizard/core/install-wizard.ts', output: [ { file: 'dist/cjs/install-wizard.cjs', format: 'cjs', sourcemap: true }, { file: 'dist/esm/install-wizard.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: true }), commonjs(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: nodeExternal }, // Install wizard types { input: 'src/wizard/core/install-wizard.ts', output: { file: 'dist/types/install-wizard.d.ts', format: 'es' }, plugins: [dts()], external: nodeExternal }, // Wizard module bundle { input: 'src/wizard/index.ts', output: [ { file: 'dist/cjs/wizard/index.cjs', format: 'cjs', sourcemap: true }, { file: 'dist/esm/wizard/index.js', format: 'es', sourcemap: true } ], plugins: [ resolve({ preferBuiltins: true }), commonjs(), json(), typescript({ tsconfig: './tsconfig.json', declaration: false, declarationMap: false }) ], external: nodeExternal }, // Wizard module types { input: 'src/wizard/index.ts', output: { file: 'dist/types/wizard/index.d.ts', format: 'es' }, plugins: [dts()], external: nodeExternal } ];