Skip to content

Commit 1ef1eda

Browse files
committed
wip speed test
1 parent 0964796 commit 1ef1eda

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

packages/qwik/src/core/preloader.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const preloadStr = 'preload';
5252

5353
let highCount = 0;
5454
let lowCount = 0;
55+
const max = 11;
5556
/**
5657
* This is called when a bundle is queued or finished loading.
5758
*
@@ -61,11 +62,11 @@ let lowCount = 0;
6162
* We make sure to first empty the high priority items, first-in-last-out.
6263
*/
6364
const trigger = () => {
64-
while (highCount < 6 && high.length) {
65+
while (highCount < max && high.length) {
6566
const bundle = high.pop()!;
6667
preloadOne(bundle!, true);
6768
}
68-
while (highCount + lowCount < 6 && low.length) {
69+
while (highCount + lowCount < max && low.length) {
6970
const bundle = low.pop()!;
7071
preloadOne(bundle!);
7172
}
@@ -108,8 +109,13 @@ const preloadOne = (bundle: BundleImport, priority?: boolean) => {
108109

109110
bundle.$state$ = BundleImportState.Loading;
110111
/** Now that we processed the bundle, its dependencies are needed ASAP */
111-
preload(bundle.$dynamicImports$);
112-
preload(bundle.$imports$, priority);
112+
if (priority) {
113+
// make sure to queue the high priority imports first so they preloaded before the low priority ones
114+
preload(bundle.$imports$, priority);
115+
preload(bundle.$dynamicImports$);
116+
} else {
117+
preload([...bundle.$imports$, ...bundle.$dynamicImports$]);
118+
}
113119
};
114120

115121
const makeBundle = (path: string, imports: string[], dynamicImports: string[]) => {
@@ -165,8 +171,7 @@ const parseBundleGraph = (text: string, base: string) => {
165171
for (const name of toProcess) {
166172
const bundle = bundles.get(name)!;
167173
// we assume low priority
168-
preload(bundle.$dynamicImports$);
169-
preload(bundle.$imports$);
174+
preload([...bundle.$imports$, ...bundle.$dynamicImports$]);
170175
}
171176
};
172177

packages/qwik/src/optimizer/src/plugins/bundle-graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function convertManifestToBundleGraph(
6161

6262
// We only include dynamic imports that have qrl segments
6363
// If the dev wants to include other dynamic imports, they can just make a qrl()
64-
const dynamicImports = bundle.dynamicImports?.filter((dep) => graph[dep]?.hasSegments) || [];
64+
const dynamicImports = bundle.dynamicImports?.filter((dep) => graph[dep]) || [];
6565

6666
// Overwrite so we don't mutate
6767
graph[bundleName] = {

scripts/submodule-core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ async function submoduleCoreProd(config: BuildConfig) {
5757
sourcemap: true,
5858
globals: {
5959
'@builder.io/qwik/build': 'qwikBuild',
60+
// not actually used
61+
'@builder.io/qwik/preloader': 'qwikPreloader',
6062
},
6163
banner: getBanner('@builder.io/qwik', config.distVersion),
6264
};

0 commit comments

Comments
 (0)