File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,21 @@ import { swc } from 'rollup-plugin-swc3';
22import commonjs from '@rollup/plugin-commonjs' ;
33import replace from '@rollup/plugin-replace' ;
44import 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
617export default {
718 input : 'src/index.js' ,
19+ external : isExternal ,
820 plugins : [
921 replace ( {
1022 'process.env.NODE_ENV' : JSON . stringify ( 'production' ) ,
You can’t perform that action at this time.
0 commit comments