Bugfix. Fix esbuild post build function for HMR
This commit is contained in:
parent
47c262392c
commit
99b319f5af
4
dist/commands/dev/index.js
vendored
4
dist/commands/dev/index.js
vendored
@ -21,7 +21,9 @@ export default function () {
|
|||||||
catch (error) { }
|
catch (error) { }
|
||||||
await bunextInit();
|
await bunextInit();
|
||||||
// await allPagesBunBundler();
|
// await allPagesBunBundler();
|
||||||
await allPagesESBuildContextBundler();
|
await allPagesESBuildContextBundler({
|
||||||
|
post_build_fn: serverPostBuildFn,
|
||||||
|
});
|
||||||
await startServer();
|
await startServer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
type Params = {};
|
type Params = {
|
||||||
|
post_build_fn?: (params: {
|
||||||
|
artifacts: any[];
|
||||||
|
}) => Promise<void> | void;
|
||||||
|
};
|
||||||
export default function allPagesESBuildContextBundler(params?: Params): Promise<void>;
|
export default function allPagesESBuildContextBundler(params?: Params): Promise<void>;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@ -62,7 +62,7 @@ export default async function allPagesESBuildContextBundler(params) {
|
|||||||
artifact;
|
artifact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// params?.post_build_fn?.({ artifacts });
|
params?.post_build_fn?.({ artifacts });
|
||||||
// writeFileSync(
|
// writeFileSync(
|
||||||
// HYDRATION_DST_DIR_MAP_JSON_FILE,
|
// HYDRATION_DST_DIR_MAP_JSON_FILE,
|
||||||
// JSON.stringify(artifacts, null, 4),
|
// JSON.stringify(artifacts, null, 4),
|
||||||
|
|||||||
6
dist/functions/server/watcher-esbuild-ctx.js
vendored
6
dist/functions/server/watcher-esbuild-ctx.js
vendored
@ -1,8 +1,10 @@
|
|||||||
import { watch, existsSync } from "fs";
|
import { watch, existsSync } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
|
import rebuildBundler from "./rebuild-bundler";
|
||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
||||||
|
import serverPostBuildFn from "./server-post-build-fn";
|
||||||
const { ROOT_DIR } = grabDirNames();
|
const { ROOT_DIR } = grabDirNames();
|
||||||
export default async function watcherEsbuildCTX() {
|
export default async function watcherEsbuildCTX() {
|
||||||
const pages_src_watcher = watch(ROOT_DIR, {
|
const pages_src_watcher = watch(ROOT_DIR, {
|
||||||
@ -67,7 +69,9 @@ async function fullRebuild(params) {
|
|||||||
global.ROUTER.reload();
|
global.ROUTER.reload();
|
||||||
await global.BUNDLER_CTX?.dispose();
|
await global.BUNDLER_CTX?.dispose();
|
||||||
global.BUNDLER_CTX = undefined;
|
global.BUNDLER_CTX = undefined;
|
||||||
await allPagesESBuildContextBundler();
|
await allPagesESBuildContextBundler({
|
||||||
|
post_build_fn: serverPostBuildFn,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "@moduletrace/bunext",
|
"name": "@moduletrace/bunext",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.0.31",
|
"version": "1.0.32",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@ -27,7 +27,9 @@ export default function () {
|
|||||||
|
|
||||||
// await allPagesBunBundler();
|
// await allPagesBunBundler();
|
||||||
|
|
||||||
await allPagesESBuildContextBundler();
|
await allPagesESBuildContextBundler({
|
||||||
|
post_build_fn: serverPostBuildFn,
|
||||||
|
});
|
||||||
|
|
||||||
await startServer();
|
await startServer();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@ let build_starts = 0;
|
|||||||
const MAX_BUILD_STARTS = 10;
|
const MAX_BUILD_STARTS = 10;
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
// post_build_fn?: (params: { artifacts: any[] }) => Promise<void> | void;
|
post_build_fn?: (params: { artifacts: any[] }) => Promise<void> | void;
|
||||||
// watch?: boolean;
|
// watch?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ export default async function allPagesESBuildContextBundler(params?: Params) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// params?.post_build_fn?.({ artifacts });
|
params?.post_build_fn?.({ artifacts });
|
||||||
|
|
||||||
// writeFileSync(
|
// writeFileSync(
|
||||||
// HYDRATION_DST_DIR_MAP_JSON_FILE,
|
// HYDRATION_DST_DIR_MAP_JSON_FILE,
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import { watch, existsSync } from "fs";
|
import { watch, existsSync } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
|
import rebuildBundler from "./rebuild-bundler";
|
||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
||||||
|
import serverPostBuildFn from "./server-post-build-fn";
|
||||||
|
|
||||||
const { ROOT_DIR } = grabDirNames();
|
const { ROOT_DIR } = grabDirNames();
|
||||||
|
|
||||||
@ -90,7 +92,9 @@ async function fullRebuild(params?: { msg?: string }) {
|
|||||||
await global.BUNDLER_CTX?.dispose();
|
await global.BUNDLER_CTX?.dispose();
|
||||||
global.BUNDLER_CTX = undefined;
|
global.BUNDLER_CTX = undefined;
|
||||||
|
|
||||||
await allPagesESBuildContextBundler();
|
await allPagesESBuildContextBundler({
|
||||||
|
post_build_fn: serverPostBuildFn,
|
||||||
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user