Skip to content

Commit 0dc1be6

Browse files
authored
fix: update type definitions and improve theme script import in devtools (#75)
1 parent 321b929 commit 0dc1be6

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

.changeset/moody-terms-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik.dev/devtools': patch
3+
---
4+
5+
fix: update type definitions and improve theme script import in devtools

packages/devtools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"./ui": {
1414
"import": "./dist/ui/index.qwik.mjs",
1515
"require": "./dist/ui/index.qwik.cjs",
16-
"types": "./dist/ui/lib-types/index.d.ts"
16+
"types": "./dist/ui/lib-types/ui/src/index.d.ts"
1717
}
1818
},
1919
"files": [

packages/plugin/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import VueInspector from 'vite-plugin-inspect'
55
import useCollectHooksSource from './utils/useCollectHooks'
66
import { parseQwikCode } from './parse/parse';
77
import { startPreloading } from './npm/index';
8+
import updateConf from './utils/updateConf';
89

910

1011
export function qwikDevtools(): Plugin[] {
@@ -41,7 +42,7 @@ export function qwikDevtools(): Plugin[] {
4142
},
4243
configResolved(viteConfig) {
4344
_config = viteConfig;
44-
45+
updateConf(_config);
4546
// Start preloading as early as possible, right after config is resolved
4647
if (!preloadStarted) {
4748
preloadStarted = true;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { ResolvedConfig } from "vite";
2+
3+
function updateConf(conf: ResolvedConfig) {
4+
const pkg = '@qwik.dev/devtools';
5+
6+
// Ensure ssr exists
7+
// Some environments may have optional ssr in typed config
8+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
9+
// @ts-ignore
10+
conf.ssr = conf.ssr ?? ({} as typeof conf.ssr);
11+
12+
const current = conf.ssr?.noExternal as unknown;
13+
14+
// If noExternal is not set (undefined/false), initialize as array
15+
if (!current) {
16+
conf.ssr.noExternal = [pkg];
17+
return conf;
18+
}
19+
20+
// If already true (do not externalize anything), nothing to do
21+
if (current === true) {
22+
return conf;
23+
}
24+
25+
// If it's an array of entries, append if missing
26+
if (Array.isArray(current)) {
27+
if (!current.includes(pkg)) {
28+
current.push(pkg);
29+
}
30+
return conf;
31+
}
32+
33+
// If it's a string, convert to array and append
34+
if (typeof current === 'string') {
35+
conf.ssr.noExternal = current === pkg ? [pkg] : [current, pkg];
36+
return conf;
37+
}
38+
39+
// For other shapes (e.g., RegExp), preserve and extend via array wrapper
40+
// This keeps existing behavior while ensuring our package is included
41+
conf.ssr.noExternal = [current as never, pkg] as unknown as typeof conf.ssr.noExternal;
42+
return conf;
43+
}
44+
45+
export default updateConf;

packages/ui/src/devtools.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { DevtoolsPanel } from './components/DevtoolsPanel/DevtoolsPanel';
3939
import { Packages } from './features/Packages/Packages';
4040
import { Inspect } from './features/inspect/Inspect';
4141
import { ThemeToggle } from './components/ThemeToggle/ThemeToggle';
42-
import { ThemeScript } from './components/ThemeToggle/theme-script';
42+
import { ThemeScript as QwikThemeScript } from './components/ThemeToggle/theme-script';
4343
import { CodeBreack } from './features/CodeBreack/CodeBreack';
4444
function getClientRpcFunctions() {
4545
return {
@@ -124,7 +124,7 @@ export const QwikDevtools = component$(() => {
124124

125125
return (
126126
<>
127-
<ThemeScript />
127+
<QwikThemeScript />
128128
<DevtoolsContainer>
129129
<DevtoolsButton state={state} />
130130

0 commit comments

Comments
 (0)