Bugfix. Fix SSR pages filters. Remove dedicated API bundler, use SSR bundler for pages and api routes.

This commit is contained in:
2026-04-12 06:48:10 +01:00
parent 532d0d6b56
commit 84d490b189
21 changed files with 131 additions and 138 deletions
+33 -31
View File
@@ -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();
}