Fix server component stale caching. Add server components to SSR bundler
This commit is contained in:
Vendored
+1
@@ -2,6 +2,7 @@ import type { PageFiles } from "../types";
|
||||
type Params = {
|
||||
exclude_api?: boolean;
|
||||
api_only?: boolean;
|
||||
include_server?: boolean;
|
||||
};
|
||||
export default function grabAllPages(params?: Params): PageFiles[];
|
||||
export {};
|
||||
|
||||
Vendored
+13
-5
@@ -5,7 +5,10 @@ import AppNames from "./grab-app-names";
|
||||
import checkExcludedPatterns from "./check-excluded-patterns";
|
||||
export default function grabAllPages(params) {
|
||||
const { PAGES_DIR } = grabDirNames();
|
||||
const pages = grabPageDirRecursively({ page_dir: PAGES_DIR });
|
||||
const pages = grabPageDirRecursively({
|
||||
page_dir: PAGES_DIR,
|
||||
include_server: params?.include_server,
|
||||
});
|
||||
if (params?.exclude_api) {
|
||||
return pages.filter((p) => !Boolean(p.url_path.startsWith("/api/")));
|
||||
}
|
||||
@@ -14,7 +17,7 @@ export default function grabAllPages(params) {
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
function grabPageDirRecursively({ page_dir }) {
|
||||
function grabPageDirRecursively({ page_dir, include_server, }) {
|
||||
const pages = readdirSync(page_dir);
|
||||
const pages_files = [];
|
||||
const root_pages_file = grabPageFileObject({ file_path: `` });
|
||||
@@ -28,13 +31,17 @@ function grabPageDirRecursively({ page_dir }) {
|
||||
if (!existsSync(full_page_path) || !page_name) {
|
||||
continue;
|
||||
}
|
||||
if (page.match(new RegExp(`${AppNames["RootPagesComponentName"]}`))) {
|
||||
if (page.match(new RegExp(`${AppNames["RootPagesComponentName"]}`)) &&
|
||||
!page_name.match(/\.server\.tsx?/)) {
|
||||
continue;
|
||||
}
|
||||
if (checkExcludedPatterns({ path: full_page_path })) {
|
||||
const is_page_excluded = checkExcludedPatterns({
|
||||
path: full_page_path,
|
||||
});
|
||||
if (is_page_excluded) {
|
||||
continue;
|
||||
}
|
||||
if (page_name.match(/\.server\.tsx?/)) {
|
||||
if (page_name.match(/\.server\.tsx?/) && !include_server) {
|
||||
continue;
|
||||
}
|
||||
const page_stat = statSync(full_page_path);
|
||||
@@ -43,6 +50,7 @@ function grabPageDirRecursively({ page_dir }) {
|
||||
continue;
|
||||
const new_page_files = grabPageDirRecursively({
|
||||
page_dir: full_page_path,
|
||||
include_server,
|
||||
});
|
||||
pages_files.push(...new_page_files);
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export default function writeLogs(log: any): void;
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import { writeFileSync } from "fs";
|
||||
import grabDirNames from "./grab-dir-names";
|
||||
import path from "path";
|
||||
const { BUNX_LOGS_DIR } = grabDirNames();
|
||||
export default function writeLogs(log) {
|
||||
try {
|
||||
const now = Date.now();
|
||||
let new_log_name = `${now}`;
|
||||
let log_content = log.toString();
|
||||
try {
|
||||
const json = JSON.stringify(log, null, 4);
|
||||
new_log_name += `.json`;
|
||||
log_content = json;
|
||||
}
|
||||
catch (error) {
|
||||
new_log_name += `.log`;
|
||||
}
|
||||
const log_path = path.join(BUNX_LOGS_DIR, new_log_name);
|
||||
writeFileSync(log_path, log_content);
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
Reference in New Issue
Block a user