Updates
This commit is contained in:
Vendored
-19
@@ -1,25 +1,6 @@
|
||||
import { readFileSync } from "fs";
|
||||
import bunextInit from "../../functions/bunext-init";
|
||||
import startServer from "../../functions/server/start-server";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import { log } from "../../utils/log";
|
||||
const { BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON } = grabDirNames();
|
||||
log.info("Starting production server ...");
|
||||
try {
|
||||
const bundler_ctx_json = JSON.parse(readFileSync(BUNDLER_CTX_MAP_JSON, "utf-8"));
|
||||
if (bundler_ctx_json) {
|
||||
global.BUNEXT_BUNDLER_CTX_MAP = bundler_ctx_json;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// log.error(`Couldn't set global bundler CTX map: ${error.message}`);
|
||||
}
|
||||
try {
|
||||
const ssr_bundler_ctx_json = JSON.parse(readFileSync(SSR_BUNDLER_CTX_MAP_JSON, "utf-8"));
|
||||
if (ssr_bundler_ctx_json) {
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP = ssr_bundler_ctx_json;
|
||||
}
|
||||
}
|
||||
catch (error) { }
|
||||
await bunextInit();
|
||||
await startServer();
|
||||
|
||||
Vendored
+2
-1
@@ -3,7 +3,7 @@ import type { FileSystemRouter, Server } from "bun";
|
||||
import { type DirNames } from "../utils/grab-dir-names";
|
||||
import type { BuildContext } from "esbuild";
|
||||
import grabConstants from "../utils/grab-constants";
|
||||
import type { FSWatcher } from "fs";
|
||||
import { type FSWatcher } from "fs";
|
||||
/**
|
||||
* # Declare Global Variables
|
||||
*/
|
||||
@@ -49,6 +49,7 @@ declare global {
|
||||
}
|
||||
type Params = {
|
||||
build_only?: boolean;
|
||||
start?: boolean;
|
||||
};
|
||||
export default function bunextInit(params?: Params): Promise<void>;
|
||||
export {};
|
||||
|
||||
Vendored
+19
-2
@@ -8,9 +8,27 @@ import serverPostBuildFn from "./server/server-post-build-fn";
|
||||
import reactModulesBundler from "./bundler/react-modules-bundler";
|
||||
import grabConstants from "../utils/grab-constants";
|
||||
import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
|
||||
import { readFileSync } from "fs";
|
||||
const dirNames = grabDirNames();
|
||||
const { PAGES_DIR } = dirNames;
|
||||
const { PAGES_DIR, BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON } = dirNames;
|
||||
export default async function bunextInit(params) {
|
||||
const is_dev = isDevelopment();
|
||||
if (!is_dev || params?.start) {
|
||||
try {
|
||||
const bundler_ctx_json = JSON.parse(readFileSync(BUNDLER_CTX_MAP_JSON, "utf-8"));
|
||||
if (bundler_ctx_json) {
|
||||
global.BUNEXT_BUNDLER_CTX_MAP = bundler_ctx_json;
|
||||
}
|
||||
}
|
||||
catch (error) { }
|
||||
try {
|
||||
const ssr_bundler_ctx_json = JSON.parse(readFileSync(SSR_BUNDLER_CTX_MAP_JSON, "utf-8"));
|
||||
if (ssr_bundler_ctx_json) {
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP = ssr_bundler_ctx_json;
|
||||
}
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
const are_modules_aready_built = global.BUNEXT_BUNDLER_CTX_MAP && global.BUNEXT_SSR_BUNDLER_CTX_MAP;
|
||||
global.BUNEXT_HMR_CONTROLLERS = [];
|
||||
if (!global.BUNEXT_BUNDLER_CTX_MAP) {
|
||||
@@ -37,7 +55,6 @@ export default async function bunextInit(params) {
|
||||
dir: PAGES_DIR,
|
||||
});
|
||||
global.BUNEXT_ROUTER = router;
|
||||
const is_dev = isDevelopment();
|
||||
if (params?.build_only) {
|
||||
log.build(`Building Modules ...`);
|
||||
await allPagesESBuildContextBundler({ build_only: params.build_only });
|
||||
|
||||
Reference in New Issue
Block a user