Skip to content
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

fix/umd-build #3924

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/esm/index.js",
"main": "build/cjs/packages/react-query-devtools/src/index.js",
"browser": "build/umd/index.production.js",
"browser": "build/umd/noop.production.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 the CJS and ESM production build entrypoints are noop's, I updated this to also follow that pattern

Copy link
Collaborator

Choose a reason for hiding this comment

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

we now have index.development.js, index.production.js, noop.developtment.js and noop.production.js produced. I don't think that's on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thought was that build/umd/index.development.js would be distributed via CDN (to support use-cases like #3916).

I'm not entirely sure what we want to do about the "browser" field here. It seems that the convention for CJS and ESM production builds is to resolve to a noop for the dev tools package? The counter-point to this would be supporting bundlers like Webpack 4, which might not know about the "exports" field and instead use the "browser" field. When I tried to use the dev tools package on a project that used an older version of Webpack, I ran into that problem and couldn't use the dev tools.

Copy link
Collaborator

Choose a reason for hiding this comment

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

When I tried to use the dev tools package on a project that used an older version of Webpack, I ran into that problem and couldn't use the dev tools.

yeah me to (react-scripts v3). would be good if we could support this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested the change from d85684b with react-scripts v3 and v4. Both versions are able to load @tanstack/react-query-devtools properly with that change

"types": "build/types/react-query-devtools/src/index.d.ts",
"files": [
"build/*",
Expand Down
20 changes: 10 additions & 10 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,39 @@ 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',
TkDodo marked this conversation as resolved.
Show resolved Hide resolved
entryFile: 'src/index.ts',
globals: {},
}),
...buildConfigs({
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: {},
}),
...buildConfigs({
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: {},
}),
...buildConfigs({
name: 'react-query',
packageDir: 'packages/react-query',
jsName: 'ReactQuery',
outputFile: 'react-query',
outputFile: 'index',
entryFile: 'src/index.ts',
globals: {
react: 'React',
Expand All @@ -79,7 +79,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 @@ -90,7 +90,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 @@ -101,7 +101,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 @@ -194,7 +194,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 @@ -224,7 +224,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