-
Notifications
You must be signed in to change notification settings - Fork 69
fix: root the vendor specifier scan in the module graph #1401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dfc1215
fix: root the vendor specifier scan in the module graph
vivek7405 747936a
test: keep the round-2 preload counterfactual discriminating
vivek7405 5abc966
fix: keep instrumentation-client a browser entry on the pin path
vivek7405 4c3c031
fix: resolve instrumentation-client in buildRouteTable, not per caller
vivek7405 b6bff61
docs: drop the orphaned instrumentation-client comment in dev.js
vivek7405 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * The browser-bound ENTRY files of an app: every module the client boot can | ||
| * import directly. | ||
| * | ||
| * Feeding these to `reachableFromEntries` produces webjs's equivalent of | ||
| * Next.js's bundler-produced page manifest, derived lazily on the first | ||
| * request (and re-derived on every rebuild) instead of at compile time. The | ||
| * dev server uses that closure as an authorization gate on its source-file | ||
| * branch: in-set is served (subject to the `.server.{js,ts}` stub guardrail), | ||
| * out-of-set 404s. Feeding them to `reachableBareSpecifiers` produces the | ||
| * vendor importmap, which is why this half is its own module: the CLI-side | ||
| * vendor paths (`pinAll`, `webjs doctor`) root at exactly the entries the gate | ||
| * does, without booting a server. | ||
| * | ||
| * Entries: | ||
| * - page / layout (both re-run on the client for hydration) | ||
| * - the error / loading / not-found / forbidden / unauthorized boundaries | ||
| * - the two root-only boundaries (global-error, global-not-found) | ||
| * - instrumentation-client (imported first in the boot) | ||
| * - every discovered component (a `static lazy` one is fetched by the lazy | ||
| * loader rather than imported by a page, so the component scan is an entry | ||
| * source in its own right) | ||
| * | ||
| * NOT entries, because the browser never fetches them as a module: | ||
| * - route.{js,ts} (API handlers) and middleware.{js,ts} | ||
| * - metadata routes (sitemap.js, robots.js, manifest.js, …) | ||
| * - .server.{js,ts} files (the browser gets a stub, not the source) | ||
| */ | ||
|
|
||
| /** | ||
| * Components are passed in (rather than rescanned) so the caller can share one | ||
| * scan with `primeComponentRegistry`, saving a full appDir walk per analysis. | ||
| * | ||
| * @param {Awaited<ReturnType<typeof import('./router.js').buildRouteTable>>} routeTable | ||
| * @param {Awaited<ReturnType<typeof import('./component-scanner.js').scanComponents>>} components | ||
| * @returns {Set<string>} | ||
| */ | ||
| export function browserEntryFiles(routeTable, components) { | ||
| /** @type {Set<string>} */ | ||
| const entries = new Set(); | ||
| for (const page of routeTable.pages) { | ||
| if (page.file) entries.add(page.file); | ||
| for (const f of page.layouts || []) entries.add(f); | ||
| for (const f of page.errors || []) entries.add(f); | ||
| for (const f of page.loadings || []) entries.add(f); | ||
| for (const f of page.forbiddens || []) entries.add(f); | ||
| for (const f of page.unauthorizeds || []) entries.add(f); | ||
| } | ||
| if (routeTable.notFound) entries.add(routeTable.notFound); | ||
| if (routeTable.notFounds) { | ||
| for (const f of routeTable.notFounds.values()) entries.add(f); | ||
| } | ||
| if (routeTable.globalError) entries.add(routeTable.globalError); | ||
| if (routeTable.globalNotFound) entries.add(routeTable.globalNotFound); | ||
| // instrumentation-client is browser-bound (imported first in the boot), so it | ||
| // must be servable through the gate. | ||
| if (routeTable.instrumentationClient) entries.add(routeTable.instrumentationClient); | ||
| // Lazy components live in the registry but no page imports their | ||
| // class directly; the lazy-loader fetches their module URLs on | ||
| // viewport entry. Add every discovered component file as an entry so | ||
| // the graph walk covers both eager and lazy paths. | ||
| for (const c of components) entries.add(c.file); | ||
| return entries; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.