-
Notifications
You must be signed in to change notification settings - Fork 0
fix(transforms): stop the veryfront server barrel from leaking into client chunks #3025
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
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
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,70 @@ | ||
| /** | ||
| * Client/SSR-safe mirror of the `veryfront` root barrel ({@link file://./index.ts}). | ||
| * | ||
| * The root barrel re-exports the server bootstrap surface (`createHandler`, | ||
| * `startServer`, `toNodeHandler`) from `#veryfront/server`. Because the browser | ||
| * and SSR pipelines transform modules per-file (no cross-module tree-shaking), | ||
| * an ESM re-export eagerly loads its source module — so pulling the root barrel | ||
| * into a client chunk drags the entire server graph in, including | ||
| * `src/server/production-server.ts`, which has module top-level `await` and | ||
| * cannot be transformed to the es2020 browser target (→ HTTP 500 on that chunk, | ||
| * which aborts hydration). | ||
| * | ||
| * A client-reachable module doing a *used* value import from the barrel (e.g. | ||
| * `import { getEnv } from "veryfront"`) is not dead-stripped, so it keeps the | ||
| * barrel — and the leak. This barrel exposes exactly the same browser-safe | ||
| * surface minus the server bootstrap functions, which no client/SSR page code | ||
| * ever legitimately calls. The import rewriter redirects `veryfront` to this | ||
| * module for the `browser` and `ssr` targets (see | ||
| * `src/transforms/import-rewriter/strategies/veryfront-strategy.ts`), the same | ||
| * mechanism `veryfront/workflow` already uses. | ||
| * | ||
| * Keep the exports below in sync with {@link file://./index.ts} — everything | ||
| * except the `createHandler` / `startServer` / `toNodeHandler` value export. | ||
| * | ||
| * @module veryfront | ||
| */ | ||
|
|
||
| export { defineConfig, defineConfigWithEnv, mergeConfigs } from "#veryfront/config"; | ||
| export type { VeryfrontConfig } from "#veryfront/config"; | ||
|
|
||
| export { getEnv } from "#veryfront/platform"; | ||
|
|
||
| // NOTE: the server bootstrap value export (`createHandler`, `startServer`, | ||
| // `toNodeHandler` from "#veryfront/server") is intentionally omitted here — it | ||
| // is server-only and pulls production-server.ts (top-level await) into client | ||
| // chunks. Types are erased at transform time, so re-exporting them is inert. | ||
| export type { StartServerOptions, VeryfrontHandler, VeryfrontServer } from "#veryfront/server"; | ||
|
|
||
| export { | ||
| badRequest, | ||
| forbidden, | ||
| json, | ||
| notFound as apiNotFound, | ||
| redirect as apiRedirect, | ||
| serverError, | ||
| unauthorized, | ||
| } from "#veryfront/routing"; | ||
| export type { APIContext, APIHandler, APIResponse, APIRoute } from "#veryfront/routing"; | ||
|
|
||
| export { notFound, redirect } from "#veryfront/data"; | ||
| export type { | ||
| DataContext, | ||
| InferGetServerDataProps, | ||
| PageWithData, | ||
| StaticPathsResult, | ||
| } from "#veryfront/data"; | ||
|
|
||
| export type { MDXFrontmatter, PageContext } from "#veryfront/types"; | ||
|
|
||
| export { | ||
| CommonSchemas, | ||
| createValidatedHandler, | ||
| createValidationError, | ||
| INPUT_VALIDATION_FAILED, | ||
| parseFormData, | ||
| parseJsonBody, | ||
| parseQueryParams, | ||
| sanitizeData, | ||
| } from "#veryfront/security"; | ||
| export type { ValidatedHandlerConfig, ValidatedHandlerFunction } from "#veryfront/security"; |
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
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.