Refactor artifacts to use relative directory for build step and retrieval
This commit is contained in:
@@ -9,7 +9,8 @@ import { cpSync, existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
||||
import fullRebuild from "../../server/full-rebuild";
|
||||
import path from "path";
|
||||
import cleanupLogsDirs from "../../cleanup-logs-dir";
|
||||
const { BUNX_BUNDLER_ERROR_EXIT_FILE, BUNX_ERROR_LOGS_DIR, BUNDLER_CTX_MAP_JSON, SSR_BUNDLER_CTX_MAP_JSON, } = grabDirNames();
|
||||
import grabRelativePath from "../../../utils/grab-relative-path";
|
||||
const { BUNX_BUNDLER_ERROR_EXIT_FILE, BUNX_ERROR_LOGS_DIR, ROOT_DIR } = grabDirNames();
|
||||
let build_start = 0;
|
||||
const MAX_BUILD_STARTS = 2;
|
||||
export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn, build_only, }) {
|
||||
@@ -53,8 +54,9 @@ export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn,
|
||||
const artifact = artifacts[i];
|
||||
if (artifact?.local_path &&
|
||||
global.BUNEXT_BUNDLER_CTX_MAP) {
|
||||
global.BUNEXT_BUNDLER_CTX_MAP[artifact.local_path] =
|
||||
_.merge(global.BUNEXT_BUNDLER_CTX_MAP[artifact.local_path], artifact);
|
||||
const relative_path = grabRelativePath(artifact.local_path);
|
||||
global.BUNEXT_BUNDLER_CTX_MAP[relative_path] =
|
||||
_.merge(global.BUNEXT_BUNDLER_CTX_MAP[relative_path], { ...artifact, local_path: relative_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ import grabArtifactsFromBundledResults from "../grab-artifacts-from-bundled-resu
|
||||
import { writeFileSync } from "fs";
|
||||
import path from "path";
|
||||
import grabDirNames from "../../../utils/grab-dir-names";
|
||||
import grabRelativePath from "../../../utils/grab-relative-path";
|
||||
let build_start = 0;
|
||||
let build_starts = 0;
|
||||
const MAX_BUILD_STARTS = 2;
|
||||
const { BUNX_TMP_DIR } = grabDirNames();
|
||||
const { BUNX_TMP_DIR, ROOT_DIR } = grabDirNames();
|
||||
export default function ssrCTXArtifactTracker({ entryToPage, post_build_fn, }) {
|
||||
const artifactTracker = {
|
||||
name: "ssr-artifact-tracker",
|
||||
@@ -44,7 +45,11 @@ export default function ssrCTXArtifactTracker({ entryToPage, post_build_fn, }) {
|
||||
const artifact = artifacts[i];
|
||||
if (artifact?.local_path &&
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP) {
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP[artifact.local_path] = artifact;
|
||||
const relative_path = grabRelativePath(artifact.local_path);
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP[relative_path] = {
|
||||
...artifact,
|
||||
local_path: relative_path,
|
||||
};
|
||||
}
|
||||
}
|
||||
// post_build_fn?.({ artifacts });
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import type { BundlerCTXMap } from "../../types";
|
||||
type Params = {
|
||||
artifacts: BundlerCTXMap[];
|
||||
page_file_paths?: string[];
|
||||
};
|
||||
export default function recordArtifacts({ artifacts, page_file_paths, }: Params): Promise<void>;
|
||||
export {};
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import _ from "lodash";
|
||||
const { HYDRATION_DST_DIR_MAP_JSON_FILE } = grabDirNames();
|
||||
export default async function recordArtifacts({ artifacts, page_file_paths, }) {
|
||||
const artifacts_map = {};
|
||||
for (const artifact of artifacts) {
|
||||
if (artifact?.local_path) {
|
||||
artifacts_map[artifact.local_path] = artifact;
|
||||
}
|
||||
}
|
||||
if (global.BUNEXT_BUNDLER_CTX_MAP) {
|
||||
global.BUNEXT_BUNDLER_CTX_MAP = _.merge(global.BUNEXT_BUNDLER_CTX_MAP, artifacts_map);
|
||||
}
|
||||
// await Bun.write(
|
||||
// HYDRATION_DST_DIR_MAP_JSON_FILE,
|
||||
// JSON.stringify(artifacts_map, null, 4),
|
||||
// );
|
||||
}
|
||||
Reference in New Issue
Block a user