From 84d490b189da0d90301132e15df68d489872341c Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Sun, 12 Apr 2026 06:48:10 +0100 Subject: [PATCH] Bugfix. Fix SSR pages filters. Remove dedicated API bundler, use SSR bundler for pages and api routes. --- .../bundler/api-routes-context-bundler.js | 64 +++++++++--------- .../bundler/build-on-start-error-handler.js | 2 +- .../bundler/pages-ssr-context-bundler.js | 3 +- .../api-routes-ctx-artifact-tracker.js | 26 ++++---- .../plugins/esbuild-ctx-artifact-tracker.js | 6 -- .../plugins/ssr-ctx-artifact-tracker.js | 7 +- dist/functions/bunext-init.d.ts | 4 -- dist/functions/bunext-init.js | 2 +- dist/functions/server/handle-routes.js | 4 +- dist/utils/grab-all-pages.js | 10 +-- package.json | 2 +- .../bundler/api-routes-context-bundler.ts | 66 +++++++++---------- .../bundler/build-on-start-error-handler.ts | 2 +- .../bundler/pages-ssr-context-bundler.ts | 3 +- .../api-routes-ctx-artifact-tracker.ts | 30 ++++----- .../plugins/esbuild-ctx-artifact-tracker.ts | 7 +- .../plugins/ssr-ctx-artifact-tracker.ts | 8 ++- src/functions/bunext-init.ts | 6 +- src/functions/server/handle-routes.ts | 4 +- src/utils/check-excluded-patterns.ts | 2 - src/utils/grab-all-pages.ts | 11 +--- 21 files changed, 131 insertions(+), 138 deletions(-) diff --git a/dist/functions/bundler/api-routes-context-bundler.js b/dist/functions/bundler/api-routes-context-bundler.js index c1813ce..de9c794 100644 --- a/dist/functions/bundler/api-routes-context-bundler.js +++ b/dist/functions/bundler/api-routes-context-bundler.js @@ -8,35 +8,37 @@ const { BUNX_CWD_MODULE_CACHE_DIR } = grabDirNames(); export default async function apiRoutesContextBundler() { const pages = grabAllPages({ api_only: true }); const dev = isDevelopment(); - if (global.API_ROUTES_BUNDLER_CTX) { - await global.API_ROUTES_BUNDLER_CTX.dispose(); - global.API_ROUTES_BUNDLER_CTX = undefined; - } - global.API_ROUTES_BUNDLER_CTX = await esbuild.context({ - entryPoints: pages.map((p) => p.local_path), - outdir: BUNX_CWD_MODULE_CACHE_DIR, - bundle: true, - minify: !dev, - format: "esm", - target: "esnext", - platform: "node", - define: { - "process.env.NODE_ENV": JSON.stringify(dev ? "development" : "production"), - }, - entryNames: "api/[dir]/[hash]", - metafile: true, - plugins: [ - tailwindEsbuildPlugin, - apiRoutesCTXArtifactTracker({ pages }), - ], - jsx: "automatic", - external: [ - "react", - "react-dom", - "react/jsx-runtime", - "react/jsx-dev-runtime", - "bun:*", - ], - }); - await global.API_ROUTES_BUNDLER_CTX.rebuild(); + // if (global.API_ROUTES_BUNDLER_CTX) { + // await global.API_ROUTES_BUNDLER_CTX.dispose(); + // global.API_ROUTES_BUNDLER_CTX = undefined; + // } + // global.API_ROUTES_BUNDLER_CTX = await esbuild.context({ + // entryPoints: pages.map((p) => p.local_path), + // outdir: BUNX_CWD_MODULE_CACHE_DIR, + // bundle: true, + // minify: !dev, + // format: "esm", + // target: "esnext", + // platform: "node", + // define: { + // "process.env.NODE_ENV": JSON.stringify( + // dev ? "development" : "production", + // ), + // }, + // entryNames: "api/[dir]/[hash]", + // metafile: true, + // plugins: [ + // tailwindEsbuildPlugin, + // apiRoutesCTXArtifactTracker({ pages }), + // ], + // jsx: "automatic", + // external: [ + // "react", + // "react-dom", + // "react/jsx-runtime", + // "react/jsx-dev-runtime", + // "bun:*", + // ], + // }); + // await global.API_ROUTES_BUNDLER_CTX.rebuild(); } diff --git a/dist/functions/bundler/build-on-start-error-handler.js b/dist/functions/bundler/build-on-start-error-handler.js index 1b2ca02..7b2adc0 100644 --- a/dist/functions/bundler/build-on-start-error-handler.js +++ b/dist/functions/bundler/build-on-start-error-handler.js @@ -5,7 +5,7 @@ export default async function buildOnstartErrorHandler(params) { global.BUNDLER_CTX_DISPOSED = true; global.RECOMPILING = false; global.IS_SERVER_COMPONENT = false; - await Promise.all([ + Promise.all([ global.SSR_BUNDLER_CTX?.dispose(), global.BUNDLER_CTX?.dispose(), ]); diff --git a/dist/functions/bundler/pages-ssr-context-bundler.js b/dist/functions/bundler/pages-ssr-context-bundler.js index 060895f..67d1dc9 100644 --- a/dist/functions/bundler/pages-ssr-context-bundler.js +++ b/dist/functions/bundler/pages-ssr-context-bundler.js @@ -9,7 +9,7 @@ import ssrVirtualFilesPlugin from "./plugins/ssr-virtual-files-plugin"; import ssrCTXArtifactTracker from "./plugins/ssr-ctx-artifact-tracker"; const { BUNX_CWD_MODULE_CACHE_DIR } = grabDirNames(); export default async function pagesSSRContextBundler(params) { - const pages = grabAllPages({ exclude_api: true }); + const pages = grabAllPages(); const dev = isDevelopment(); if (global.SSR_BUNDLER_CTX) { await global.SSR_BUNDLER_CTX.dispose(); @@ -61,6 +61,7 @@ export default async function pagesSSRContextBundler(params) { "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime", + "bun:*", ], // logLevel: "silent", }); diff --git a/dist/functions/bundler/plugins/api-routes-ctx-artifact-tracker.js b/dist/functions/bundler/plugins/api-routes-ctx-artifact-tracker.js index 917ee07..cad8ccc 100644 --- a/dist/functions/bundler/plugins/api-routes-ctx-artifact-tracker.js +++ b/dist/functions/bundler/plugins/api-routes-ctx-artifact-tracker.js @@ -44,17 +44,21 @@ export default function apiRoutesCTXArtifactTracker({ pages }) { url_path, }; }); - if (artifacts?.[0] && artifacts.length > 0) { - for (let i = 0; i < artifacts.length; i++) { - const artifact = artifacts[i]; - if (artifact?.local_path && - global.API_ROUTES_BUNDLER_CTX_MAP) { - global.API_ROUTES_BUNDLER_CTX_MAP[artifact.local_path] = artifact; - } - } - } - // const elapsed = (performance.now() - build_start).toFixed(0); - // log.success(`API Routes [Built] in ${elapsed}ms`); + // if (artifacts?.[0] && artifacts.length > 0) { + // for (let i = 0; i < artifacts.length; i++) { + // const artifact = artifacts[i]; + // if ( + // artifact?.local_path && + // global.API_ROUTES_BUNDLER_CTX_MAP + // ) { + // global.API_ROUTES_BUNDLER_CTX_MAP[ + // artifact.local_path + // ] = artifact; + // } + // } + // } + const elapsed = (performance.now() - build_start).toFixed(0); + log.success(`API Routes [Built] in ${elapsed}ms`); }); }, }; diff --git a/dist/functions/bundler/plugins/esbuild-ctx-artifact-tracker.js b/dist/functions/bundler/plugins/esbuild-ctx-artifact-tracker.js index 38775a9..09d216e 100644 --- a/dist/functions/bundler/plugins/esbuild-ctx-artifact-tracker.js +++ b/dist/functions/bundler/plugins/esbuild-ctx-artifact-tracker.js @@ -48,12 +48,6 @@ export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn, else { pagesSSRContextBundler(); } - if (global.API_ROUTES_BUNDLER_CTX) { - global.API_ROUTES_BUNDLER_CTX.rebuild(); - } - else { - apiRoutesContextBundler(); - } }); }, }; diff --git a/dist/functions/bundler/plugins/ssr-ctx-artifact-tracker.js b/dist/functions/bundler/plugins/ssr-ctx-artifact-tracker.js index 08fc1b9..612e49f 100644 --- a/dist/functions/bundler/plugins/ssr-ctx-artifact-tracker.js +++ b/dist/functions/bundler/plugins/ssr-ctx-artifact-tracker.js @@ -1,6 +1,7 @@ import {} from "esbuild"; import grabArtifactsFromBundledResults from "../grab-artifacts-from-bundled-result"; import buildOnstartErrorHandler from "../build-on-start-error-handler"; +import { log } from "../../../utils/log"; let build_start = 0; let build_starts = 0; const MAX_BUILD_STARTS = 2; @@ -34,7 +35,11 @@ export default function ssrCTXArtifactTracker({ entryToPage, post_build_fn, }) { artifact; } } - post_build_fn?.({ artifacts }); + // post_build_fn?.({ artifacts }); + // const elapsed = (performance.now() - build_start).toFixed( + // 0, + // ); + // log.success(`SSR [Built] in ${elapsed}ms`); } }); }, diff --git a/dist/functions/bunext-init.d.ts b/dist/functions/bunext-init.d.ts index 37039f1..dc2f987 100644 --- a/dist/functions/bunext-init.d.ts +++ b/dist/functions/bunext-init.d.ts @@ -23,9 +23,6 @@ declare global { var SSR_BUNDLER_CTX_MAP: { [k: string]: BundlerCTXMap; }; - var API_ROUTES_BUNDLER_CTX_MAP: { - [k: string]: BundlerCTXMap; - }; var BUNDLER_REBUILDS: 0; var PAGES_SRC_WATCHER: FSWatcher | undefined; var CURRENT_VERSION: string | undefined; @@ -34,7 +31,6 @@ declare global { var SKIPPED_BROWSER_MODULES: Set; var BUNDLER_CTX: BuildContext | undefined; var SSR_BUNDLER_CTX: BuildContext | undefined; - var API_ROUTES_BUNDLER_CTX: BuildContext | undefined; var DIR_NAMES: ReturnType; var REACT_IMPORTS_MAP: { imports: Record; diff --git a/dist/functions/bunext-init.js b/dist/functions/bunext-init.js index cbeca15..fc65285 100644 --- a/dist/functions/bunext-init.js +++ b/dist/functions/bunext-init.js @@ -15,7 +15,7 @@ export default async function bunextInit() { global.HMR_CONTROLLERS = []; global.BUNDLER_CTX_MAP = {}; global.SSR_BUNDLER_CTX_MAP = {}; - global.API_ROUTES_BUNDLER_CTX_MAP = {}; + // global.API_ROUTES_BUNDLER_CTX_MAP = {}; global.BUNDLER_REBUILDS = 0; global.REBUILD_RETRIES = 0; global.PAGE_FILES = []; diff --git a/dist/functions/server/handle-routes.js b/dist/functions/server/handle-routes.js index 00fdda6..181198d 100644 --- a/dist/functions/server/handle-routes.js +++ b/dist/functions/server/handle-routes.js @@ -30,8 +30,8 @@ export default async function ({ req }) { }); let module; const now = Date.now(); - if (is_dev && global.API_ROUTES_BUNDLER_CTX_MAP?.[match.filePath]?.path) { - const target_import = path.join(ROOT_DIR, global.API_ROUTES_BUNDLER_CTX_MAP[match.filePath].path); + if (is_dev && global.SSR_BUNDLER_CTX_MAP?.[match.filePath]?.path) { + const target_import = path.join(ROOT_DIR, global.SSR_BUNDLER_CTX_MAP[match.filePath].path); module = await import(`${target_import}?t=${now}`); } else { diff --git a/dist/utils/grab-all-pages.js b/dist/utils/grab-all-pages.js index 49e8f2c..658fec8 100644 --- a/dist/utils/grab-all-pages.js +++ b/dist/utils/grab-all-pages.js @@ -2,7 +2,6 @@ import { existsSync, readdirSync, statSync } from "fs"; import grabDirNames from "./grab-dir-names"; import path from "path"; import AppNames from "./grab-app-names"; -import pagePathTransform from "./page-path-transform"; import checkExcludedPatterns from "./check-excluded-patterns"; export default function grabAllPages(params) { const { PAGES_DIR } = grabDirNames(); @@ -32,18 +31,15 @@ function grabPageDirRecursively({ page_dir }) { if (page.match(new RegExp(`${AppNames["RootPagesComponentName"]}`))) { continue; } - if (checkExcludedPatterns({ path: page })) { + if (checkExcludedPatterns({ path: full_page_path })) { continue; } - if (page.match(/\/api\//)) { - continue; - } - if (page_name.split(".").length > 2) { + if (page_name.match(/\.server\.tsx?/)) { continue; } const page_stat = statSync(full_page_path); if (page_stat.isDirectory()) { - if (checkExcludedPatterns({ path: page })) + if (checkExcludedPatterns({ path: full_page_path })) continue; const new_page_files = grabPageDirRecursively({ page_dir: full_page_path, diff --git a/package.json b/package.json index 5205281..9c1a7ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/bunext", - "version": "1.0.75", + "version": "1.0.76", "main": "dist/index.js", "module": "index.ts", "dependencies": { diff --git a/src/functions/bundler/api-routes-context-bundler.ts b/src/functions/bundler/api-routes-context-bundler.ts index b8d6d7d..3eddfa6 100644 --- a/src/functions/bundler/api-routes-context-bundler.ts +++ b/src/functions/bundler/api-routes-context-bundler.ts @@ -11,39 +11,39 @@ export default async function apiRoutesContextBundler() { const pages = grabAllPages({ api_only: true }); const dev = isDevelopment(); - if (global.API_ROUTES_BUNDLER_CTX) { - await global.API_ROUTES_BUNDLER_CTX.dispose(); - global.API_ROUTES_BUNDLER_CTX = undefined; - } + // if (global.API_ROUTES_BUNDLER_CTX) { + // await global.API_ROUTES_BUNDLER_CTX.dispose(); + // global.API_ROUTES_BUNDLER_CTX = undefined; + // } - global.API_ROUTES_BUNDLER_CTX = await esbuild.context({ - entryPoints: pages.map((p) => p.local_path), - outdir: BUNX_CWD_MODULE_CACHE_DIR, - bundle: true, - minify: !dev, - format: "esm", - target: "esnext", - platform: "node", - define: { - "process.env.NODE_ENV": JSON.stringify( - dev ? "development" : "production", - ), - }, - entryNames: "api/[dir]/[hash]", - metafile: true, - plugins: [ - tailwindEsbuildPlugin, - apiRoutesCTXArtifactTracker({ pages }), - ], - jsx: "automatic", - external: [ - "react", - "react-dom", - "react/jsx-runtime", - "react/jsx-dev-runtime", - "bun:*", - ], - }); + // global.API_ROUTES_BUNDLER_CTX = await esbuild.context({ + // entryPoints: pages.map((p) => p.local_path), + // outdir: BUNX_CWD_MODULE_CACHE_DIR, + // bundle: true, + // minify: !dev, + // format: "esm", + // target: "esnext", + // platform: "node", + // define: { + // "process.env.NODE_ENV": JSON.stringify( + // dev ? "development" : "production", + // ), + // }, + // entryNames: "api/[dir]/[hash]", + // metafile: true, + // plugins: [ + // tailwindEsbuildPlugin, + // apiRoutesCTXArtifactTracker({ pages }), + // ], + // jsx: "automatic", + // external: [ + // "react", + // "react-dom", + // "react/jsx-runtime", + // "react/jsx-dev-runtime", + // "bun:*", + // ], + // }); - await global.API_ROUTES_BUNDLER_CTX.rebuild(); + // await global.API_ROUTES_BUNDLER_CTX.rebuild(); } diff --git a/src/functions/bundler/build-on-start-error-handler.ts b/src/functions/bundler/build-on-start-error-handler.ts index 88674e5..04c7024 100644 --- a/src/functions/bundler/build-on-start-error-handler.ts +++ b/src/functions/bundler/build-on-start-error-handler.ts @@ -11,7 +11,7 @@ export default async function buildOnstartErrorHandler(params?: Params) { global.RECOMPILING = false; global.IS_SERVER_COMPONENT = false; - await Promise.all([ + Promise.all([ global.SSR_BUNDLER_CTX?.dispose(), global.BUNDLER_CTX?.dispose(), ]); diff --git a/src/functions/bundler/pages-ssr-context-bundler.ts b/src/functions/bundler/pages-ssr-context-bundler.ts index cc7abc5..7318a50 100644 --- a/src/functions/bundler/pages-ssr-context-bundler.ts +++ b/src/functions/bundler/pages-ssr-context-bundler.ts @@ -16,7 +16,7 @@ type Params = { }; export default async function pagesSSRContextBundler(params?: Params) { - const pages = grabAllPages({ exclude_api: true }); + const pages = grabAllPages(); const dev = isDevelopment(); if (global.SSR_BUNDLER_CTX) { @@ -77,6 +77,7 @@ export default async function pagesSSRContextBundler(params?: Params) { "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime", + "bun:*", ], // logLevel: "silent", }); diff --git a/src/functions/bundler/plugins/api-routes-ctx-artifact-tracker.ts b/src/functions/bundler/plugins/api-routes-ctx-artifact-tracker.ts index 288d3c0..5b2b275 100644 --- a/src/functions/bundler/plugins/api-routes-ctx-artifact-tracker.ts +++ b/src/functions/bundler/plugins/api-routes-ctx-artifact-tracker.ts @@ -66,22 +66,22 @@ export default function apiRoutesCTXArtifactTracker({ pages }: Params) { }; }); - if (artifacts?.[0] && artifacts.length > 0) { - for (let i = 0; i < artifacts.length; i++) { - const artifact = artifacts[i]; - if ( - artifact?.local_path && - global.API_ROUTES_BUNDLER_CTX_MAP - ) { - global.API_ROUTES_BUNDLER_CTX_MAP[ - artifact.local_path - ] = artifact; - } - } - } + // if (artifacts?.[0] && artifacts.length > 0) { + // for (let i = 0; i < artifacts.length; i++) { + // const artifact = artifacts[i]; + // if ( + // artifact?.local_path && + // global.API_ROUTES_BUNDLER_CTX_MAP + // ) { + // global.API_ROUTES_BUNDLER_CTX_MAP[ + // artifact.local_path + // ] = artifact; + // } + // } + // } - // const elapsed = (performance.now() - build_start).toFixed(0); - // log.success(`API Routes [Built] in ${elapsed}ms`); + const elapsed = (performance.now() - build_start).toFixed(0); + log.success(`API Routes [Built] in ${elapsed}ms`); }); }, }; diff --git a/src/functions/bundler/plugins/esbuild-ctx-artifact-tracker.ts b/src/functions/bundler/plugins/esbuild-ctx-artifact-tracker.ts index 8f42269..97df0dd 100644 --- a/src/functions/bundler/plugins/esbuild-ctx-artifact-tracker.ts +++ b/src/functions/bundler/plugins/esbuild-ctx-artifact-tracker.ts @@ -31,6 +31,7 @@ export default function esbuildCTXArtifactTracker({ build.onStart(async () => { build_starts++; build_start = performance.now(); + if (build_starts == MAX_BUILD_STARTS) { await buildOnstartErrorHandler(); } @@ -74,12 +75,6 @@ export default function esbuildCTXArtifactTracker({ } else { pagesSSRContextBundler(); } - - if (global.API_ROUTES_BUNDLER_CTX) { - global.API_ROUTES_BUNDLER_CTX.rebuild(); - } else { - apiRoutesContextBundler(); - } }); }, }; diff --git a/src/functions/bundler/plugins/ssr-ctx-artifact-tracker.ts b/src/functions/bundler/plugins/ssr-ctx-artifact-tracker.ts index 4c300d8..591967e 100644 --- a/src/functions/bundler/plugins/ssr-ctx-artifact-tracker.ts +++ b/src/functions/bundler/plugins/ssr-ctx-artifact-tracker.ts @@ -2,6 +2,7 @@ import { type Plugin } from "esbuild"; import type { PageFiles } from "../../../types"; import grabArtifactsFromBundledResults from "../grab-artifacts-from-bundled-result"; import buildOnstartErrorHandler from "../build-on-start-error-handler"; +import { log } from "../../../utils/log"; let build_start = 0; let build_starts = 0; @@ -56,7 +57,12 @@ export default function ssrCTXArtifactTracker({ } } - post_build_fn?.({ artifacts }); + // post_build_fn?.({ artifacts }); + + // const elapsed = (performance.now() - build_start).toFixed( + // 0, + // ); + // log.success(`SSR [Built] in ${elapsed}ms`); } }); }, diff --git a/src/functions/bunext-init.ts b/src/functions/bunext-init.ts index 16c9941..dc24186 100644 --- a/src/functions/bunext-init.ts +++ b/src/functions/bunext-init.ts @@ -33,7 +33,7 @@ declare global { var LAST_BUILD_TIME: number; var BUNDLER_CTX_MAP: { [k: string]: BundlerCTXMap }; var SSR_BUNDLER_CTX_MAP: { [k: string]: BundlerCTXMap }; - var API_ROUTES_BUNDLER_CTX_MAP: { [k: string]: BundlerCTXMap }; + // var API_ROUTES_BUNDLER_CTX_MAP: { [k: string]: BundlerCTXMap }; var BUNDLER_REBUILDS: 0; var PAGES_SRC_WATCHER: FSWatcher | undefined; var CURRENT_VERSION: string | undefined; @@ -42,7 +42,7 @@ declare global { var SKIPPED_BROWSER_MODULES: Set; var BUNDLER_CTX: BuildContext | undefined; var SSR_BUNDLER_CTX: BuildContext | undefined; - var API_ROUTES_BUNDLER_CTX: BuildContext | undefined; + // var API_ROUTES_BUNDLER_CTX: BuildContext | undefined; var DIR_NAMES: ReturnType; var REACT_IMPORTS_MAP: { imports: Record }; var REACT_DOM_SERVER: any; @@ -60,7 +60,7 @@ export default async function bunextInit() { global.HMR_CONTROLLERS = []; global.BUNDLER_CTX_MAP = {}; global.SSR_BUNDLER_CTX_MAP = {}; - global.API_ROUTES_BUNDLER_CTX_MAP = {}; + // global.API_ROUTES_BUNDLER_CTX_MAP = {}; global.BUNDLER_REBUILDS = 0; global.REBUILD_RETRIES = 0; global.PAGE_FILES = []; diff --git a/src/functions/server/handle-routes.ts b/src/functions/server/handle-routes.ts index 21228e8..a2c85c9 100644 --- a/src/functions/server/handle-routes.ts +++ b/src/functions/server/handle-routes.ts @@ -52,10 +52,10 @@ export default async function ({ req }: Params): Promise { let module: any; const now = Date.now(); - if (is_dev && global.API_ROUTES_BUNDLER_CTX_MAP?.[match.filePath]?.path) { + if (is_dev && global.SSR_BUNDLER_CTX_MAP?.[match.filePath]?.path) { const target_import = path.join( ROOT_DIR, - global.API_ROUTES_BUNDLER_CTX_MAP[match.filePath].path, + global.SSR_BUNDLER_CTX_MAP[match.filePath].path, ); module = await import(`${target_import}?t=${now}`); diff --git a/src/utils/check-excluded-patterns.ts b/src/utils/check-excluded-patterns.ts index 049e4e3..cfb9c89 100644 --- a/src/utils/check-excluded-patterns.ts +++ b/src/utils/check-excluded-patterns.ts @@ -1,5 +1,3 @@ -import type { APIResponseObject } from "../types"; - type Params = { path: string; }; diff --git a/src/utils/grab-all-pages.ts b/src/utils/grab-all-pages.ts index 6c45e68..15310cb 100644 --- a/src/utils/grab-all-pages.ts +++ b/src/utils/grab-all-pages.ts @@ -3,7 +3,6 @@ import grabDirNames from "./grab-dir-names"; import path from "path"; import type { PageFiles } from "../types"; import AppNames from "./grab-app-names"; -import pagePathTransform from "./page-path-transform"; import checkExcludedPatterns from "./check-excluded-patterns"; type Params = { @@ -50,22 +49,18 @@ function grabPageDirRecursively({ page_dir }: { page_dir: string }) { continue; } - if (checkExcludedPatterns({ path: page })) { + if (checkExcludedPatterns({ path: full_page_path })) { continue; } - if (page.match(/\/api\//)) { - continue; - } - - if (page_name.split(".").length > 2) { + if (page_name.match(/\.server\.tsx?/)) { continue; } const page_stat = statSync(full_page_path); if (page_stat.isDirectory()) { - if (checkExcludedPatterns({ path: page })) continue; + if (checkExcludedPatterns({ path: full_page_path })) continue; const new_page_files = grabPageDirRecursively({ page_dir: full_page_path, });