File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import heif_1 from 'image-size/dist/types/heif.js';
1818
1919import type { Connect } from 'vite' ;
2020import 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
2424const firstBytes : Record < number , keyof typeof types > = {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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-
291export interface Loc {
302 file : string ;
313 line : number | undefined ;
You can’t perform that action at this time.
0 commit comments