Skip to content

fix/umd-build #3924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"module": "build/lib/index.mjs",
"main": "build/lib/index.js",
"browser": "build/umd/index.production.js",
"browser": "build/lib/index.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should allow for older bundlers (e.g. Webpack 4) to properly resolve @tanstack/react-query-devtools

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that we should remove browser field from all packages.
UMD build should be linked directly from CDN.
We do not ship separate code for node and browser (ie. xxx.server.js and xxx.client.js), so we could stick to main field.
Or remap all packages this way.

"types": "build/lib/index.d.ts",
"files": [
"build/lib/*",
Expand Down
20 changes: 10 additions & 10 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'query-core',
packageDir: 'packages/query-core',
jsName: 'QueryCore',
outputFile: 'query-core',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {},
}),
...buildConfigs({
name: 'query-async-storage-persister',
packageDir: 'packages/query-async-storage-persister',
jsName: 'QueryAsyncStoragePersister',
outputFile: 'query-async-storage-persister',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
'@tanstack/react-query-persist-client': 'ReactQueryPersistClient',
Expand All @@ -56,7 +56,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'query-broadcast-client-experimental',
packageDir: 'packages/query-broadcast-client-experimental',
jsName: 'QueryBroadcastClient',
outputFile: 'query-broadcast-client-experimental',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
'@tanstack/query-core': 'QueryCore',
Expand All @@ -67,7 +67,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'query-sync-storage-persister',
packageDir: 'packages/query-sync-storage-persister',
jsName: 'QuerySyncStoragePersister',
outputFile: 'query-sync-storage-persister',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
'@tanstack/react-query-persist-client': 'ReactQueryPersistClient',
Expand All @@ -77,7 +77,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'react-query',
packageDir: 'packages/react-query',
jsName: 'ReactQuery',
outputFile: 'react-query',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
react: 'React',
Expand All @@ -88,7 +88,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'react-query-devtools',
packageDir: 'packages/react-query-devtools',
jsName: 'ReactQueryDevtools',
outputFile: 'react-query-devtools',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
react: 'React',
Expand All @@ -99,7 +99,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'react-query-devtools-noop',
packageDir: 'packages/react-query-devtools',
jsName: 'ReactQueryDevtools',
outputFile: 'react-query-devtools',
outputFile: 'noop',
Copy link
Contributor Author

@JohnDaly JohnDaly Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this to noop will allow react-query-devtools-noop to generate its own output files, and not overwrite the ones for react-query-devtools

entryFile: 'src/noop.ts',
globals: {
react: 'React',
Expand All @@ -110,7 +110,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] {
name: 'react-query-persist-client',
packageDir: 'packages/react-query-persist-client',
jsName: 'ReactQueryPersistClient',
outputFile: 'react-query-persist-client',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
react: 'React',
Expand Down Expand Up @@ -205,7 +205,7 @@ function umdDev({
output: {
format: 'umd',
sourcemap: true,
file: `${packageDir}/build/umd/index.development.js`,
file: `${packageDir}/build/umd/${outputFile}.development.js`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all UMD builds were generating an output file with the index name, this change will only affect the output of the react-query-devtools package

name: jsName,
globals,
banner,
Expand Down Expand Up @@ -236,7 +236,7 @@ function umdProd({
output: {
format: 'umd',
sourcemap: true,
file: `${packageDir}/build/umd/index.production.js`,
file: `${packageDir}/build/umd/${outputFile}.production.js`,
name: jsName,
globals,
banner,
Expand Down