Update logs
This commit is contained in:
@@ -11,6 +11,7 @@ import isDevelopment from "../../utils/is-development";
|
||||
import type { BundlerCTXMap } from "../../types";
|
||||
import { execSync } from "child_process";
|
||||
import grabConstants from "../../utils/grab-constants";
|
||||
import { log } from "../../utils/log";
|
||||
|
||||
const { HYDRATION_DST_DIR, PAGES_DIR, HYDRATION_DST_DIR_MAP_JSON_FILE } =
|
||||
grabDirNames();
|
||||
@@ -94,8 +95,10 @@ export default async function allPagesBundler(params?: Params) {
|
||||
const artifactTracker: esbuild.Plugin = {
|
||||
name: "artifact-tracker",
|
||||
setup(build) {
|
||||
let buildStart = 0;
|
||||
|
||||
build.onStart(() => {
|
||||
console.time("build");
|
||||
buildStart = performance.now();
|
||||
});
|
||||
|
||||
build.onEnd((result) => {
|
||||
@@ -150,7 +153,8 @@ export default async function allPagesBundler(params?: Params) {
|
||||
);
|
||||
}
|
||||
|
||||
console.timeEnd("build");
|
||||
const elapsed = (performance.now() - buildStart).toFixed(0);
|
||||
log.success(`Built in ${elapsed}ms`);
|
||||
|
||||
if (params?.exit_after_first_build) {
|
||||
process.exit();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import allPagesBundler from "../bundler/all-pages-bundler";
|
||||
import serverPostBuildFn from "./server-post-build-fn";
|
||||
import { log } from "../../utils/log";
|
||||
|
||||
export default async function rebuildBundler() {
|
||||
try {
|
||||
@@ -13,6 +14,6 @@ export default async function rebuildBundler() {
|
||||
post_build_fn: serverPostBuildFn,
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
log.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import AppNames from "../../utils/grab-app-names";
|
||||
import { log } from "../../utils/log";
|
||||
import allPagesBundler from "../bundler/all-pages-bundler";
|
||||
import serverParamsGen from "./server-params-gen";
|
||||
import watcher from "./watcher";
|
||||
@@ -32,7 +33,7 @@ export default async function startServer(params?: Params) {
|
||||
readFileSync(HYDRATION_DST_DIR_MAP_JSON_FILE, "utf-8"),
|
||||
) as BundlerCTXMap[] | undefined;
|
||||
if (!artifacts?.[0]) {
|
||||
console.error(`Please build first.`);
|
||||
log.error("Please build first.");
|
||||
process.exit(1);
|
||||
}
|
||||
global.BUNDLER_CTX_MAP = artifacts;
|
||||
@@ -45,7 +46,7 @@ export default async function startServer(params?: Params) {
|
||||
|
||||
while (!global.IS_FIRST_BUNDLE_READY) {
|
||||
if (bundle_ready_retries > MAX_BUNDLE_READY_RETRIES) {
|
||||
console.error(`Couldn't grab first bundle for dev environment`);
|
||||
log.error("Couldn't grab first bundle for dev environment");
|
||||
process.exit(1);
|
||||
}
|
||||
bundle_ready_retries++;
|
||||
@@ -56,9 +57,7 @@ export default async function startServer(params?: Params) {
|
||||
|
||||
global.SERVER = server;
|
||||
|
||||
console.log(
|
||||
`${name} Server Running on http://localhost:${server.port} ...`,
|
||||
);
|
||||
log.server(`http://localhost:${server.port}`);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { watch, existsSync } from "fs";
|
||||
import path from "path";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import rebuildBundler from "./rebuild-bundler";
|
||||
import { log } from "../../utils/log";
|
||||
|
||||
const { SRC_DIR } = grabDirNames();
|
||||
|
||||
@@ -25,11 +26,11 @@ export default function watcher() {
|
||||
try {
|
||||
global.RECOMPILING = true;
|
||||
|
||||
console.log(`Page ${action}: ${filename}. Rebuilding ...`);
|
||||
log.watch(`Page ${action}: ${filename}. Rebuilding ...`);
|
||||
|
||||
await rebuildBundler();
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
log.error(error);
|
||||
} finally {
|
||||
global.RECOMPILING = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user