diff --git a/rollup.config.ts b/rollup.config.ts index 7e3384fb8b..33de5b501d 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -84,6 +84,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] { 'react-dom': 'ReactDOM', '@tanstack/query-core': 'QueryCore', }, + bundleUMDGlobals: ['@tanstack/query-core'], }), ...buildConfigs({ name: 'react-query-devtools', @@ -129,10 +130,17 @@ function buildConfigs(opts: { outputFile: string entryFile: string globals: Record + // This option allows to bundle specified dependencies for umd build + bundleUMDGlobals?: string[] }): RollupOptions[] { const input = path.resolve(opts.packageDir, opts.entryFile) const externalDeps = Object.keys(opts.globals) + const bundleUMDGlobals = opts.bundleUMDGlobals || [] + const umdExternal = externalDeps.filter( + (external) => !bundleUMDGlobals.includes(external), + ) + const external = (moduleName) => externalDeps.includes(moduleName) const banner = createBanner(opts.name) @@ -146,7 +154,7 @@ function buildConfigs(opts: { globals: opts.globals, } - return [esm(options), cjs(options), umdDev(options), umdProd(options)] + return [esm(options), cjs(options), umdDev({...options, external: umdExternal}), umdProd({...options, external: umdExternal})] } function esm({ input, packageDir, external, banner }: Options): RollupOptions {