1.4.1: nested pages dirs, CommonJS require of react in client bundles

- Page URL paths are now relative to src/pages. The old greedy
  `.*/pages/` cut mapped src/pages/admin/pages/index.tsx to /index, so
  every page under a nested `pages` directory collided with the home page
  and was never bundled. SSR also tells API routes by URL path now.
- CommonJS `require("react…")` in client bundles (for example
  use-sync-external-store/shim, pulled in by MUI) threw "Dynamic require
  of "react" is not supported" in the browser. Those requires now go
  through a small bundled ESM module that imports the external.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-09 08:37:44 +01:00
co-authored by Claude Opus 5.5
parent 96e392f556
commit 33145bea9e
11 changed files with 246 additions and 29 deletions
@@ -1,3 +1,4 @@
import * as esbuild from "esbuild";
import type { BundlerCTXMap } from "../../types";
type Params = {
post_build_fn?: (params: {
@@ -17,4 +18,13 @@ type Params = {
*/
export declare function isHydrationEntryPage(local_path: string): boolean;
export default function allPagesESBuildContextBundler(params?: Params): Promise<void>;
/**
* CommonJS `require("react")` (e.g. `use-sync-external-store/shim`, pulled
* in by MUI) for a module that is external in ESM output becomes esbuild's
* `__require`, which throws "Dynamic require of "react" is not supported" in
* the browser. Give those requires a small bundled ESM module that imports
* the external instead; esbuild wires `require()` to it.
*/
export declare function externalRequireShim(specifier: string): string;
export declare function forceExternalReact(): esbuild.Plugin;
export {};