Updates
This commit is contained in:
Vendored
-19
@@ -1,25 +1,6 @@
|
|||||||
import { readFileSync } from "fs";
|
|
||||||
import bunextInit from "../../functions/bunext-init";
|
import bunextInit from "../../functions/bunext-init";
|
||||||
import startServer from "../../functions/server/start-server";
|
import startServer from "../../functions/server/start-server";
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
|
||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
const { BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON } = grabDirNames();
|
|
||||||
log.info("Starting production server ...");
|
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 bunextInit();
|
||||||
await startServer();
|
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 DirNames } from "../utils/grab-dir-names";
|
||||||
import type { BuildContext } from "esbuild";
|
import type { BuildContext } from "esbuild";
|
||||||
import grabConstants from "../utils/grab-constants";
|
import grabConstants from "../utils/grab-constants";
|
||||||
import type { FSWatcher } from "fs";
|
import { type FSWatcher } from "fs";
|
||||||
/**
|
/**
|
||||||
* # Declare Global Variables
|
* # Declare Global Variables
|
||||||
*/
|
*/
|
||||||
@@ -49,6 +49,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
type Params = {
|
type Params = {
|
||||||
build_only?: boolean;
|
build_only?: boolean;
|
||||||
|
start?: boolean;
|
||||||
};
|
};
|
||||||
export default function bunextInit(params?: Params): Promise<void>;
|
export default function bunextInit(params?: Params): Promise<void>;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
Vendored
+19
-2
@@ -8,9 +8,27 @@ import serverPostBuildFn from "./server/server-post-build-fn";
|
|||||||
import reactModulesBundler from "./bundler/react-modules-bundler";
|
import reactModulesBundler from "./bundler/react-modules-bundler";
|
||||||
import grabConstants from "../utils/grab-constants";
|
import grabConstants from "../utils/grab-constants";
|
||||||
import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
|
import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
const dirNames = grabDirNames();
|
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) {
|
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;
|
const are_modules_aready_built = global.BUNEXT_BUNDLER_CTX_MAP && global.BUNEXT_SSR_BUNDLER_CTX_MAP;
|
||||||
global.BUNEXT_HMR_CONTROLLERS = [];
|
global.BUNEXT_HMR_CONTROLLERS = [];
|
||||||
if (!global.BUNEXT_BUNDLER_CTX_MAP) {
|
if (!global.BUNEXT_BUNDLER_CTX_MAP) {
|
||||||
@@ -37,7 +55,6 @@ export default async function bunextInit(params) {
|
|||||||
dir: PAGES_DIR,
|
dir: PAGES_DIR,
|
||||||
});
|
});
|
||||||
global.BUNEXT_ROUTER = router;
|
global.BUNEXT_ROUTER = router;
|
||||||
const is_dev = isDevelopment();
|
|
||||||
if (params?.build_only) {
|
if (params?.build_only) {
|
||||||
log.build(`Building Modules ...`);
|
log.build(`Building Modules ...`);
|
||||||
await allPagesESBuildContextBundler({ build_only: params.build_only });
|
await allPagesESBuildContextBundler({ build_only: params.build_only });
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/bunext",
|
"name": "@moduletrace/bunext",
|
||||||
"version": "1.1.8",
|
"version": "1.1.9",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,36 +1,9 @@
|
|||||||
import { readFileSync } from "fs";
|
|
||||||
import bunextInit from "../../functions/bunext-init";
|
import bunextInit from "../../functions/bunext-init";
|
||||||
import startServer from "../../functions/server/start-server";
|
import startServer from "../../functions/server/start-server";
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
|
||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
import type { BundlerCTXMap } from "../../types";
|
|
||||||
|
|
||||||
const { BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON } = grabDirNames();
|
|
||||||
|
|
||||||
log.info("Starting production server ...");
|
log.info("Starting production server ...");
|
||||||
|
|
||||||
try {
|
|
||||||
const bundler_ctx_json = JSON.parse(
|
|
||||||
readFileSync(BUNDLER_CTX_MAP_JSON, "utf-8"),
|
|
||||||
) as { [k: string]: BundlerCTXMap } | undefined;
|
|
||||||
|
|
||||||
if (bundler_ctx_json) {
|
|
||||||
global.BUNEXT_BUNDLER_CTX_MAP = bundler_ctx_json;
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
// 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"),
|
|
||||||
) as { [k: string]: BundlerCTXMap } | undefined;
|
|
||||||
|
|
||||||
if (ssr_bundler_ctx_json) {
|
|
||||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP = ssr_bundler_ctx_json;
|
|
||||||
}
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
await bunextInit();
|
await bunextInit();
|
||||||
|
|
||||||
await startServer();
|
await startServer();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import serverPostBuildFn from "./server/server-post-build-fn";
|
|||||||
import reactModulesBundler from "./bundler/react-modules-bundler";
|
import reactModulesBundler from "./bundler/react-modules-bundler";
|
||||||
import grabConstants from "../utils/grab-constants";
|
import grabConstants from "../utils/grab-constants";
|
||||||
import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
|
import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
|
||||||
import type { FSWatcher } from "fs";
|
import { readFileSync, type FSWatcher } from "fs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* # Declare Global Variables
|
* # Declare Global Variables
|
||||||
@@ -56,13 +56,38 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dirNames = grabDirNames();
|
const dirNames = grabDirNames();
|
||||||
const { PAGES_DIR } = dirNames;
|
const { PAGES_DIR, BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON } = dirNames;
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
build_only?: boolean;
|
build_only?: boolean;
|
||||||
|
start?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function bunextInit(params?: Params) {
|
export default async function bunextInit(params?: Params) {
|
||||||
|
const is_dev = isDevelopment();
|
||||||
|
|
||||||
|
if (!is_dev || params?.start) {
|
||||||
|
try {
|
||||||
|
const bundler_ctx_json = JSON.parse(
|
||||||
|
readFileSync(BUNDLER_CTX_MAP_JSON, "utf-8"),
|
||||||
|
) as { [k: string]: BundlerCTXMap } | undefined;
|
||||||
|
|
||||||
|
if (bundler_ctx_json) {
|
||||||
|
global.BUNEXT_BUNDLER_CTX_MAP = bundler_ctx_json;
|
||||||
|
}
|
||||||
|
} catch (error: any) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ssr_bundler_ctx_json = JSON.parse(
|
||||||
|
readFileSync(SSR_BUNDLER_CTX_MAP_JSON, "utf-8"),
|
||||||
|
) as { [k: string]: BundlerCTXMap } | undefined;
|
||||||
|
|
||||||
|
if (ssr_bundler_ctx_json) {
|
||||||
|
global.BUNEXT_SSR_BUNDLER_CTX_MAP = ssr_bundler_ctx_json;
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
}
|
||||||
|
|
||||||
const are_modules_aready_built =
|
const are_modules_aready_built =
|
||||||
global.BUNEXT_BUNDLER_CTX_MAP && global.BUNEXT_SSR_BUNDLER_CTX_MAP;
|
global.BUNEXT_BUNDLER_CTX_MAP && global.BUNEXT_SSR_BUNDLER_CTX_MAP;
|
||||||
|
|
||||||
@@ -97,8 +122,6 @@ export default async function bunextInit(params?: Params) {
|
|||||||
|
|
||||||
global.BUNEXT_ROUTER = router;
|
global.BUNEXT_ROUTER = router;
|
||||||
|
|
||||||
const is_dev = isDevelopment();
|
|
||||||
|
|
||||||
if (params?.build_only) {
|
if (params?.build_only) {
|
||||||
log.build(`Building Modules ...`);
|
log.build(`Building Modules ...`);
|
||||||
await allPagesESBuildContextBundler({ build_only: params.build_only });
|
await allPagesESBuildContextBundler({ build_only: params.build_only });
|
||||||
|
|||||||
Reference in New Issue
Block a user