Skip to content

Commit

Permalink
improved naming of inner appSymbols
Browse files Browse the repository at this point in the history
  • Loading branch information
shairez committed Feb 5, 2025
1 parent 45c9752 commit df5c3bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 8 additions & 3 deletions packages/qwik-city/src/runtime/src/service-worker/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const setupServiceWorkerScope = (
linkBundles: LinkBundle[]
) => {
const swFetch = swScope.fetch.bind(swScope);
const appSymbols = computeAppSymbols(appBundles);
const symbolToBundles = computeAppSymbols(appBundles);

swScope.addEventListener('activate', (event) => {
(async () => {
Expand Down Expand Up @@ -75,13 +75,18 @@ export const setupServiceWorkerScope = (
}

if (Array.isArray(data.symbols)) {
logger.log('[PREFETCHING SYMBOLS]: ', resolveSymbols(appSymbols, data.symbols));
logger.log(
'[PREFETCHING SYMBOLS]: ',
data.symbols,
' bundles: ',
resolveSymbols(symbolToBundles, data.symbols)
);
prefetchBundleNames(
appBundles,
qBuildCache,
swFetch,
baseUrl,
resolveSymbols(appSymbols, data.symbols)
resolveSymbols(symbolToBundles, data.symbols)
);
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/qwik-city/src/runtime/src/service-worker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export const resolveSymbols = (appSymbols: Map<string, string>, symbolsHashes: s
symbolsHashes.map((s) => appSymbols.get(s)).filter((s) => s != null) as string[];

export const computeAppSymbols = (appBundles: AppBundle[]): AppSymbols => {
const appSymbols = new Map<string, string>();
const symbolToBundles = new Map<string, string>();
for (const bundle of appBundles) {
const hashes = bundle[2];
if (hashes) {
for (const hash of hashes) {
appSymbols.set(hash, bundle[0]);
const symbols = bundle[2];
if (symbols) {
for (const symbol of symbols) {
symbolToBundles.set(symbol, bundle[0]);
}
}
}
return appSymbols;
return symbolToBundles;
};

0 comments on commit df5c3bf

Please sign in to comment.