-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: resolve environment-api build issues for client & CSS #14770
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
Changes from 3 commits
185ec37
3b4d68f
c934f63
c65ae92
5768c75
3fa1331
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import type { | |
| SSRElement, | ||
| SSRResult, | ||
| } from '../../types/public/internal.js'; | ||
| import { VIRTUAL_PAGE_MODULE_ID } from '../../vite-plugin-pages/index.js'; | ||
| import { VIRTUAL_PAGE_MODULE_ID, VIRTUAL_PAGE_RESOLVED_MODULE_ID } from '../../vite-plugin-pages/index.js'; | ||
| import { getVirtualModulePageName } from '../../vite-plugin-pages/util.js'; | ||
| import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js'; | ||
| import type { SSRManifest } from '../app/types.js'; | ||
|
|
@@ -18,8 +18,7 @@ import { createDefaultRoutes } from '../routing/default.js'; | |
| import { findRouteToRewrite } from '../routing/rewrite.js'; | ||
| import { getOutDirWithinCwd } from './common.js'; | ||
| import { type BuildInternals, cssOrder, getPageData, mergeInlineCss } from './internal.js'; | ||
| import type { PageBuildData, SinglePageBuiltModule, StaticBuildOptions } from './types.js'; | ||
| import { i18nHasFallback } from './util.js'; | ||
| import type { SinglePageBuiltModule, StaticBuildOptions } from './types.js'; | ||
|
|
||
| /** | ||
| * The build pipeline is responsible to gather the files emitted by the SSR build and generate the pages by executing these files. | ||
|
|
@@ -141,42 +140,23 @@ export class BuildPipeline extends Pipeline { | |
| * It collects the routes to generate during the build. | ||
| * It returns a map of page information and their relative entry point as a string. | ||
| */ | ||
| retrieveRoutesToGenerate(): Map<PageBuildData, string> { | ||
| const pages = new Map<PageBuildData, string>(); | ||
| retrieveRoutesToGenerate(): Map<RouteData, string> { | ||
| const pages = new Map<RouteData, string>(); | ||
|
|
||
| for (const pageData of this.internals.pagesByKeys.values()) { | ||
| if (routeIsRedirect(pageData.route)) { | ||
| pages.set(pageData, pageData.component); | ||
| } else if ( | ||
| routeIsFallback(pageData.route) && | ||
| (i18nHasFallback(this.config) || | ||
| (routeIsFallback(pageData.route) && pageData.route.route === '/')) | ||
| ) { | ||
|
Comment on lines
-148
to
-154
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we removed essential logic that hasn't been placed anywhere else. Why? Maybe we should update the docs of this method to better align it with the new logic
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now add all routes. This function is quite different because it now operates on the list of routes in the manifest rather than these other maps we used to use. Can you explain what this logic was doing? It's filtering out fallback routes unless i18n has fallback configuration or the route happens to be the base? I was of course trying to be careful to preserve logic as much as possible but given that prerendering works much differently now (being based on the manifest) it was difficult to preserve everything, and I figured as we went through the tests we would fix these kinds of things.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, then maybe it's best if later you can share with us how the prerendering works. Not a blocker |
||
| // The original component is transformed during the first build, so we have to retrieve | ||
| // the actual `.mjs` that was created. | ||
| // During the build, we transform the names of our pages with some weird name, and those weird names become the keys of a map. | ||
| // The values of the map are the actual `.mjs` files that are generated during the build | ||
| for(const { routeData } of this.manifest.routes) { | ||
| // Here, we take the component path and transform it in the virtual module name | ||
| const moduleSpecifier = getVirtualModulePageName(VIRTUAL_PAGE_RESOLVED_MODULE_ID, routeData.component); | ||
| // We retrieve the original JS module | ||
| const filePath = this.internals.entrySpecifierToBundleMap.get(moduleSpecifier); | ||
| if (filePath) { | ||
| // it exists, added it to pages to render, using the file path that we just retrieved | ||
| pages.set(routeData, filePath); | ||
|
|
||
| // Here, we take the component path and transform it in the virtual module name | ||
| const moduleSpecifier = getVirtualModulePageName(VIRTUAL_PAGE_MODULE_ID, pageData.component); | ||
| // We retrieve the original JS module | ||
| const filePath = this.internals.entrySpecifierToBundleMap.get(moduleSpecifier); | ||
| if (filePath) { | ||
| // it exists, added it to pages to render, using the file path that we just retrieved | ||
| pages.set(pageData, filePath); | ||
| } | ||
| } | ||
| // Regular page | ||
| else { | ||
| // TODO: The value doesn't matter anymore. In a future refactor, we can remove it from the Map entirely. | ||
| pages.set(pageData, ''); | ||
| // Populate the cache | ||
| this.#routesByFilePath.set(routeData, filePath); | ||
| } | ||
| } | ||
|
|
||
| for (const [buildData, filePath] of pages.entries()) { | ||
| this.#routesByFilePath.set(buildData.route, filePath); | ||
| } | ||
|
|
||
| return pages; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.