Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/puny-eels-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/devtools': patch
---

Changed package.json exports to allow safe usage in ssr environments
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*

.angular
.nitro
3 changes: 2 additions & 1 deletion examples/react/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"db:migrate": "prisma migrate dev --name init",
"db:reset": " prisma migrate reset",
"db:gen": "prisma generate",
"db:studio": "prisma studio"
"db:studio": "prisma studio",
"build": "vite build"
},
"dependencies": {
"@prisma/client": "^6.13.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"size-limit": [
{
"path": "packages/devtools/dist/esm/index.js",
"path": "packages/devtools/dist/index.js",
"limit": "40 KB"
},
{
Expand Down
27 changes: 18 additions & 9 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@
"devtools"
],
"type": "module",
"types": "dist/esm/index.d.ts",
"module": "dist/esm/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.js",
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
}
"browser": {
"development": {
"types": "./dist/index.d.ts",
"import": "./dist/dev.js"
},
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./package.json": "./package.json"
"node": {
"types": "./dist/index.d.ts",
"import": "./dist/server.js"
},
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"sideEffects": false,
"engines": {
Expand All @@ -45,7 +52,7 @@
"test:lib:dev": "pnpm test:lib --watch",
"test:types": "tsc",
"test:build": "publint --strict",
"build": "vite build"
"build": "tsup"
},
"dependencies": {
"@solid-primitives/keyboard": "^1.2.8",
Expand All @@ -60,6 +67,8 @@
"solid-js": ">=1.9.7"
},
"devDependencies": {
"tsup": "^8.5.0",
"tsup-preset-solid": "^2.2.0",
"vite-plugin-solid": "^2.11.6"
}
}
3 changes: 3 additions & 0 deletions packages/devtools/src/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class TanStackDevtoolsCore {
}

mount<T extends HTMLElement>(el: T) {
// tsup-preset-solid statically replaces this variable during build, which eliminates this code from server bundle
if (import.meta.env.SSR) return

if (this.#isMounted) {
throw new Error('Devtools is already mounted')
}
Expand Down
8 changes: 1 addition & 7 deletions packages/devtools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": [
"src",
"eslint.config.js",
"vite.config.ts",
"tests",
"src/server"
],
"include": ["src", "*.config.*", "tests", "src/server"],
"compilerOptions": {
"jsxImportSource": "solid-js",
"jsx": "preserve",
Expand Down
19 changes: 19 additions & 0 deletions packages/devtools/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'tsup'
import { generateTsupOptions, parsePresetOptions } from 'tsup-preset-solid'

const preset_options = {
entries: {
entry: 'src/index.ts',
dev_entry: true,
server_entry: true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ build for SSR, will pick up this server_entry that have client side only modules removed which makes it safe to use, and Devtols are only ever mounted on the client side

},
cjs: false,
drop_console: true,
}

export default defineConfig(() => {
const parsed_data = parsePresetOptions(preset_options)
const tsup_options = generateTsupOptions(parsed_data)

return tsup_options
})
Loading