diff --git a/package-lock.json b/package-lock.json index 0f8a180e89..16c7d3a5ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "@commitlint/parse": "^16.2.1", "@faker-js/faker": "^6.3.1", "@rollup/plugin-babel": "^5.3.1", + "@rollup/plugin-commonjs": "22.0.1", "@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-replace": "^4.0.0", "@testing-library/jest-dom": "^5.16.4", @@ -9936,6 +9937,33 @@ } } }, + "node_modules/@rollup/plugin-commonjs": { + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-22.0.1.tgz", + "integrity": "sha512-dGfEZvdjDHObBiP5IvwTKMVeq/tBZGMBHZFMdIV1ClMM/YoWS34xrHFGfag9SN2ZtMgNZRFruqvxZQEa70O6nQ==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "engines": { + "node": ">= 12.0.0" + }, + "peerDependencies": { + "rollup": "^2.68.0" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "node_modules/@rollup/plugin-node-resolve": { "version": "13.3.0", "dev": true, @@ -21766,6 +21794,15 @@ "dev": true, "license": "MIT" }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-regex": { "version": "1.1.4", "license": "MIT", @@ -48365,6 +48402,29 @@ "@rollup/pluginutils": "^3.1.0" } }, + "@rollup/plugin-commonjs": { + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-22.0.1.tgz", + "integrity": "sha512-dGfEZvdjDHObBiP5IvwTKMVeq/tBZGMBHZFMdIV1ClMM/YoWS34xrHFGfag9SN2ZtMgNZRFruqvxZQEa70O6nQ==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "dependencies": { + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + } + } + }, "@rollup/plugin-node-resolve": { "version": "13.3.0", "dev": true, @@ -56920,6 +56980,15 @@ "version": "1.0.1", "dev": true }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, "is-regex": { "version": "1.1.4", "requires": { diff --git a/package.json b/package.json index 0bc8968378..95f893b920 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,11 @@ "name": "query", "repository": "https://github.com/tanstack/query.git", "scripts": { - "clean": "npm exec --workspaces -c \"rm -rf build || true\"", + "clean": "lerna run clean --stream --no-bail", "install:csb": "npm install --frozen-lockfile && node ./scripts/fix-package-json.js", "test": "(is-ci && npm run test:ci) || npm run test:dev", - "test:ci": "npm run compile && npm run test:format && npm run test:eslint && npm run test:jest", - "test:dev": "npm run compile && npm run test:format && npm run test:eslint && npm run test:jest:dev", + "test:ci": "npm run typecheck && npm run test:format && npm run test:eslint && npm run test:jest", + "test:dev": "npm run typecheck && npm run test:format && npm run test:eslint && npm run test:jest:dev", "test:dev:17": "REACTJS_VERSION=17 jest --watch", "test:eslint": "lerna run test:eslint --stream --no-bail", "test:format": "npm run prettier -- --check", @@ -23,8 +23,7 @@ "prettier": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\"", "prettier:write": "npm run prettier -- --write", "visualize": "lerna exec 'open build/stats-html.html'", - "cipublish": "ts-node scripts/publish.ts", - "compile": "lerna run compile --stream --no-bail" + "cipublish": "ts-node scripts/publish.ts" }, "namespace": "@tanstack", "workspaces": [ @@ -64,6 +63,7 @@ "@commitlint/parse": "^16.2.1", "@faker-js/faker": "^6.3.1", "@rollup/plugin-babel": "^5.3.1", + "@rollup/plugin-commonjs": "22.0.1", "@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-replace": "^4.0.0", "@testing-library/jest-dom": "^5.16.4", diff --git a/packages/query-async-storage-persister/.eslintrc b/packages/query-async-storage-persister/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/query-async-storage-persister/.eslintrc +++ b/packages/query-async-storage-persister/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index 7f8e96ac58..ce1c2072bd 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -10,16 +10,25 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/packages/query-async-storage-persister/src/index.d.ts", + "types": "build/lib/index.d.ts", + "exports": { + ".": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" + }, "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src" ], "scripts": { - "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "clean": "rm -rf ./build", + "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" } } diff --git a/packages/query-async-storage-persister/tsconfig.json b/packages/query-async-storage-persister/tsconfig.json index bf9a1a74a0..b02272a3e0 100644 --- a/packages/query-async-storage-persister/tsconfig.json +++ b/packages/query-async-storage-persister/tsconfig.json @@ -1,9 +1,15 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/__tests__"], + "references": [ + { "path": "../query-core" }, + { "path": "../react-query-persist-client" } + ] } diff --git a/packages/query-async-storage-persister/tsconfig.lint.json b/packages/query-async-storage-persister/tsconfig.lint.json new file mode 100644 index 0000000000..4b2b5f7be9 --- /dev/null +++ b/packages/query-async-storage-persister/tsconfig.lint.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"], + "references": [ + { "path": "../query-core" }, + { "path": "../react-query-persist-client" } + ] +} diff --git a/packages/query-broadcast-client-experimental/.eslintrc b/packages/query-broadcast-client-experimental/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/query-broadcast-client-experimental/.eslintrc +++ b/packages/query-broadcast-client-experimental/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index 947e189f2c..ecd97a41b3 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -10,17 +10,26 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/packages/query-broadcast-client-experimental/src/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/query-broadcast-client-experimental/src/index.d.ts", + "types": "build/lib/index.d.ts", + "exports": { + ".": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" + }, "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src" ], "scripts": { - "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "clean": "rm -rf ./build", + "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" }, "dependencies": { "broadcast-channel": "^3.4.1" diff --git a/packages/query-broadcast-client-experimental/tsconfig.json b/packages/query-broadcast-client-experimental/tsconfig.json index bf9a1a74a0..374e959a56 100644 --- a/packages/query-broadcast-client-experimental/tsconfig.json +++ b/packages/query-broadcast-client-experimental/tsconfig.json @@ -1,9 +1,12 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/__tests__"], + "references": [{ "path": "../query-core" }] } diff --git a/packages/query-broadcast-client-experimental/tsconfig.lint.json b/packages/query-broadcast-client-experimental/tsconfig.lint.json new file mode 100644 index 0000000000..7f90d602fb --- /dev/null +++ b/packages/query-broadcast-client-experimental/tsconfig.lint.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"], + "references": [{ "path": "../query-core" }] +} diff --git a/packages/query-broadcast-client-experimental/yarn.lock b/packages/query-broadcast-client-experimental/yarn.lock deleted file mode 100644 index 536ee7cdf5..0000000000 --- a/packages/query-broadcast-client-experimental/yarn.lock +++ /dev/null @@ -1,25 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/runtime@^7.16.7": - version "7.17.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.0.tgz#b8d142fc0f7664fb3d9b5833fd40dcbab89276c0" - integrity sha512-etcO/ohMNaNA2UBdaXBBSX/3aEzFMRrVfaPv8Ptc0k+cWpWW0QFiGZ2XnVqQZI1Cf734LbPGmqBKWESfW4x/dQ== - dependencies: - regenerator-runtime "^0.13.4" - -"@reach/observe-rect@^1.1.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@reach/observe-rect/-/observe-rect-1.2.0.tgz#d7a6013b8aafcc64c778a0ccb83355a11204d3b2" - integrity sha512-Ba7HmkFgfQxZqqaeIWWkNK0rEhpxVQHIoVyW1YDSkGsGIXzcaW4deC8B0pZrNSSyLTdIk7y+5olKt5+g0GmFIQ== - -babel-plugin-transform-async-to-promises@^0.8.18: - version "0.8.18" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-promises/-/babel-plugin-transform-async-to-promises-0.8.18.tgz#f4dc5980b8afa0fc9c784b8d931afde913413e39" - integrity sha512-WpOrF76nUHijnNn10eBGOHZmXQC8JYRME9rOLxStOga7Av2VO53ehVFvVNImMksVtQuL2/7ZNxEgxnx7oo/3Hw== - -regenerator-runtime@^0.13.4: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== diff --git a/packages/query-core/.eslintrc b/packages/query-core/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/query-core/.eslintrc +++ b/packages/query-core/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/query-core/package.json b/packages/query-core/package.json index 0c7762e7d5..bbdee3303a 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -10,16 +10,25 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/packages/query-core/src/index.d.ts", + "types": "build/lib/index.d.ts", + "exports": { + ".": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" + }, "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src" ], "scripts": { - "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "clean": "rm -rf ./build", + "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" } } diff --git a/packages/query-core/src/index.ts b/packages/query-core/src/index.ts index 520993fd14..609c74931c 100644 --- a/packages/query-core/src/index.ts +++ b/packages/query-core/src/index.ts @@ -17,13 +17,13 @@ export { parseMutationFilterArgs, parseMutationArgs, } from './utils' -export type { MutationFilters, QueryFilters } from './utils' +export type { MutationFilters, QueryFilters, Updater } from './utils' export { isCancelledError } from './retryer' export { dehydrate, hydrate } from './hydration' // Types export * from './types' -export type { Query } from './query' +export type { Query, QueryState } from './query' export type { Mutation } from './mutation' export type { Logger } from './logger' export type { diff --git a/packages/query-core/tsconfig.json b/packages/query-core/tsconfig.json index bf9a1a74a0..2321ff7608 100644 --- a/packages/query-core/tsconfig.json +++ b/packages/query-core/tsconfig.json @@ -1,9 +1,11 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/tests"] } diff --git a/packages/query-core/tsconfig.lint.json b/packages/query-core/tsconfig.lint.json new file mode 100644 index 0000000000..9ee9f26e25 --- /dev/null +++ b/packages/query-core/tsconfig.lint.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"] +} diff --git a/packages/query-sync-storage-persister/.eslintrc b/packages/query-sync-storage-persister/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/query-sync-storage-persister/.eslintrc +++ b/packages/query-sync-storage-persister/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index 975ea459f7..3e181e36e0 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -10,16 +10,25 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/packages/query-sync-storage-persister/src/index.d.ts", + "types": "build/lib/index.d.ts", + "exports": { + ".": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" + }, "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src" ], "scripts": { - "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "clean": "rm -rf ./build", + "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" } } diff --git a/packages/query-sync-storage-persister/tsconfig.json b/packages/query-sync-storage-persister/tsconfig.json index bf9a1a74a0..ed417347da 100644 --- a/packages/query-sync-storage-persister/tsconfig.json +++ b/packages/query-sync-storage-persister/tsconfig.json @@ -1,9 +1,14 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/__tests__"], + "references": [ + { "path": "../react-query-persist-client" } + ] } diff --git a/packages/query-sync-storage-persister/tsconfig.lint.json b/packages/query-sync-storage-persister/tsconfig.lint.json new file mode 100644 index 0000000000..2dd100c7b8 --- /dev/null +++ b/packages/query-sync-storage-persister/tsconfig.lint.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"], + "references": [ + { "path": "../react-query-persist-client" } + ] +} diff --git a/packages/react-query-devtools/.eslintrc b/packages/react-query-devtools/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/react-query-devtools/.eslintrc +++ b/packages/react-query-devtools/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index 81b380cde9..d352b982b5 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -10,27 +10,38 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/packages/react-query-devtools/src/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/react-query-devtools/src/index.d.ts", + "types": "build/lib/index.d.ts", "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src" ], "exports": { - "development": { - "require": "./build/cjs/packages/react-query-devtools/src/index.js", - "default": "./build/esm/index.js" + ".": { + "development": { + "types": "./build/lib/index.d.ts", + "require": "./build/lib/index.js", + "default": "./build/lib/index.mjs" + }, + "default": { + "types": "./build/lib/index.d.ts", + "require": "./build/lib/noop.js", + "default": "./build/lib/noop.mjs" + } }, - "default": { - "require": "./build/cjs/noop.js", - "default": "./build/esm/noop.js" - } + "./production": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" }, "scripts": { - "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "clean": "rm -rf ./build", + "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" }, "dependencies": { "@tanstack/match-sorter-utils": "^8.0.0-alpha.82", diff --git a/packages/react-query-devtools/src/devtools.tsx b/packages/react-query-devtools/src/devtools.tsx index 7070228364..6ad1d53db0 100644 --- a/packages/react-query-devtools/src/devtools.tsx +++ b/packages/react-query-devtools/src/devtools.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { useSyncExternalStore } from 'use-sync-external-store/shim' +import { useSyncExternalStore } from './useSyncExternalStore' import { useQueryClient, onlineManager, diff --git a/packages/react-query-devtools/src/useSyncExternalStore.native.ts b/packages/react-query-devtools/src/useSyncExternalStore.native.ts new file mode 100644 index 0000000000..226ccef519 --- /dev/null +++ b/packages/react-query-devtools/src/useSyncExternalStore.native.ts @@ -0,0 +1,3 @@ +// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601 +// @ts-ignore +export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js' diff --git a/packages/react-query-devtools/src/useSyncExternalStore.ts b/packages/react-query-devtools/src/useSyncExternalStore.ts new file mode 100644 index 0000000000..c2b6d1454e --- /dev/null +++ b/packages/react-query-devtools/src/useSyncExternalStore.ts @@ -0,0 +1,2 @@ +// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601 +export { useSyncExternalStore } from 'use-sync-external-store/shim/index.js' diff --git a/packages/react-query-devtools/tsconfig.json b/packages/react-query-devtools/tsconfig.json index bf9a1a74a0..b02272a3e0 100644 --- a/packages/react-query-devtools/tsconfig.json +++ b/packages/react-query-devtools/tsconfig.json @@ -1,9 +1,15 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/__tests__"], + "references": [ + { "path": "../query-core" }, + { "path": "../react-query-persist-client" } + ] } diff --git a/packages/react-query-devtools/tsconfig.lint.json b/packages/react-query-devtools/tsconfig.lint.json new file mode 100644 index 0000000000..4b2b5f7be9 --- /dev/null +++ b/packages/react-query-devtools/tsconfig.lint.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"], + "references": [ + { "path": "../query-core" }, + { "path": "../react-query-persist-client" } + ] +} diff --git a/packages/react-query-persist-client/.eslintrc b/packages/react-query-persist-client/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/react-query-persist-client/.eslintrc +++ b/packages/react-query-persist-client/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index edf620fc99..4cdf63dc94 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -10,16 +10,25 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/react-query-persist-client/src/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/packages/react-query-persist-client/src/index.d.ts", + "types": "build/lib/index.d.ts", + "exports": { + ".": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" + }, "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src" ], "scripts": { - "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "clean": "rm -rf ./build", + "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src" } } diff --git a/packages/react-query-persist-client/tsconfig.json b/packages/react-query-persist-client/tsconfig.json index bf9a1a74a0..11630f1dfd 100644 --- a/packages/react-query-persist-client/tsconfig.json +++ b/packages/react-query-persist-client/tsconfig.json @@ -1,9 +1,15 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/__tests__"], + "references": [ + { "path": "../query-core" }, + { "path": "../react-query" } + ] } diff --git a/packages/react-query-persist-client/tsconfig.lint.json b/packages/react-query-persist-client/tsconfig.lint.json new file mode 100644 index 0000000000..6411238e53 --- /dev/null +++ b/packages/react-query-persist-client/tsconfig.lint.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"], + "references": [ + { "path": "../query-core" }, + { "path": "../react-query" } + ] +} diff --git a/packages/react-query/.eslintrc b/packages/react-query/.eslintrc index 067a57a416..fbc604e96c 100644 --- a/packages/react-query/.eslintrc +++ b/packages/react-query/.eslintrc @@ -1,6 +1,6 @@ { "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.lint.json", "sourceType": "module" } } diff --git a/packages/react-query/package.json b/packages/react-query/package.json index a7e7d7bda3..8e8ca7820b 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -10,27 +10,31 @@ "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, - "module": "build/esm/index.js", - "main": "build/cjs/react-query/src/index.js", + "module": "build/lib/index.mjs", + "main": "build/lib/index.js", "browser": "build/umd/index.production.js", - "types": "build/types/packages/react-query/src/index.d.ts", + "types": "build/lib/index.d.ts", + "exports": { + ".": { + "types": "./build/lib/index.d.ts", + "import": "./build/lib/index.mjs", + "default": "./build/lib/index.js" + }, + "./package.json": "./package.json" + }, "sideEffects": [ - "lib/index.js", - "lib/index.mjs", - "lib/reactjs/index.js", - "lib/reactjs/index.mjs", - "lib/reactjs/setBatchUpdatesFn.js", - "lib/reactjs/setBatchUpdatesFn.mjs" + "./src/setBatchUpdatesFn.ts" ], "scripts": { + "clean": "rm -rf ./build", "test:codemods": "../../node_modules/.bin/jest --config codemods/jest.config.js", "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src", "test:jest": "yarn test:codemods && ../../node_modules/.bin/jest --config jest.config.js", - "test:jest:dev": "yarn test:jest --watch", - "compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false" + "test:jest:dev": "yarn test:jest --watch" }, "files": [ - "build/*", + "build/lib/*", + "build/umd/*", "src", "codemods", "!codemods/jest.config.js", diff --git a/packages/react-query/src/useBaseQuery.ts b/packages/react-query/src/useBaseQuery.ts index f819925b26..7272a4b817 100644 --- a/packages/react-query/src/useBaseQuery.ts +++ b/packages/react-query/src/useBaseQuery.ts @@ -1,5 +1,5 @@ import * as React from 'react' -import { useSyncExternalStore } from 'use-sync-external-store/shim' +import { useSyncExternalStore } from './useSyncExternalStore' import { QueryKey, notifyManager, QueryObserver } from '@tanstack/query-core' import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary' diff --git a/packages/react-query/src/useIsFetching.ts b/packages/react-query/src/useIsFetching.ts index 784c164560..c5332008ac 100644 --- a/packages/react-query/src/useIsFetching.ts +++ b/packages/react-query/src/useIsFetching.ts @@ -6,7 +6,7 @@ import { QueryFilters, } from '@tanstack/query-core' -import { useSyncExternalStore } from 'use-sync-external-store/shim' +import { useSyncExternalStore } from './useSyncExternalStore' import { ContextOptions } from './types' import { useQueryClient } from './QueryClientProvider' diff --git a/packages/react-query/src/useIsMutating.ts b/packages/react-query/src/useIsMutating.ts index b2d74e4752..04710c9796 100644 --- a/packages/react-query/src/useIsMutating.ts +++ b/packages/react-query/src/useIsMutating.ts @@ -1,5 +1,5 @@ import * as React from 'react' -import { useSyncExternalStore } from 'use-sync-external-store/shim' +import { useSyncExternalStore } from './useSyncExternalStore' import { notifyManager, diff --git a/packages/react-query/src/useMutation.ts b/packages/react-query/src/useMutation.ts index 2d6c00ee5f..cfd26f8661 100644 --- a/packages/react-query/src/useMutation.ts +++ b/packages/react-query/src/useMutation.ts @@ -1,5 +1,5 @@ import * as React from 'react' -import { useSyncExternalStore } from 'use-sync-external-store/shim' +import { useSyncExternalStore } from './useSyncExternalStore' import { notifyManager, diff --git a/packages/react-query/src/useQueries.ts b/packages/react-query/src/useQueries.ts index 9935f67858..cebaf05086 100644 --- a/packages/react-query/src/useQueries.ts +++ b/packages/react-query/src/useQueries.ts @@ -1,5 +1,5 @@ import * as React from 'react' -import { useSyncExternalStore } from 'use-sync-external-store/shim' +import { useSyncExternalStore } from './useSyncExternalStore' import { QueryKey, diff --git a/packages/react-query/src/useSyncExternalStore.native.ts b/packages/react-query/src/useSyncExternalStore.native.ts new file mode 100644 index 0000000000..226ccef519 --- /dev/null +++ b/packages/react-query/src/useSyncExternalStore.native.ts @@ -0,0 +1,3 @@ +// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601 +// @ts-ignore +export { useSyncExternalStore } from 'use-sync-external-store/shim/index.native.js' diff --git a/packages/react-query/src/useSyncExternalStore.ts b/packages/react-query/src/useSyncExternalStore.ts new file mode 100644 index 0000000000..c2b6d1454e --- /dev/null +++ b/packages/react-query/src/useSyncExternalStore.ts @@ -0,0 +1,2 @@ +// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601 +export { useSyncExternalStore } from 'use-sync-external-store/shim/index.js' diff --git a/packages/react-query/tsconfig.json b/packages/react-query/tsconfig.json index bf9a1a74a0..48a8c7efce 100644 --- a/packages/react-query/tsconfig.json +++ b/packages/react-query/tsconfig.json @@ -1,9 +1,14 @@ { - "composite": true, "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./build/types" + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" }, - "files": ["src/index.ts"], - "include": ["src"] + "include": ["src"], + "exclude": ["src/__tests__"], + "references": [ + { "path": "../query-core" } + ] } diff --git a/packages/react-query/tsconfig.lint.json b/packages/react-query/tsconfig.lint.json new file mode 100644 index 0000000000..85281afb6c --- /dev/null +++ b/packages/react-query/tsconfig.lint.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "rootDir": "./src", + "outDir": "./build/lib", + "tsBuildInfoFile": "./build/.tsbuildinfo" + }, + "include": ["src"], + "references": [ + { "path": "../query-core" } + ] +} diff --git a/rollup.config.ts b/rollup.config.ts index 01b7b1c78f..806b4cc277 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -5,6 +5,7 @@ import size from 'rollup-plugin-size' import visualizer from 'rollup-plugin-visualizer' import replace from '@rollup/plugin-replace' import nodeResolve from '@rollup/plugin-node-resolve' +import commonJS from '@rollup/plugin-commonjs' import path from 'path' import svelte from 'rollup-plugin-svelte' @@ -47,7 +48,9 @@ export default function rollup(options: RollupOptions): RollupOptions[] { jsName: 'QueryAsyncStoragePersister', outputFile: 'query-async-storage-persister', entryFile: 'src/index.ts', - globals: {}, + globals: { + '@tanstack/react-query-persist-client': 'ReactQueryPersistClient', + }, }), ...buildConfigs({ name: 'query-broadcast-client-experimental', @@ -55,7 +58,10 @@ export default function rollup(options: RollupOptions): RollupOptions[] { jsName: 'QueryBroadcastClient', outputFile: 'query-broadcast-client-experimental', entryFile: 'src/index.ts', - globals: {}, + globals: { + '@tanstack/query-core': 'QueryCore', + 'broadcast-channel': 'BroadcastChannel', + }, }), ...buildConfigs({ name: 'query-sync-storage-persister', @@ -63,7 +69,9 @@ export default function rollup(options: RollupOptions): RollupOptions[] { jsName: 'QuerySyncStoragePersister', outputFile: 'query-sync-storage-persister', entryFile: 'src/index.ts', - globals: {}, + globals: { + '@tanstack/react-query-persist-client': 'ReactQueryPersistClient', + }, }), ...buildConfigs({ name: 'react-query', @@ -73,6 +81,7 @@ export default function rollup(options: RollupOptions): RollupOptions[] { entryFile: 'src/index.ts', globals: { react: 'React', + '@tanstack/query-core': 'QueryCore', }, }), ...buildConfigs({ @@ -145,13 +154,15 @@ function esm({ input, packageDir, external, banner }: Options): RollupOptions { input, output: { format: 'esm', + entryFileNames: '[name].mjs', sourcemap: true, - dir: `${packageDir}/build/esm`, + dir: `${packageDir}/build/lib`, banner, }, plugins: [ svelte(), babelPlugin, + commonJS(), nodeResolve({ extensions: ['.ts', '.tsx'] }), ], } @@ -165,14 +176,14 @@ function cjs({ input, external, packageDir, banner }: Options): RollupOptions { output: { format: 'cjs', sourcemap: true, - dir: `${packageDir}/build/cjs`, - preserveModules: true, + dir: `${packageDir}/build/lib`, exports: 'named', banner, }, plugins: [ svelte(), babelPlugin, + commonJS(), nodeResolve({ extensions: ['.ts', '.tsx'] }), ], } @@ -203,6 +214,7 @@ function umdDev({ svelte(), babelPlugin, nodeResolve({ extensions: ['.ts', '.tsx'] }), + commonJS(), umdDevPlugin('development'), ], } @@ -232,6 +244,7 @@ function umdProd({ plugins: [ svelte(), babelPlugin, + commonJS(), nodeResolve({ extensions: ['.ts', '.tsx'] }), umdDevPlugin('production'), terser({