Refactor artifacts to use relative directory for build step and retrieval
This commit is contained in:
+5
-30
@@ -5,6 +5,7 @@ import isDevelopment from "../../utils/is-development";
|
||||
import _ from "lodash";
|
||||
import path from "path";
|
||||
import grabDirNames from "../../utils/grab-dir-names";
|
||||
import grabRelativePath from "../../utils/grab-relative-path";
|
||||
const { ROOT_DIR } = grabDirNames();
|
||||
export default async function ({ req }) {
|
||||
const url = new URL(req.url);
|
||||
@@ -30,8 +31,10 @@ export default async function ({ req }) {
|
||||
});
|
||||
let module;
|
||||
const now = Date.now();
|
||||
if (is_dev && global.BUNEXT_SSR_BUNDLER_CTX_MAP?.[match.filePath]?.path) {
|
||||
const target_import = path.join(ROOT_DIR, global.BUNEXT_SSR_BUNDLER_CTX_MAP[match.filePath].path);
|
||||
const relative_match_path = grabRelativePath(match.filePath);
|
||||
if (is_dev &&
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP?.[relative_match_path]?.path) {
|
||||
const target_import = path.join(ROOT_DIR, global.BUNEXT_SSR_BUNDLER_CTX_MAP[relative_match_path].path);
|
||||
module = await import(`${target_import}?t=${now}`);
|
||||
}
|
||||
else {
|
||||
@@ -99,31 +102,3 @@ export default async function ({ req }) {
|
||||
}
|
||||
return Response.json({ err: `Route handler error` });
|
||||
}
|
||||
// const relative_path = match.filePath.replace(API_DIR, "");
|
||||
// const relative_module_js_file = relative_path.replace(/\.tsx?$/, ".js");
|
||||
// const bun_module_file = path.join(
|
||||
// BUNX_CWD_MODULE_CACHE_DIR,
|
||||
// "api",
|
||||
// relative_module_js_file,
|
||||
// );
|
||||
// if (existsSync(bun_module_file)) {
|
||||
// module = await import(`${bun_module_file}?t=${now}`);
|
||||
// } else {
|
||||
// const import_path = is_dev
|
||||
// ? `${match.filePath}?t=${now}`
|
||||
// : match.filePath;
|
||||
// module = await import(import_path);
|
||||
// }
|
||||
// if (is_dev) {
|
||||
// const tmp_path = `${match.filePath}.${now}${AppData["BunextTmpFileExt"]}`;
|
||||
// cpSync(match.filePath, tmp_path);
|
||||
// module = await import(`${tmp_path}?t=${now}`);
|
||||
// try {
|
||||
// unlinkSync(tmp_path);
|
||||
// } catch (error) {}
|
||||
// } else {
|
||||
// // const import_path = is_dev ? `${match.filePath}?t=${now}` : match.filePath;
|
||||
// module = await import(match.filePath);
|
||||
// }
|
||||
// const import_path = is_dev ? `${match.filePath}?t=${now}` : match.filePath;
|
||||
// module = await import(import_path);
|
||||
|
||||
Reference in New Issue
Block a user