Add SSR bundle minify config
This commit is contained in:
+5
-2
@@ -12,7 +12,8 @@ import { evictDeletedModules } from "../../utils/import-fresh";
|
||||
import { writeFileSync } from "fs";
|
||||
import path from "path";
|
||||
import { log } from "../../utils/log";
|
||||
import { logBuildErrorsOnce, } from "../../utils/build-error-log";
|
||||
import { logBuildErrorsOnce } from "../../utils/build-error-log";
|
||||
import shouldMinifySSR from "../../utils/should-minify-ssr";
|
||||
const { BUNX_CWD_MODULE_CACHE_DIR, BUNX_TMP_DIR } = grabDirNames();
|
||||
// Current virtual entry contents. The SSR virtual plugin resolves its
|
||||
// onLoad contents lazily from this map on every rebuild, so edits to
|
||||
@@ -124,7 +125,9 @@ async function doSSRRebuild(params) {
|
||||
entryPoints,
|
||||
outdir: BUNX_CWD_MODULE_CACHE_DIR,
|
||||
bundle: true,
|
||||
minify: !dev,
|
||||
minify: shouldMinifySSR({
|
||||
minify_ssr_bundle: config.minify_ssr_bundle,
|
||||
}),
|
||||
format: "esm",
|
||||
target: "esnext",
|
||||
platform: "node",
|
||||
|
||||
Vendored
+7
@@ -114,6 +114,13 @@ export type BunextConfig = {
|
||||
* aborted and answered with a 500. Defaults to 30000.
|
||||
*/
|
||||
ssr_render_timeout_ms?: number;
|
||||
/**
|
||||
* Minify the SSR bundle. The SSR output is read off local disk by the
|
||||
* server and is never downloaded by a browser, so minifying it only costs
|
||||
* build memory. Set to `false` on memory-constrained hosts. Never minified
|
||||
* in dev; defaults to `true` in production.
|
||||
*/
|
||||
minify_ssr_bundle?: boolean;
|
||||
};
|
||||
export type BunextConfigMiddlewareParams = {
|
||||
req: Request;
|
||||
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
type Params = {
|
||||
/**
|
||||
* The value of `minify_ssr_bundle` in `bunext.config.ts`
|
||||
* (`global.BUNEXT_CONFIG.minify_ssr_bundle`).
|
||||
*/
|
||||
minify_ssr_bundle?: boolean;
|
||||
};
|
||||
/**
|
||||
* Whether the SSR bundle should be minified.
|
||||
*
|
||||
* The SSR output is read off local disk by the server and is never downloaded
|
||||
* by a browser, so minifying it only costs build memory. Dev is never minified.
|
||||
* In production the bundle is minified unless `minify_ssr_bundle` is explicitly
|
||||
* set to `false` in `bunext.config.ts`.
|
||||
*/
|
||||
export default function shouldMinifySSR(params?: Params): boolean;
|
||||
export {};
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import isDevelopment from "./is-development";
|
||||
/**
|
||||
* Whether the SSR bundle should be minified.
|
||||
*
|
||||
* The SSR output is read off local disk by the server and is never downloaded
|
||||
* by a browser, so minifying it only costs build memory. Dev is never minified.
|
||||
* In production the bundle is minified unless `minify_ssr_bundle` is explicitly
|
||||
* set to `false` in `bunext.config.ts`.
|
||||
*/
|
||||
export default function shouldMinifySSR(params = {}) {
|
||||
if (isDevelopment())
|
||||
return false;
|
||||
return params.minify_ssr_bundle !== false;
|
||||
}
|
||||
Reference in New Issue
Block a user