From 9bab0edccf16657acf8005f21f0e30533cc72c6c Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Sun, 4 Jun 2023 09:59:52 +1000 Subject: [PATCH] fix(query-devtools): Broken package.json exports (#5528) * Make publint throw errors * Rewrite CJS files to use .cjs extension * Add concurrency option to PR workflow * Fix export extensions --- .github/workflows/pr.yml | 4 +++ packages/eslint-plugin-query/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- packages/query-core/package.json | 2 +- packages/query-devtools/package.json | 30 +++++++++--------- packages/query-devtools/rollup.config.js | 31 ++++++++++++++----- .../query-persist-client-core/package.json | 2 +- .../query-sync-storage-persister/package.json | 2 +- packages/react-query-devtools/package.json | 2 +- .../react-query-persist-client/package.json | 2 +- packages/react-query/package.json | 2 +- packages/solid-query/package.json | 2 +- packages/svelte-query-devtools/package.json | 2 +- packages/svelte-query/package.json | 2 +- packages/vue-query/package.json | 2 +- 16 files changed, 55 insertions(+), 36 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7e74b3ee54..0efc3910ab 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -2,6 +2,10 @@ name: pr on: [pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} diff --git a/packages/eslint-plugin-query/package.json b/packages/eslint-plugin-query/package.json index c825f2b4b6..e54bb7ada2 100644 --- a/packages/eslint-plugin-query/package.json +++ b/packages/eslint-plugin-query/package.json @@ -30,7 +30,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "tsup --minify --dts" }, "files": [ diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index d81ec84f3c..2ed50db7ca 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -34,7 +34,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index f7a478f120..9519bc8f2b 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -32,7 +32,7 @@ "clean": "rimraf ./build && rimraf ./coverage", "test:eslint": "eslint --ext .ts,.tsx ./src", "test:types": "tsc --noEmit", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/query-core/package.json b/packages/query-core/package.json index 85befc2c3d..3db268f065 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -34,7 +34,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/query-devtools/package.json b/packages/query-devtools/package.json index 7b7697b350..fb9fa2bba2 100644 --- a/packages/query-devtools/package.json +++ b/packages/query-devtools/package.json @@ -11,20 +11,20 @@ "url": "https://github.com/sponsors/tannerlinsley" }, "type": "module", - "types": "build/types/index.d.ts", - "main": "build/cjs/index.js", - "module": "build/esm/index.js", + "types": "dist/types/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.js", "exports": { ".": { - "types": "./build/types/index.d.ts", - "solid": "./build/source/index.jsx", - "import": "./build/esm/index.js", + "types": "./dist/types/index.d.ts", + "solid": "./dist/source/index.jsx", + "import": "./dist/esm/index.js", "browser": { - "import": "./build/esm/index.js", - "require": "./build/cjs/index.js" + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.cjs" }, - "require": "./build/cjs/index.js", - "node": "./build/cjs/index.js" + "require": "./dist/cjs/index.cjs", + "node": "./dist/cjs/index.cjs" }, "./package.json": "./package.json" }, @@ -34,14 +34,12 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", - "build": "pnpm build:rollup && pnpm rename-build-dir", - "rename-build-dir": "rimraf ./build && mv ./dist ./build", - "build:rollup": "rollup --config rollup.config.js", - "build:types": "tsc --emitDeclarationOnly" + "test:build": "publint --strict", + "build": "pnpm build:rollup", + "build:rollup": "rollup --config rollup.config.js" }, "files": [ - "build", + "dist", "src" ], "dependencies": { diff --git a/packages/query-devtools/rollup.config.js b/packages/query-devtools/rollup.config.js index 540dc9e36f..e188340430 100644 --- a/packages/query-devtools/rollup.config.js +++ b/packages/query-devtools/rollup.config.js @@ -1,13 +1,30 @@ // @ts-check + +import { defineConfig } from 'rollup' import withSolid from 'rollup-preset-solid' -const config = withSolid({ - input: 'src/index.tsx', - targets: ['esm', 'cjs'], -}) +export function createQueryDevtoolsConfig() { + const solidRollupOptions = /** @type {import('rollup').RollupOptions} */ ( + withSolid({ + input: `./src/index.tsx`, + targets: ['esm', 'cjs'], + external: [], + }) + ) + + const outputs = !solidRollupOptions.output + ? [] + : Array.isArray(solidRollupOptions.output) + ? solidRollupOptions.output + : [solidRollupOptions.output] + + outputs.forEach((output) => { + if (output.format === 'cjs') { + output.entryFileNames = '[name].cjs' + } + }) -if (!Array.isArray(config)) { - config.external = [] + return solidRollupOptions } -export default config +export default defineConfig(createQueryDevtoolsConfig()) diff --git a/packages/query-persist-client-core/package.json b/packages/query-persist-client-core/package.json index 0605e65470..10b7c6a4a8 100644 --- a/packages/query-persist-client-core/package.json +++ b/packages/query-persist-client-core/package.json @@ -34,7 +34,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index ed1ac3d03c..0005cd6e59 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -34,7 +34,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index a232ca461b..5f1e394d58 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -40,7 +40,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly && cpy index.d.ts index.prod.d.ts --cwd=build/lib" diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index 143f0c5363..52a4a0e56c 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -34,7 +34,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 82190fc087..0c56669f96 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -30,7 +30,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:codemods && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:codemods": "cpy ../codemods/src/**/* ./build/codemods", diff --git a/packages/solid-query/package.json b/packages/solid-query/package.json index f4775add4a..4d0cf70199 100644 --- a/packages/solid-query/package.json +++ b/packages/solid-query/package.json @@ -33,7 +33,7 @@ "test:types": "tsc --noEmit", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly" diff --git a/packages/svelte-query-devtools/package.json b/packages/svelte-query-devtools/package.json index b365dd6b0d..578af66c6b 100644 --- a/packages/svelte-query-devtools/package.json +++ b/packages/svelte-query-devtools/package.json @@ -31,7 +31,7 @@ "clean": "rimraf ./build && rimraf ./coverage", "test:types": "svelte-check --tsconfig ./tsconfig.json", "test:eslint": "eslint --ext .svelte,.ts ./src", - "test:build": "publint", + "test:build": "publint --strict", "build": "svelte-package --input ./src --output ./build/lib" }, "dependencies": { diff --git a/packages/svelte-query/package.json b/packages/svelte-query/package.json index 8f7cb2f1f9..988f22b491 100644 --- a/packages/svelte-query/package.json +++ b/packages/svelte-query/package.json @@ -35,7 +35,7 @@ "test:eslint": "eslint --ext .svelte,.ts ./src", "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "svelte-package --input ./src --output ./build/lib" }, "dependencies": { diff --git a/packages/vue-query/package.json b/packages/vue-query/package.json index 1ff09a5642..f6083f5774 100644 --- a/packages/vue-query/package.json +++ b/packages/vue-query/package.json @@ -37,7 +37,7 @@ "test:2.7": "vue-demi-switch 2.7 vue2.7 && vitest", "test:3": "vue-demi-switch 3 && vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint", + "test:build": "publint --strict", "build": "pnpm build:rollup && pnpm build:types", "build:rollup": "rollup --config rollup.config.js", "build:types": "tsc --emitDeclarationOnly"