Skip to content

Commit 9a9c7d8

Browse files
committed
fix: divide deps and new build
1 parent f1b72b4 commit 9a9c7d8

33 files changed

+2513
-265
lines changed

package.json

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
{
2-
"name": "devtools",
3-
"version": "1.0.0",
2+
"name": "@qwik.dev/devtools",
3+
"version": "0.0.3",
44
"license": "MIT",
5+
"main": "./dist/plugin/index.mjs",
6+
"description": "Qwik devtools package",
7+
"qwik": "./dist/component/index.qwik.mjs",
8+
"exports": {
9+
".": {
10+
"import": "./dist/plugin/index.mjs",
11+
"types": "./dist/plugin/index.d.ts"
12+
},
13+
"./component": {
14+
"import": "./dist/component/index.qwik.mjs",
15+
"require": "./dist/component/index.qwik.cjs",
16+
"types": "./dist/component/lib-types/index.d.ts"
17+
}
18+
},
19+
"files": [
20+
"dist/**"
21+
],
522
"scripts": {
6-
"build:devtools": "pnpm --filter @qwik.dev/devtools build",
7-
"playground": "pnpm --filter playground dev"
23+
"playground": "pnpm --filter playground dev",
24+
"build:devtools": "tsx scripts/build-devtools.ts"
25+
},
26+
"peerDependencies": {
27+
"vite": "^6.0.7",
28+
"@qwik.dev/core": "^2.0.0-alpha.4"
29+
},
30+
"dependencies": {
31+
"birpc": "^0.2.19",
32+
"superjson": "^2.2.2",
33+
"dree": "^5.1.5",
34+
"@qwikest/icons": "^0.0.13",
35+
"vite-hot-client": "^0.2.4"
36+
},
37+
"devDependencies": {
38+
"tsx": "^4.19.2",
39+
"@types/node": "^22.10.5"
840
},
941
"private": false,
1042
"keywords": [

packages/devtools/package.json

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@qwik.dev/devtools",
3-
"version": "0.0.3",
2+
"name": "@devtools/component",
3+
"version": "1.0.0",
44
"description": "Qwik devtools package",
55
"main": "./lib/index.qwik.mjs",
66
"exports": {
@@ -9,7 +9,6 @@
99
}
1010
},
1111
"files": [
12-
"src",
1312
"lib",
1413
"lib-types"
1514
],
@@ -35,19 +34,15 @@
3534
},
3635
"peerDependencies": {
3736
"@qwik.dev/core": "^2.0.0-alpha.4",
38-
"vite": "^6.0.0"
37+
"@qwik.dev/router": "^2.0.0-alpha.4"
3938
},
40-
"dependencies": {
41-
"image-meta": "^0.2.1",
39+
"devDependencies": {
40+
"@devtools/kit": "workspace:*",
4241
"birpc": "^0.2.19",
43-
"perfect-debounce": "^1.0.0",
44-
"fast-glob": "^3.3.2",
4542
"superjson": "^2.2.2",
4643
"dree": "^5.1.5",
4744
"@qwikest/icons": "^0.0.13",
48-
"vite-hot-client": "^0.2.4"
49-
},
50-
"devDependencies": {
45+
"vite-hot-client": "^0.2.4",
5146
"@types/eslint": "8.56.10",
5247
"@types/node": "20.14.11",
5348
"@typescript-eslint/eslint-plugin": "7.16.1",

packages/devtools/src/devtools.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import {
2222
type AssetInfo,
2323
type RoutesInfo,
2424
RouteType,
25-
} from './kit';
25+
} from '@devtools/kit';
2626
import styles from './devtools.css?inline';
27-
import { getCurrentLocation } from './utils/location';
27+
import { useLocation } from '@qwik.dev/router';
28+
2829
function getClientRpcFunctions() {
2930
return {
3031
healthCheck: () => true,
@@ -49,7 +50,7 @@ export const QwikDevtools = component$(() => {
4950
routes: undefined,
5051
});
5152
const panelRef = useSignal<HTMLDivElement>();
52-
const location = getCurrentLocation();
53+
const location = useLocation();
5354

5455
// eslint-disable-next-line qwik/no-use-visible-task
5556
useVisibleTask$(async ({ cleanup, track }) => {
@@ -371,7 +372,10 @@ export const QwikDevtools = component$(() => {
371372
<div class="col-route">
372373
<span
373374
class={
374-
location === `/${route.relativePath}`
375+
(location.url.pathname === '/' &&
376+
route.relativePath === '') ||
377+
location.url.pathname ===
378+
`/${route.relativePath}/`
375379
? 'active-route'
376380
: ''
377381
}

packages/devtools/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export { qwikDevtools } from './plugin';
21
export { QwikDevtools } from './devtools';

packages/devtools/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"jsx": "react-jsx",
88
"jsxImportSource": "@qwik.dev/core",
99
"strict": true,
10-
"declaration": true,
1110
"declarationDir": "lib-types",
12-
"resolveJsonModule": true,
1311
"moduleResolution": "Bundler",
12+
"declaration": true,
13+
"resolveJsonModule": true,
1414
"esModuleInterop": true,
1515
"skipLibCheck": true,
1616
"isolatedModules": true,
1717
"types": ["vite/client"],
1818
"paths": {
19-
"@qwik/devtools-kit": ["../../packages/devtools-kit"]
19+
"@devtools/kit": ["../kit/src/index.ts"]
2020
}
2121
},
2222
"include": ["src"]

packages/devtools/vite.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export default defineConfig(() => {
2525
// externalize deps that shouldn't be bundled into the library
2626
external: [
2727
/^node:.*/,
28-
...excludeAll(dependencies),
2928
...excludeAll(peerDependencies),
29+
...excludeAll(dependencies),
3030
],
3131
},
3232
},

packages/kit/build.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineBuildConfig } from 'unbuild';
2+
3+
export default defineBuildConfig({
4+
entries: ['src/index'],
5+
externals: [],
6+
declaration: true,
7+
rollup: {
8+
emitCJS: true,
9+
},
10+
});

packages/kit/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@devtools/kit",
3+
"version": "1.0.0",
4+
"description": "Qwik devtools package",
5+
"main": "./src/index.ts",
6+
"exports": {
7+
".": {
8+
"import": "./src/index.ts"
9+
}
10+
},
11+
"files": [
12+
"src"
13+
],
14+
"private": false,
15+
"type": "module",
16+
"scripts": {},
17+
"dependencies": {
18+
"superjson": "^2.2.2",
19+
"birpc": "^0.2.19",
20+
"dree": "^5.1.5"
21+
},
22+
"peerDependencies": {
23+
"vite": "^6.0.7"
24+
},
25+
"devDependencies": {
26+
"@types/eslint": "8.56.10",
27+
"unbuild": "^3.2.0",
28+
"@types/node": "20.14.11",
29+
"@typescript-eslint/eslint-plugin": "7.16.1",
30+
"@typescript-eslint/parser": "7.16.1",
31+
"eslint": "8.57.0",
32+
"eslint-plugin-qwik": "2.0.0-alpha.3",
33+
"np": "^8.0.4",
34+
"prettier": "3.3.3",
35+
"typescript": "5.4.5",
36+
"vite-tsconfig-paths": "^4.2.1",
37+
"cpy-cli": "^5.0.0"
38+
}
39+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/kit/tsconfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "esnext",
5+
"moduleResolution": "Bundler",
6+
"strict": true
7+
}
8+
}

packages/playgrounds/package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"qwik": "qwik"
2828
},
2929
"devDependencies": {
30-
"@qwik.dev/devtools": "workspace:*",
30+
"@devtools/plugin": "workspace:*",
31+
"@devtools/component": "workspace:*",
3132
"@qwik.dev/core": "^2.0.0-alpha.4",
3233
"@qwik.dev/router": "^2.0.0-alpha.3",
3334
"@types/eslint": "8.56.10",
@@ -38,10 +39,7 @@
3839
"eslint-plugin-qwik": "2.0.0-alpha.3",
3940
"prettier": "3.3.3",
4041
"typescript": "5.4.5",
41-
"vite": "5.4.10",
42-
"vite-tsconfig-paths": "^4.2.1",
43-
"vite-hot-client": "^0.2.4",
44-
"birpc": "^0.2.19",
45-
"dree": "^5.1.5"
42+
"vite": "^6.0.7",
43+
"vite-tsconfig-paths": "^4.2.1"
4644
}
4745
}

packages/playgrounds/vite.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { qwikVite } from '@qwik.dev/core/optimizer';
66
import { qwikRouter } from '@qwik.dev/router/vite';
77
import { defineConfig, ResolvedConfig, type UserConfig, Plugin } from 'vite';
88
import tsconfigPaths from 'vite-tsconfig-paths';
9-
import { qwikDevtools } from '@qwik.dev/devtools';
9+
import { qwikDevtools } from '@devtools/plugin';
1010
import pkg from './package.json';
1111
type PkgDep = Record<string, string>;
1212
const { dependencies = {}, devDependencies = {} } = pkg as any as {

packages/plugin/build.config.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineBuildConfig } from 'unbuild';
2+
3+
export default defineBuildConfig({
4+
entries: ['./src/index.ts'],
5+
externals: ['vite'],
6+
declaration: true,
7+
clean: true,
8+
failOnWarn: false,
9+
rollup: {
10+
output: {
11+
dir: '../../dist/plugin',
12+
},
13+
inlineDependencies: true,
14+
emitCJS: true,
15+
},
16+
});

packages/plugin/package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@devtools/plugin",
3+
"version": "1.0.0",
4+
"description": "Qwik devtools plugin",
5+
"main": "./dist/index.mjs",
6+
"exports": {
7+
".": {
8+
"import": "./dist/index.mjs"
9+
}
10+
},
11+
"files": [
12+
"src"
13+
],
14+
"private": false,
15+
"type": "module",
16+
"scripts": {
17+
"build": "unbuild",
18+
"stub": "tsup --watch"
19+
},
20+
"devDependencies": {
21+
"@devtools/kit": "workspace:*",
22+
"dree": "^5.1.5",
23+
"fast-glob": "^3.3.2",
24+
"image-meta": "^0.2.1",
25+
"birpc": "^0.2.19",
26+
"vite": "^6.0.7",
27+
"unbuild": "^3.2.0",
28+
"tsup": "^8.3.5",
29+
"@types/eslint": "8.56.10",
30+
"@types/node": "20.14.11",
31+
"@typescript-eslint/eslint-plugin": "7.16.1",
32+
"@typescript-eslint/parser": "7.16.1",
33+
"eslint": "8.57.0",
34+
"np": "^8.0.4",
35+
"prettier": "3.3.3",
36+
"typescript": "5.4.5",
37+
"cpy-cli": "^5.0.0"
38+
}
39+
}

packages/devtools/src/plugin/assets/index.ts packages/plugin/src/assets/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fsp from 'node:fs/promises';
22
import fg from 'fast-glob';
33
import { resolve, relative, join } from 'node:path/posix';
44
import { ServerContext } from '../types';
5-
import { AssetType, AssetInfo } from '../../kit/types';
5+
import { AssetType, AssetInfo } from '@devtools/kit';
66

77
// const defaultAllowedExtensions = [
88
// 'png',

packages/devtools/src/plugin/index.ts packages/plugin/src/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ResolvedConfig, type Plugin } from 'vite';
22
import { getServerFunctions } from './rpc';
3-
import { createServerRpc, setViteServerContext } from '../kit';
3+
import { createServerRpc, setViteServerContext } from '@devtools/kit';
44

55
export function qwikDevtools(): Plugin {
66
let _config: ResolvedConfig;
@@ -13,12 +13,15 @@ export function qwikDevtools(): Plugin {
1313
transform: {
1414
order: 'pre',
1515
handler(code, id) {
16+
const isDev = _config.env.DEV;
17+
1618
// Only transform the root component file
1719
if (id.endsWith('root.tsx')) {
20+
const importPath = '@qwik.dev/devtools/component';
1821
// Check if QwikDevtools import already exists
19-
if (!code.includes('@qwik.dev/devtools')) {
22+
if (!code.includes(importPath)) {
2023
// Add import for QwikDevtools using the correct package name
21-
code = `import { QwikDevtools } from '@qwik.dev/devtools';\n${code}`;
24+
code = `import { QwikDevtools } from '${importPath}';\n${code}`;
2225
}
2326

2427
// Find the closing body tag and inject the QwikDevtools component before it

packages/devtools/src/plugin/npm/index.ts packages/plugin/src/npm/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { ServerContext } from '../types';
22
import fsp from 'node:fs/promises';
3-
import { NpmInfo } from '../../kit/types';
3+
import { NpmInfo } from '@devtools/kit';
44

55
export function getNpmFunctions({ config }: ServerContext) {
66
return {
77
async getQwikPackages(): Promise<NpmInfo> {
8-
const pathToPackageJson = config.configFileDependencies.find((file) =>
9-
file.endsWith('package.json'),
8+
const pathToPackageJson = config.configFileDependencies.find(
9+
(file: string) => file.endsWith('package.json'),
1010
);
1111
if (!pathToPackageJson) return [];
1212

packages/devtools/src/plugin/routes/index.ts packages/plugin/src/routes/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RoutesInfo } from '../../kit/types';
1+
import { RoutesInfo } from '@devtools/kit';
22
import { ServerContext } from '../types';
33
import { scanAsync } from 'dree';
44

packages/devtools/src/plugin/rpc/index.ts packages/plugin/src/rpc/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ServerFunctions } from '../../kit/types';
1+
import { ServerFunctions } from '@devtools/kit';
22
import { getAssetsFunctions } from '../assets';
33
import { ServerContext } from '../types';
44
import { getRouteFunctions } from '../routes';

packages/devtools/src/plugin/types/index.ts packages/plugin/src/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ViteDevServer, ResolvedConfig } from 'vite';
1+
import { type ViteDevServer, type ResolvedConfig } from 'vite';
22

33
export interface ServerContext {
44
server: ViteDevServer;

packages/plugin/tsconfig.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "esnext",
5+
"moduleResolution": "Bundler",
6+
"strict": true,
7+
"declaration": true,
8+
"resolveJsonModule": true,
9+
"esModuleInterop": true,
10+
"skipLibCheck": true,
11+
"isolatedModules": true,
12+
"types": ["vite/client"],
13+
"paths": {
14+
"@devtools/kit": ["../../packages/devtools-kit"]
15+
}
16+
},
17+
"include": ["src"],
18+
}
19+

0 commit comments

Comments
 (0)