Skip to content

Commit 39c08bc

Browse files
authored
Merge pull request #7569 from QwikDev/v2-fixes
fix(core): find core qrl chunk correctly
2 parents 3d774f7 + 5a1ca51 commit 39c08bc

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

packages/qwik/src/optimizer/src/manifest.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export function generateManifestFromBundles(
427427
return canonPath(bundle.fileName);
428428
};
429429

430-
let qwikBundleName: string | undefined;
430+
let qwikHandlersName: string | undefined;
431431
// We need to find our QRL exports
432432
const qrlNames = new Set(segments.map((h) => h.name));
433433
for (const outputBundle of Object.values(outputBundles)) {
@@ -475,12 +475,10 @@ export function generateManifestFromBundles(
475475
.map((m) => path.relative(opts.rootDir, m));
476476
if (modulePaths.length > 0) {
477477
bundle.origins = modulePaths;
478-
if (modulePaths.some((m) => /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js/.test(m))) {
478+
if (modulePaths.some((m) => /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(m))) {
479479
manifest.preloader = bundleFileName;
480-
} else if (
481-
modulePaths.some((m) => /[/\\](core|qwik)[/\\]dist[/\\]core(\.prod)?\.[cm]js/.test(m))
482-
) {
483-
qwikBundleName = bundleFileName;
480+
} else if (modulePaths.some((m) => /[/\\](core|qwik)[/\\]handlers\.[cm]js$/.test(m))) {
481+
qwikHandlersName = bundleFileName;
484482
}
485483
}
486484

@@ -507,7 +505,7 @@ export function generateManifestFromBundles(
507505
loc: segment.loc,
508506
};
509507
}
510-
if (qwikBundleName) {
508+
if (qwikHandlersName) {
511509
for (const symbol of extraSymbols) {
512510
manifest.symbols[symbol] = {
513511
origin: 'Qwik core',
@@ -520,7 +518,7 @@ export function generateManifestFromBundles(
520518
parent: null,
521519
loc: [0, 0],
522520
};
523-
manifest.mapping[symbol] = qwikBundleName;
521+
manifest.mapping[symbol] = qwikHandlersName;
524522
}
525523
} else {
526524
console.error('Qwik bundle not found, is Qwik actually used in this project?');

packages/qwik/src/optimizer/src/plugins/plugin.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -949,14 +949,21 @@ export const manifest = ${JSON.stringify(serverManifest)};\n`;
949949
}
950950

951951
function manualChunks(id: string, { getModuleInfo }: Rollup.ManualChunkMeta) {
952-
// The preloader has to stay in a separate chunk if it's a client build
953-
// the vite preload helper must be included or to prevent breaking circular dependencies
954-
if (
955-
opts.target === 'client' &&
956-
(/[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js/.test(id) ||
957-
id === '\0vite/preload-helper.js')
958-
) {
959-
return 'qwik-preloader';
952+
if (opts.target === 'client') {
953+
if (
954+
// The preloader has to stay in a separate chunk if it's a client build
955+
// the vite preload helper must be included or to prevent breaking circular dependencies
956+
/[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(id) ||
957+
id === '\0vite/preload-helper.js'
958+
) {
959+
return 'qwik-preloader';
960+
} else if (
961+
// likewise, core and handlers have to be in the same chunk so there's no import waterfall
962+
id.endsWith('@qwik.dev/core/build') ||
963+
/[/\\](core|qwik)[/\\](handlers|dist[/\\]core(\.prod|\.min)?)\.[cm]js$/.test(id)
964+
) {
965+
return 'qwik-core';
966+
}
960967
}
961968

962969
const module = getModuleInfo(id)!;

0 commit comments

Comments
 (0)