From 3749441885611eaf21314ce35b29dca960b74738 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Mon, 16 Sep 2024 10:27:36 +0200 Subject: [PATCH] rename files to kebab-case --- builder/src/build/build-worker/index.ts | 20 ++++++++++--------- .../{copyTemplates.ts => copy-templates.ts} | 2 +- .../{patchRequire.ts => patch-require.ts} | 0 .../{patchUrl.ts => patch-url.ts} | 0 ...valManifest.ts => inline-eval-manifest.ts} | 2 +- ...eNextRequire.ts => inline-next-require.ts} | 2 +- .../{patchFindDir.ts => patch-find-dir.ts} | 2 +- .../{patchReadFile.ts => patch-read-file.ts} | 2 +- .../{wranglerDeps.ts => wrangler-deps.ts} | 2 +- builder/src/build/index.ts | 2 +- .../src/{nextjsPaths.ts => nextjs-paths.ts} | 0 11 files changed, 18 insertions(+), 16 deletions(-) rename builder/src/build/build-worker/patches/investigated/{copyTemplates.ts => copy-templates.ts} (90%) rename builder/src/build/build-worker/patches/investigated/{patchRequire.ts => patch-require.ts} (100%) rename builder/src/build/build-worker/patches/investigated/{patchUrl.ts => patch-url.ts} (100%) rename builder/src/build/build-worker/patches/to-investigate/{inlineEvalManifest.ts => inline-eval-manifest.ts} (96%) rename builder/src/build/build-worker/patches/to-investigate/{inlineNextRequire.ts => inline-next-require.ts} (96%) rename builder/src/build/build-worker/patches/to-investigate/{patchFindDir.ts => patch-find-dir.ts} (94%) rename builder/src/build/build-worker/patches/to-investigate/{patchReadFile.ts => patch-read-file.ts} (96%) rename builder/src/build/build-worker/patches/to-investigate/{wranglerDeps.ts => wrangler-deps.ts} (97%) rename builder/src/{nextjsPaths.ts => nextjs-paths.ts} (100%) diff --git a/builder/src/build/build-worker/index.ts b/builder/src/build/build-worker/index.ts index be2d2f0..5ff7b63 100644 --- a/builder/src/build/build-worker/index.ts +++ b/builder/src/build/build-worker/index.ts @@ -1,17 +1,17 @@ -import { NextjsAppPaths } from "../../nextjsPaths"; +import { NextjsAppPaths } from "../../nextjs-paths"; import { build, Plugin } from "esbuild"; import { readdirSync, readFileSync, writeFileSync } from "node:fs"; import { cp, readFile, writeFile } from "node:fs/promises"; -import { patchRequire } from "./patches/investigated/patchRequire"; -import { patchUrl } from "./patches/investigated/patchUrl"; -import { copyTemplates } from "./patches/investigated/copyTemplates"; +import { patchRequire } from "./patches/investigated/patch-require"; +import { patchUrl } from "./patches/investigated/patch-url"; +import { copyTemplates } from "./patches/investigated/copy-templates"; -import { patchReadFile } from "./patches/to-investigate/patchReadFile"; -import { patchFindDir } from "./patches/to-investigate/patchFindDir"; -import { inlineNextRequire } from "./patches/to-investigate/inlineNextRequire"; -import { inlineEvalManifest } from "./patches/to-investigate/inlineEvalManifest"; -import { patchWranglerDeps } from "./patches/to-investigate/wranglerDeps"; +import { patchReadFile } from "./patches/to-investigate/patch-read-file"; +import { patchFindDir } from "./patches/to-investigate/patch-find-dir"; +import { inlineNextRequire } from "./patches/to-investigate/inline-next-require"; +import { inlineEvalManifest } from "./patches/to-investigate/inline-eval-manifest"; +import { patchWranglerDeps } from "./patches/to-investigate/wrangler-deps"; /** * Using the Next.js build output in the `.next` directory builds a workerd compatible output @@ -92,6 +92,8 @@ export async function buildWorker( globalThis.__dirname ??= ""; // Do not crash on cache not supported +// https://github.com/cloudflare/workerd/pull/2434 +// compatibility flag "cache_option_enabled" -> does not support "force-cache" let isPatchedAlready = globalThis.fetch.__nextPatched; const curFetch = globalThis.fetch; globalThis.fetch = (input, init) => { diff --git a/builder/src/build/build-worker/patches/investigated/copyTemplates.ts b/builder/src/build/build-worker/patches/investigated/copy-templates.ts similarity index 90% rename from builder/src/build/build-worker/patches/investigated/copyTemplates.ts rename to builder/src/build/build-worker/patches/investigated/copy-templates.ts index 73ce990..93424ca 100644 --- a/builder/src/build/build-worker/patches/investigated/copyTemplates.ts +++ b/builder/src/build/build-worker/patches/investigated/copy-templates.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import { NextjsAppPaths } from "../../../../nextjsPaths"; +import { NextjsAppPaths } from "../../../../nextjs-paths"; import { cpSync } from "node:fs"; /** diff --git a/builder/src/build/build-worker/patches/investigated/patchRequire.ts b/builder/src/build/build-worker/patches/investigated/patch-require.ts similarity index 100% rename from builder/src/build/build-worker/patches/investigated/patchRequire.ts rename to builder/src/build/build-worker/patches/investigated/patch-require.ts diff --git a/builder/src/build/build-worker/patches/investigated/patchUrl.ts b/builder/src/build/build-worker/patches/investigated/patch-url.ts similarity index 100% rename from builder/src/build/build-worker/patches/investigated/patchUrl.ts rename to builder/src/build/build-worker/patches/investigated/patch-url.ts diff --git a/builder/src/build/build-worker/patches/to-investigate/inlineEvalManifest.ts b/builder/src/build/build-worker/patches/to-investigate/inline-eval-manifest.ts similarity index 96% rename from builder/src/build/build-worker/patches/to-investigate/inlineEvalManifest.ts rename to builder/src/build/build-worker/patches/to-investigate/inline-eval-manifest.ts index c56bb25..d49794d 100644 --- a/builder/src/build/build-worker/patches/to-investigate/inlineEvalManifest.ts +++ b/builder/src/build/build-worker/patches/to-investigate/inline-eval-manifest.ts @@ -1,5 +1,5 @@ import { globSync } from "glob"; -import { NextjsAppPaths } from "../../../../nextjsPaths"; +import { NextjsAppPaths } from "../../../../nextjs-paths"; /** * `evalManifest` relies on readFileSync so we need to patch the function so that it instead returns the content of the manifest files diff --git a/builder/src/build/build-worker/patches/to-investigate/inlineNextRequire.ts b/builder/src/build/build-worker/patches/to-investigate/inline-next-require.ts similarity index 96% rename from builder/src/build/build-worker/patches/to-investigate/inlineNextRequire.ts rename to builder/src/build/build-worker/patches/to-investigate/inline-next-require.ts index 135947a..44221f3 100644 --- a/builder/src/build/build-worker/patches/to-investigate/inlineNextRequire.ts +++ b/builder/src/build/build-worker/patches/to-investigate/inline-next-require.ts @@ -1,5 +1,5 @@ import { readFileSync, existsSync } from "node:fs"; -import { NextjsAppPaths } from "../../../../nextjsPaths"; +import { NextjsAppPaths } from "../../../../nextjs-paths"; /** * The following avoid various Next.js specific files `require`d at runtime since we can just read diff --git a/builder/src/build/build-worker/patches/to-investigate/patchFindDir.ts b/builder/src/build/build-worker/patches/to-investigate/patch-find-dir.ts similarity index 94% rename from builder/src/build/build-worker/patches/to-investigate/patchFindDir.ts rename to builder/src/build/build-worker/patches/to-investigate/patch-find-dir.ts index 2ce88ad..9b4f3c4 100644 --- a/builder/src/build/build-worker/patches/to-investigate/patchFindDir.ts +++ b/builder/src/build/build-worker/patches/to-investigate/patch-find-dir.ts @@ -1,4 +1,4 @@ -import { NextjsAppPaths } from "../../../../nextjsPaths"; +import { NextjsAppPaths } from "../../../../nextjs-paths"; import { existsSync } from "node:fs"; /** diff --git a/builder/src/build/build-worker/patches/to-investigate/patchReadFile.ts b/builder/src/build/build-worker/patches/to-investigate/patch-read-file.ts similarity index 96% rename from builder/src/build/build-worker/patches/to-investigate/patchReadFile.ts rename to builder/src/build/build-worker/patches/to-investigate/patch-read-file.ts index cb2fdce..35c6e14 100644 --- a/builder/src/build/build-worker/patches/to-investigate/patchReadFile.ts +++ b/builder/src/build/build-worker/patches/to-investigate/patch-read-file.ts @@ -1,6 +1,6 @@ import { readFileSync } from "node:fs"; import { globSync } from "glob"; -import { NextjsAppPaths } from "../../../../nextjsPaths"; +import { NextjsAppPaths } from "../../../../nextjs-paths"; export function patchReadFile( code: string, diff --git a/builder/src/build/build-worker/patches/to-investigate/wranglerDeps.ts b/builder/src/build/build-worker/patches/to-investigate/wrangler-deps.ts similarity index 97% rename from builder/src/build/build-worker/patches/to-investigate/wranglerDeps.ts rename to builder/src/build/build-worker/patches/to-investigate/wrangler-deps.ts index 0fd554f..ac87516 100644 --- a/builder/src/build/build-worker/patches/to-investigate/wranglerDeps.ts +++ b/builder/src/build/build-worker/patches/to-investigate/wrangler-deps.ts @@ -1,6 +1,6 @@ import path from "node:path"; import fs, { writeFileSync } from "node:fs"; -import { NextjsAppPaths } from "../../../../nextjsPaths"; +import { NextjsAppPaths } from "../../../../nextjs-paths"; export function patchWranglerDeps(paths: NextjsAppPaths) { console.log("# patchWranglerDeps"); diff --git a/builder/src/build/index.ts b/builder/src/build/index.ts index 0f3f212..19801be 100644 --- a/builder/src/build/index.ts +++ b/builder/src/build/index.ts @@ -1,7 +1,7 @@ import { rm } from "node:fs/promises"; import { buildNextjsApp } from "./build-next-app"; import { buildWorker } from "./build-worker"; -import { getNextjsAppPaths } from "../nextjsPaths"; +import { getNextjsAppPaths } from "../nextjs-paths"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { cpSync, rmSync } from "node:fs"; diff --git a/builder/src/nextjsPaths.ts b/builder/src/nextjs-paths.ts similarity index 100% rename from builder/src/nextjsPaths.ts rename to builder/src/nextjs-paths.ts