diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index 3f36011185..9207fe2d60 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -10,10 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/umd/index.production.js", - "types": "build/lib/index.d.ts", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index 15a8082a07..148dbab155 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -10,10 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/umd/index.production.js", - "types": "build/lib/index.d.ts", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-core/package.json b/packages/query-core/package.json index e6f8161b6f..847c3f5c77 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -10,10 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/umd/index.production.js", - "types": "build/lib/index.d.ts", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index 154727f2fd..51b94aaf4c 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -10,10 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/umd/index.production.js", - "types": "build/lib/index.d.ts", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index 819cb173e0..817cd8734e 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -10,16 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/lib/index.js", - "types": "build/lib/index.d.ts", - "files": [ - "build/lib/*", - "build/umd/*", - "cjs.fallback.js", - "src" - ], "exports": { ".": { "development": { @@ -40,6 +33,12 @@ }, "./package.json": "./package.json" }, + "files": [ + "build/lib/*", + "build/umd/*", + "cjs.fallback.js", + "src" + ], "scripts": { "clean": "rm -rf ./build", "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index 74d2af8210..2ef129ef00 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -10,10 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/umd/index.production.js", - "types": "build/lib/index.d.ts", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 497586a069..0cfdb29628 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -10,10 +10,9 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, + "types": "build/lib/index.d.ts", "module": "build/lib/index.mjs", "main": "build/lib/index.js", - "browser": "build/umd/index.production.js", - "types": "build/lib/index.d.ts", "exports": { ".": { "types": "./build/lib/index.d.ts", diff --git a/rollup.config.ts b/rollup.config.ts index 22903a4931..33de5b501d 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -81,8 +81,10 @@ export default function rollup(options: RollupOptions): RollupOptions[] { entryFile: 'src/index.ts', globals: { react: 'React', + 'react-dom': 'ReactDOM', '@tanstack/query-core': 'QueryCore', }, + bundleUMDGlobals: ['@tanstack/query-core'], }), ...buildConfigs({ name: 'react-query-devtools', @@ -128,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) @@ -145,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 {