Skip to content

Commit a58174f

Browse files
committed
update rollup config
Signed-off-by: YASHMAHAKAL <yvsst01@gmail.com>
1 parent e2ca3dc commit a58174f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

rollup.config.js renamed to rollup.config.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@ import { swc } from 'rollup-plugin-swc3';
22
import commonjs from '@rollup/plugin-commonjs';
33
import replace from '@rollup/plugin-replace';
44
import uglify from '@lopatnov/rollup-plugin-uglify';
5+
import packageJson from './package.json' with { type: 'json' };
6+
7+
// Automatically externalize all dependencies and peerDependencies.
8+
// This prevents bundling tss-react, MUI, emotion etc. into dist and ensures
9+
// the consuming app's single instance of each package is used (critical for
10+
// React Context-based theme sharing with tss-react).
11+
const externalPackages = [
12+
...Object.keys(packageJson.dependencies || {}),
13+
...Object.keys(packageJson.peerDependencies || {}),
14+
];
15+
const isExternal = (id) => externalPackages.some((pkg) => id === pkg || id.startsWith(`${pkg}/`));
516

617
export default {
718
input: 'src/index.js',
19+
external: isExternal,
820
plugins: [
921
replace({
1022
'process.env.NODE_ENV': JSON.stringify('production'),

0 commit comments

Comments
 (0)