Skip to content

Commit

Permalink
fix: bundle query-core with react-query for umd
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianOsipiuk committed Aug 18, 2022
1 parent a6c91da commit 4148da7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
'react-dom': 'ReactDOM',
'@tanstack/query-core': 'QueryCore',
},
skipUmdExternals: ['@tanstack/query-core'],
}),
...buildConfigs({
name: 'react-query-devtools',
Expand Down Expand Up @@ -129,10 +130,17 @@ function buildConfigs(opts: {
outputFile: string
entryFile: string
globals: Record<string, string>
// This option allows to bundle specified dependencies for umd build
skipUmdExternals?: string[]
}): RollupOptions[] {
const input = path.resolve(opts.packageDir, opts.entryFile)
const externalDeps = Object.keys(opts.globals)

const skipUmdExternals = opts.skipUmdExternals || []
const umdExternal = externalDeps.filter(
(external) => !skipUmdExternals.includes(external),
)

const external = (moduleName) => externalDeps.includes(moduleName)
const banner = createBanner(opts.name)

Expand All @@ -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 {
Expand Down

0 comments on commit 4148da7

Please sign in to comment.