Skip to content

Commit

Permalink
fix(query-devtools): Broken package.json exports (#5528)
Browse files Browse the repository at this point in the history
* Make publint throw errors

* Rewrite CJS files to use .cjs extension

* Add concurrency option to PR workflow

* Fix export extensions
  • Loading branch information
lachlancollins authored Jun 3, 2023
1 parent 392393a commit 9bab0ed
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion packages/query-async-storage-persister/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/query-broadcast-client-experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 14 additions & 16 deletions packages/query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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": {
Expand Down
31 changes: 24 additions & 7 deletions packages/query-devtools/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 1 addition & 1 deletion packages/query-persist-client-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/query-sync-storage-persister/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query-persist-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9bab0ed

Please sign in to comment.