diff --git a/dist/commands/dev/index.js b/dist/commands/dev/index.js index 024ed8b..d8fd4c5 100644 --- a/dist/commands/dev/index.js +++ b/dist/commands/dev/index.js @@ -21,7 +21,9 @@ export default function () { catch (error) { } await bunextInit(); // await allPagesBunBundler(); - await allPagesESBuildContextBundler(); + await allPagesESBuildContextBundler({ + post_build_fn: serverPostBuildFn, + }); await startServer(); }); } diff --git a/dist/functions/bundler/all-pages-esbuild-context-bundler.d.ts b/dist/functions/bundler/all-pages-esbuild-context-bundler.d.ts index b725a35..6ac7707 100644 --- a/dist/functions/bundler/all-pages-esbuild-context-bundler.d.ts +++ b/dist/functions/bundler/all-pages-esbuild-context-bundler.d.ts @@ -1,3 +1,7 @@ -type Params = {}; +type Params = { + post_build_fn?: (params: { + artifacts: any[]; + }) => Promise | void; +}; export default function allPagesESBuildContextBundler(params?: Params): Promise; export {}; diff --git a/dist/functions/bundler/all-pages-esbuild-context-bundler.js b/dist/functions/bundler/all-pages-esbuild-context-bundler.js index 80bb440..5ba3bb8 100644 --- a/dist/functions/bundler/all-pages-esbuild-context-bundler.js +++ b/dist/functions/bundler/all-pages-esbuild-context-bundler.js @@ -62,7 +62,7 @@ export default async function allPagesESBuildContextBundler(params) { artifact; } } - // params?.post_build_fn?.({ artifacts }); + params?.post_build_fn?.({ artifacts }); // writeFileSync( // HYDRATION_DST_DIR_MAP_JSON_FILE, // JSON.stringify(artifacts, null, 4), diff --git a/dist/functions/server/watcher-esbuild-ctx.js b/dist/functions/server/watcher-esbuild-ctx.js index 1274428..8e17075 100644 --- a/dist/functions/server/watcher-esbuild-ctx.js +++ b/dist/functions/server/watcher-esbuild-ctx.js @@ -1,8 +1,10 @@ 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"; import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler"; +import serverPostBuildFn from "./server-post-build-fn"; const { ROOT_DIR } = grabDirNames(); export default async function watcherEsbuildCTX() { const pages_src_watcher = watch(ROOT_DIR, { @@ -67,7 +69,9 @@ async function fullRebuild(params) { global.ROUTER.reload(); await global.BUNDLER_CTX?.dispose(); global.BUNDLER_CTX = undefined; - await allPagesESBuildContextBundler(); + await allPagesESBuildContextBundler({ + post_build_fn: serverPostBuildFn, + }); } catch (error) { log.error(error); diff --git a/package.json b/package.json index d9693a3..cd2d44e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@moduletrace/bunext", "module": "index.ts", "type": "module", - "version": "1.0.31", + "version": "1.0.32", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/src/commands/dev/index.ts b/src/commands/dev/index.ts index dc20607..141ca13 100644 --- a/src/commands/dev/index.ts +++ b/src/commands/dev/index.ts @@ -27,7 +27,9 @@ export default function () { // await allPagesBunBundler(); - await allPagesESBuildContextBundler(); + await allPagesESBuildContextBundler({ + post_build_fn: serverPostBuildFn, + }); await startServer(); }); diff --git a/src/functions/bundler/all-pages-esbuild-context-bundler.ts b/src/functions/bundler/all-pages-esbuild-context-bundler.ts index 0b45054..91bd5e8 100644 --- a/src/functions/bundler/all-pages-esbuild-context-bundler.ts +++ b/src/functions/bundler/all-pages-esbuild-context-bundler.ts @@ -20,7 +20,7 @@ let build_starts = 0; const MAX_BUILD_STARTS = 10; type Params = { - // post_build_fn?: (params: { artifacts: any[] }) => Promise | void; + post_build_fn?: (params: { artifacts: any[] }) => Promise | void; // watch?: boolean; }; @@ -89,7 +89,7 @@ export default async function allPagesESBuildContextBundler(params?: Params) { } } - // params?.post_build_fn?.({ artifacts }); + params?.post_build_fn?.({ artifacts }); // writeFileSync( // HYDRATION_DST_DIR_MAP_JSON_FILE, diff --git a/src/functions/server/watcher-esbuild-ctx.ts b/src/functions/server/watcher-esbuild-ctx.ts index 01d5dd3..63ee32f 100644 --- a/src/functions/server/watcher-esbuild-ctx.ts +++ b/src/functions/server/watcher-esbuild-ctx.ts @@ -1,8 +1,10 @@ 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"; import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler"; +import serverPostBuildFn from "./server-post-build-fn"; const { ROOT_DIR } = grabDirNames(); @@ -90,7 +92,9 @@ async function fullRebuild(params?: { msg?: string }) { await global.BUNDLER_CTX?.dispose(); global.BUNDLER_CTX = undefined; - await allPagesESBuildContextBundler(); + await allPagesESBuildContextBundler({ + post_build_fn: serverPostBuildFn, + }); } catch (error: any) { log.error(error); } finally {