Skip to content

Commit d57a664

Browse files
committed
fix(build): circular types tsc errors
1 parent dc83625 commit d57a664

4 files changed

Lines changed: 31 additions & 31 deletions

File tree

packages/qwik-router/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
"@qwik-router-sw-register": ["packages/qwik-router/src/runtime/src/sw-register-runtime.ts"]
4545
}
4646
},
47-
"include": ["."],
48-
"exclude": ["dist"]
47+
"include": ["src", "global.d.ts"],
48+
"exclude": ["dist", "lib"]
4949
}

packages/qwik-vite/src/plugins/dev/image-size-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import heif_1 from 'image-size/dist/types/heif.js';
1818

1919
import type { Connect } from 'vite';
2020
import type { OptimizerSystem } from '../../types';
21-
import { formatError } from '../vite-utils';
21+
import { formatError } from '../format-error';
2222

2323
// This map helps avoid validating for every single image type
2424
const firstBytes: Record<number, keyof typeof types> = {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { OptimizerSystem } from '../types';
2+
import { findLocation, generateCodeFrame } from './vite-utils';
3+
4+
export async function formatError(sys: OptimizerSystem, e: Error) {
5+
const err = e as any;
6+
let loc = err.loc;
7+
8+
if (!err.frame && !err.plugin) {
9+
if (!loc) {
10+
loc = findLocation(err);
11+
}
12+
if (loc) {
13+
err.loc = loc;
14+
if (loc.file) {
15+
const fs: typeof import('fs') = await sys.dynamicImport('node:fs');
16+
const { normalizePath }: typeof import('vite') = await sys.dynamicImport('vite');
17+
err.id = normalizePath(err.loc.file);
18+
try {
19+
const code = fs.readFileSync(err.loc.file, 'utf-8');
20+
err.frame = generateCodeFrame(code, err.loc);
21+
} catch {
22+
// nothing
23+
}
24+
}
25+
}
26+
}
27+
return e;
28+
}

packages/qwik-vite/src/plugins/vite-utils.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
import type { OptimizerSystem } from '../types';
2-
3-
export async function formatError(sys: OptimizerSystem, e: Error) {
4-
const err = e as any;
5-
let loc = err.loc;
6-
7-
if (!err.frame && !err.plugin) {
8-
if (!loc) {
9-
loc = findLocation(err);
10-
}
11-
if (loc) {
12-
err.loc = loc;
13-
if (loc.file) {
14-
const fs: typeof import('fs') = await sys.dynamicImport('node:fs');
15-
const { normalizePath }: typeof import('vite') = await sys.dynamicImport('vite');
16-
err.id = normalizePath(err.loc.file);
17-
try {
18-
const code = fs.readFileSync(err.loc.file, 'utf-8');
19-
err.frame = generateCodeFrame(code, err.loc);
20-
} catch {
21-
// nothing
22-
}
23-
}
24-
}
25-
}
26-
return e;
27-
}
28-
291
export interface Loc {
302
file: string;
313
line: number | undefined;

0 commit comments

Comments
 (0)