@@ -2,49 +2,80 @@ import resolve from '@rollup/plugin-node-resolve';
22import commonjs from '@rollup/plugin-commonjs' ;
33import typescript from '@rollup/plugin-typescript' ;
44import peerDepsExternal from 'rollup-plugin-peer-deps-external' ;
5- import { terser } from 'rollup- plugin-terser' ;
5+ import terser from '@ rollup/ plugin-terser' ;
66import { babel } from '@rollup/plugin-babel' ;
77import copy from 'rollup-plugin-copy' ;
88import fs from 'fs-extra' ;
99
1010const packageJson = JSON . parse ( fs . readFileSync ( './package.json' , 'utf8' ) ) ;
1111
12- export default {
13- input : 'src/index.ts' ,
14- output : [
15- {
12+ const commonPlugins = [
13+ peerDepsExternal ( ) ,
14+ resolve ( {
15+ browser : true ,
16+ preferBuiltins : false ,
17+ } ) ,
18+ commonjs ( ) ,
19+ typescript ( {
20+ tsconfig : './tsconfig.json' ,
21+ exclude : [ '**/*.test.*' , '**/*.stories.*' ] ,
22+ } ) ,
23+ babel ( {
24+ babelHelpers : 'bundled' ,
25+ exclude : 'node_modules/**' ,
26+ extensions : [ '.js' , '.jsx' , '.ts' , '.tsx' ] ,
27+ presets : [ [ '@babel/preset-env' , { exclude : [ 'transform-regenerator' ] } ] ] ,
28+ } ) ,
29+ ] ;
30+
31+ const externalDependencies = [ '@daily-co/daily-js' , 'jotai' , 'react' , 'react-dom' ] ;
32+
33+ export default [
34+ // ESM build (unminified)
35+ {
36+ input : 'src/index.ts' ,
37+ output : {
38+ file : packageJson . module ,
39+ format : 'esm' ,
40+ sourcemap : true ,
41+ } ,
42+ plugins : [
43+ ...commonPlugins ,
44+ copy ( {
45+ targets : [ { src : 'src/types' , dest : 'dist' } ] ,
46+ } ) ,
47+ ] ,
48+ external : externalDependencies ,
49+ } ,
50+ // CJS build (minified)
51+ {
52+ input : 'src/index.ts' ,
53+ output : {
1654 file : packageJson . main ,
1755 format : 'cjs' ,
1856 sourcemap : true ,
1957 exports : 'named' ,
2058 } ,
21- {
22- file : packageJson . module ,
23- format : 'esm' ,
24- sourcemap : true ,
25- } ,
26- ] ,
27- plugins : [
28- peerDepsExternal ( ) ,
29- resolve ( {
30- browser : true ,
31- preferBuiltins : false ,
32- } ) ,
33- commonjs ( ) ,
34- typescript ( {
35- tsconfig : './tsconfig.json' ,
36- exclude : [ '**/*.test.*' , '**/*.stories.*' ] ,
37- } ) ,
38- babel ( {
39- babelHelpers : 'bundled' ,
40- exclude : 'node_modules/**' ,
41- extensions : [ '.js' , '.jsx' , '.ts' , '.tsx' ] ,
42- presets : [ [ '@babel/preset-env' , { exclude : [ 'transform-regenerator' ] } ] ] ,
43- } ) ,
44- terser ( ) ,
45- copy ( {
46- targets : [ { src : 'src/types' , dest : 'dist' } ] ,
47- } ) ,
48- ] ,
49- external : [ '@daily-co/daily-js' , 'jotai' , 'react' , 'react-dom' ] ,
50- } ;
59+ plugins : [
60+ ...commonPlugins ,
61+ terser ( {
62+ ecma : 2018 , // Target ES2018+ since WebRTC requires modern browsers
63+ compress : {
64+ passes : 2 , // Run compression twice for better results
65+ unsafe : true , // Enable unsafe optimizations (safe for modern browsers)
66+ } ,
67+ mangle : {
68+ properties : {
69+ regex : / ^ _ / , // Mangle properties starting with underscore
70+ } ,
71+ safari10 : false , // Don't worry about Safari 10 compatibility
72+ } ,
73+ format : {
74+ comments : false , // Remove all comments
75+ ecma : 2018 , // Use modern JS syntax in output
76+ } ,
77+ } ) ,
78+ ] ,
79+ external : externalDependencies ,
80+ } ,
81+ ] ;
0 commit comments