@@ -84,6 +84,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
8484 'react-dom' : 'ReactDOM' ,
8585 '@tanstack/query-core' : 'QueryCore' ,
8686 } ,
87+ bundleUMDGlobals : [ '@tanstack/query-core' ] ,
8788 } ) ,
8889 ...buildConfigs ( {
8990 name : 'react-query-devtools' ,
@@ -129,10 +130,17 @@ function buildConfigs(opts: {
129130 outputFile : string
130131 entryFile : string
131132 globals : Record < string , string >
133+ // This option allows to bundle specified dependencies for umd build
134+ bundleUMDGlobals ?: string [ ]
132135} ) : RollupOptions [ ] {
133136 const input = path . resolve ( opts . packageDir , opts . entryFile )
134137 const externalDeps = Object . keys ( opts . globals )
135138
139+ const bundleUMDGlobals = opts . bundleUMDGlobals || [ ]
140+ const umdExternal = externalDeps . filter (
141+ ( external ) => ! bundleUMDGlobals . includes ( external ) ,
142+ )
143+
136144 const external = ( moduleName ) => externalDeps . includes ( moduleName )
137145 const banner = createBanner ( opts . name )
138146
@@ -146,7 +154,7 @@ function buildConfigs(opts: {
146154 globals : opts . globals ,
147155 }
148156
149- return [ esm ( options ) , cjs ( options ) , umdDev ( options ) , umdProd ( options ) ]
157+ return [ esm ( options ) , cjs ( options ) , umdDev ( { ... options , external : umdExternal } ) , umdProd ( { ... options , external : umdExternal } ) ]
150158}
151159
152160function esm ( { input, packageDir, external, banner } : Options ) : RollupOptions {
0 commit comments