Skip to content

Commit

Permalink
fix(solid-query): Use rollup-preset-solid (#5565)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins authored Jun 12, 2023
1 parent a4d753b commit b098c22
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"rollup-plugin-node-externals": "^6.1.0",
"rollup-plugin-preserve-directives": "^0.2.0",
"rollup-plugin-visualizer": "^5.9.0",
"rollup-preset-solid": "^2.0.1",
"semver": "^7.5.1",
"solid-js": "^1.6.13",
"stream-to-array": "^2.3.0",
Expand Down
1 change: 0 additions & 1 deletion packages/query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
},
"devDependencies": {
"@tanstack/query-core": "^5.0.0-alpha.43",
"rollup-preset-solid": "^2.0.1",
"vite-plugin-solid": "^2.5.0"
}
}
28 changes: 15 additions & 13 deletions packages/solid-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,37 @@
"url": "https://github.com/sponsors/tannerlinsley"
},
"type": "module",
"types": "build/lib/index.d.ts",
"main": "build/lib/index.cjs",
"module": "build/lib/index.js",
"types": "dist/types/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"exports": {
".": {
"types": "./build/lib/index.d.ts",
"solid": "./build/lib/index.js",
"import": "./build/lib/index.js",
"require": "./build/lib/index.cjs",
"default": "./build/lib/index.cjs"
"types": "./dist/types/index.d.ts",
"solid": "./dist/source/index.jsx",
"import": "./dist/esm/index.js",
"browser": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs"
},
"require": "./dist/cjs/index.cjs",
"node": "./dist/cjs/index.cjs"
},
"./package.json": "./package.json"
},
"sideEffects": [
"./src/setBatchUpdatesFn.ts"
],
"scripts": {
"clean": "rimraf ./build && rimraf ./coverage",
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint --ext .ts,.tsx ./src",
"test:types": "tsc --noEmit",
"test:lib": "vitest run --coverage",
"test:lib:dev": "pnpm run test:lib --watch",
"test:build": "publint --strict",
"build": "pnpm build:rollup && pnpm build:types",
"build:rollup": "rollup --config rollup.config.js",
"build:types": "tsc --emitDeclarationOnly"
"build": "rollup --config rollup.config.js"
},
"files": [
"build",
"dist",
"src"
],
"dependencies": {
Expand Down
37 changes: 28 additions & 9 deletions packages/solid-query/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
// @ts-check

import { defineConfig } from 'rollup'
import { buildConfigs } from '../../scripts/getRollupConfig.js'

export default defineConfig(
buildConfigs({
name: 'solid-query',
outputFile: 'index',
entryFile: './src/index.ts',
}),
)
import withSolid from 'rollup-preset-solid'

export function createSolidQueryConfig() {
const solidRollupOptions = /** @type {import('rollup').RollupOptions} */ (
withSolid({
input: `./src/index.ts`,
targets: ['esm', 'cjs'],
external: ['@tanstack/query-core'],
})
)

const outputs = !solidRollupOptions.output
? []
: Array.isArray(solidRollupOptions.output)
? solidRollupOptions.output
: [solidRollupOptions.output]

outputs.forEach((output) => {
if (output.format === 'cjs') {
output.entryFileNames = '[name].cjs'
output.chunkFileNames = '[name]-[hash].cjs'
}
})

return solidRollupOptions
}

export default defineConfig(createSolidQueryConfig())
2 changes: 1 addition & 1 deletion packages/solid-query/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"jsx": "preserve",
"jsxImportSource": "solid-js",
"outDir": "./build/lib",
"outDir": "./dist",
"types": ["vitest/globals"]
},
"include": ["src"]
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b098c22

Please sign in to comment.