Conversation
|
@meteorlxy This is completed, but we should expected the following things to be preloaded as well:
But these are theme concept, and I am not comming up with any idea how to solve this gracefully. Any ideas for probably a new hook for themes? |
Coverage Report for CI Build 30081445920Coverage increased (+0.8%) to 73.948%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
| let candidateFiles: string[] | ||
|
|
||
| return prefetchFiles | ||
| if (shouldPrefetch === 'as-needed') { |
There was a problem hiding this comment.
Maybe extract this snippet to bundlerutils?
There was a problem hiding this comment.
How? The data structures are different accross bundlers, and rely on bundler types.
There was a problem hiding this comment.
L33-L45 is identical and duplicate across 3(4) files
Co-authored-by: Xinyu Liu <meteor.lxy@foxmail.com>
Co-authored-by: Xinyu Liu <meteor.lxy@foxmail.com>
There was a problem hiding this comment.
Pull request overview
This PR changes the default prefetch strategy to an “as-needed” mode that only emits prefetch hints for chunks belonging to pages linked from the current page, enabled via a new per-page chunk-file mapping built during bundler output generation.
Changes:
- Change
shouldPrefetchdefault fromtrueto'as-needed'and extend the option type accordingly. - Add bundlerutils helpers (
createPageChunkFilesMap,resolveLinkRoutePath,resolveLinkedPageChunkFiles) plus unit tests to support linked-page chunk discovery. - Extend webpack/vite build pipelines to compute and pass a
PageChunkFilesMapinto prefetch rendering; add E2E coverage for resource-hint behavior.
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Updates workspace lock to reflect new workspace dependency usage. |
| packages/core/tests/app/resolveAppOptions.spec.ts | Updates expectation for new shouldPrefetch default. |
| packages/core/src/types/app/options.ts | Extends shouldPrefetch type and updates default value. |
| packages/core/src/app/resolveAppOptions.ts | Sets new default shouldPrefetch = 'as-needed'. |
| packages/core/src/app/prepare/prepareRoutes.ts | Exports resolvePageRedirects for reuse in mapping logic. |
| packages/bundlerutils/package.json | Adds @vuepress/markdown dependency for MarkdownLink typing. |
| packages/bundlerutils/src/build/index.ts | Re-exports new mapping/link-resolution utilities and types. |
| packages/bundlerutils/src/build/types.ts | Introduces PageChunkFilesMap type. |
| packages/bundlerutils/src/build/resolveLinkRoutePath.ts | Normalizes markdown links into route paths for map lookups. |
| packages/bundlerutils/src/build/resolveLinkedPageChunkFiles.ts | Computes linked pages’ chunk files for “as-needed” prefetch. |
| packages/bundlerutils/src/build/createPageChunkFilesMap.ts | Builds route/redirect → chunk-files map using resolvePageRedirects. |
| packages/bundlerutils/tests/build/resolveLinkRoutePath.spec.ts | Unit tests for link → route normalization. |
| packages/bundlerutils/tests/build/resolveLinkedPageChunkFiles.spec.ts | Unit tests for linked-page chunk resolution and deduping. |
| packages/bundlerutils/tests/build/createPageChunkFilesMap.spec.ts | Unit tests for mapping final and inferred/redirect route paths to chunks. |
| packages/bundler-webpack/src/build/types.ts | Extends client manifest to include chunk-name → output-files mapping. |
| packages/bundler-webpack/src/build/createClientPlugin.ts | Produces clientManifest.chunks mapping from webpack stats chunks. |
| packages/bundler-webpack/src/build/renderPagePrefetchLinks.ts | Implements 'as-needed' prefetch selection using linked-page chunks. |
| packages/bundler-webpack/src/build/renderPage.ts | Passes page and pageChunkFilesMap into prefetch rendering. |
| packages/bundler-webpack/src/build/build.ts | Builds pageChunkFilesMap from manifest chunk mapping and passes through. |
| packages/bundler-vite/src/build/renderPagePrefetchLinks.ts | Implements 'as-needed' prefetch selection for rolldown dynamic imports. |
| packages/bundler-vite/src/build/renderPage.ts | Passes page and pageChunkFilesMap into prefetch rendering. |
| packages/bundler-vite/src/build/build.ts | Builds pageChunkFilesMap using resolvePageChunkFiles and passes through. |
| e2e/tests/resource-hints.spec.ts | Adds E2E assertions that only linked pages’ resources are prefetched (not preloaded), including virtual pages. |
| e2e/docs/.vuepress/config.ts | Creates a virtual source page during initialization for E2E coverage. |
| e2e/docs/resource-hints/source.md | Adds a source page linking to linked/permalink pages for E2E. |
| e2e/docs/resource-hints/linked.md | Adds linked page fixture. |
| e2e/docs/resource-hints/linked-permalink.md | Adds linked page fixture with permalink frontmatter. |
| e2e/docs/resource-hints/unlinked.md | Adds unlinked page fixture used to compute differences in E2E. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.