Skip to content

Commit 5063e1c

Browse files
committed
more logging
1 parent e832641 commit 5063e1c

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

packages/qwik/src/core/preloader.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,20 @@ const enum BundleImportState {
3535
Loading,
3636
}
3737
type BundleImport = {
38+
$name$: string;
3839
$url$: string | null;
3940
$state$: BundleImportState;
4041
$imports$: string[];
4142
$dynamicImports$: string[];
43+
$created$?: number | null;
4244
};
4345
const bundles = new Map<string, BundleImport>();
4446
const high: BundleImport[] = [];
4547
const low: BundleImport[] = [];
4648

49+
const log = (...args: any[]) => {
50+
console.log(`PL> ${high.length}hi ${low.length}lo`, ...args);
51+
};
4752
let base: string | undefined;
4853

4954
// minification helpers
@@ -86,8 +91,11 @@ const preloadOne = (bundle: BundleImport, priority?: boolean) => {
8691
return;
8792
}
8893
if (bundle.$url$) {
89-
const start = performance.now();
90-
console.log('>> preloadOne', bundle.$url$, priority);
94+
const start = Date.now();
95+
log(
96+
`load ${priority ? 'high' : 'low'} after ${`${start - bundle.$created$!}ms`}`,
97+
bundle.$name$
98+
);
9199
const link = doc.createElement('link');
92100
link.href = bundle.$url$!;
93101
link.rel = rel;
@@ -98,8 +106,8 @@ const preloadOne = (bundle: BundleImport, priority?: boolean) => {
98106
}
99107
link.as = 'script';
100108
link.onload = link.onerror = () => {
101-
const end = performance.now();
102-
console.log('<< preloadOne done', bundle.$url$, priority, `${end - start}ms`);
109+
const end = Date.now();
110+
log(`DONE ${end - start}ms`, bundle.$name$);
103111
link.remove();
104112
if (priority) {
105113
highCount--;
@@ -126,10 +134,12 @@ const preloadOne = (bundle: BundleImport, priority?: boolean) => {
126134
const makeBundle = (path: string, imports: string[], dynamicImports: string[]) => {
127135
const url = path.endsWith('.js') ? new URL(`${base}${path}`, doc.baseURI).toString() : null;
128136
return {
137+
$name$: path,
129138
$url$: url,
130139
$state$: BundleImportState.None,
131140
$imports$: imports,
132141
$dynamicImports$: dynamicImports,
142+
$created$: Date.now(),
133143
};
134144
};
135145
const ensureBundle = (name: string) => {
@@ -186,13 +196,10 @@ const parseBundleGraph = (text: string, base: string) => {
186196
* @internal
187197
*/
188198
const preload = (name: string | string[], priority?: boolean) => {
189-
if (!isBrowser || !base) {
199+
if (!isBrowser || !base || !name.length) {
190200
return;
191201
}
192202
const queue = priority ? high : low;
193-
console.log(
194-
`preload queue ${name} ${priority ? 'high' : 'low'} - high ${high.length} low ${low.length}`
195-
);
196203
if (Array.isArray(name)) {
197204
queue.push(...(name.map(ensureBundle).filter(Boolean) as BundleImport[]).reverse());
198205
} else {
@@ -201,6 +208,7 @@ const preload = (name: string | string[], priority?: boolean) => {
201208
queue.push(bundle);
202209
}
203210
}
211+
log(`queue ${priority ? 'high' : 'low'}`, name);
204212
trigger();
205213
};
206214

packages/qwik/src/core/qrl/qrl-class.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ export const createQRL = <TYPE>(
127127
};
128128

129129
const resolve = async (containerEl?: Element): Promise<TYPE> => {
130+
console.warn('QRL fire', symbol);
130131
// Give it another bump
131-
preload(symbol, true);
132+
preload(getSymbolHash(symbol), true);
132133
if (symbolRef !== null) {
133134
// Resolving (Promise) or already resolved (value)
134135
return symbolRef;
@@ -229,6 +230,7 @@ export const createQRL = <TYPE>(
229230
if (qDev) {
230231
seal(qrl);
231232
}
233+
console.warn('QRL created', symbol);
232234
preload(hash, true);
233235
return qrl;
234236
};

0 commit comments

Comments
 (0)