Skip to content

Commit 80c9c46

Browse files
author
Daily Autobot
committed
Merge branch 'main' into daily-js-releases
2 parents f33cbd1 + c194180 commit 80c9c46

File tree

2 files changed

+73
-40
lines changed

2 files changed

+73
-40
lines changed

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"node": ">=12"
2424
},
2525
"scripts": {
26+
"prebuild": "npm run clean",
2627
"build": "rollup -c",
2728
"build:watch": "rollup -c -w",
2829
"clean": "rimraf dist",
@@ -63,19 +64,21 @@
6364
],
6465
"size-limit": [
6566
{
66-
"path": "dist/daily-react.cjs.production.min.js",
67-
"limit": "10 KB"
67+
"path": "dist/index.js",
68+
"limit": "16 KB"
6869
},
6970
{
70-
"path": "dist/daily-react.esm.js",
71-
"limit": "10 KB"
71+
"path": "dist/index.esm.js",
72+
"limit": "17 KB"
7273
}
7374
],
7475
"devDependencies": {
76+
"@babel/preset-env": "^7.28.3",
7577
"@faker-js/faker": "^8.4.1",
7678
"@rollup/plugin-babel": "^6.0.4",
7779
"@rollup/plugin-commonjs": "^28.0.6",
7880
"@rollup/plugin-node-resolve": "^16.0.1",
81+
"@rollup/plugin-terser": "^0.4.4",
7982
"@rollup/plugin-typescript": "^12.1.4",
8083
"@size-limit/preset-small-lib": "^5.0.3",
8184
"@testing-library/react": "^15.0.5",
@@ -106,7 +109,6 @@
106109
"rollup": "^4.44.2",
107110
"rollup-plugin-copy": "^3.5.0",
108111
"rollup-plugin-peer-deps-external": "^2.2.4",
109-
"rollup-plugin-terser": "^7.0.2",
110112
"size-limit": "^5.0.3",
111113
"ts-jest": "^27.0.5",
112114
"tslib": "^2.3.1",

rollup.config.mjs

Lines changed: 66 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,80 @@ import resolve from '@rollup/plugin-node-resolve';
22
import commonjs from '@rollup/plugin-commonjs';
33
import typescript from '@rollup/plugin-typescript';
44
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
5-
import { terser } from 'rollup-plugin-terser';
5+
import terser from '@rollup/plugin-terser';
66
import { babel } from '@rollup/plugin-babel';
77
import copy from 'rollup-plugin-copy';
88
import fs from 'fs-extra';
99

1010
const 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

Comments
 (0)