diff --git a/packages/cloudflare/src/cli/build/patches/to-investigate/inline-eval-manifest.ts b/packages/cloudflare/src/cli/build/patches/to-investigate/inline-eval-manifest.ts index 4fde5ed7f..510b0ce7c 100644 --- a/packages/cloudflare/src/cli/build/patches/to-investigate/inline-eval-manifest.ts +++ b/packages/cloudflare/src/cli/build/patches/to-investigate/inline-eval-manifest.ts @@ -14,7 +14,7 @@ import { normalizePath } from "../../utils/index.js"; */ export function inlineEvalManifest(code: string, config: Config): string { const manifestJss = globSync( - normalizePath(join(config.paths.output.standaloneAppDotNext, "**", "*_client-reference-manifest.js")) + normalizePath(join(config.paths.output.standaloneAppDotNext, "**/*_client-reference-manifest.js")) ).map((file) => normalizePath(file).replace(normalizePath(config.paths.output.standaloneApp) + posix.sep, "") ); diff --git a/packages/cloudflare/src/cli/build/patches/to-investigate/patch-read-file.ts b/packages/cloudflare/src/cli/build/patches/to-investigate/patch-read-file.ts index 7a26f717a..6a2dd3680 100644 --- a/packages/cloudflare/src/cli/build/patches/to-investigate/patch-read-file.ts +++ b/packages/cloudflare/src/cli/build/patches/to-investigate/patch-read-file.ts @@ -24,7 +24,7 @@ export function patchLoadManifest(code: string, config: Config): string { // (source: https://github.com/vercel/next.js/blob/15aeb92e/packages/next/src/server/load-manifest.ts#L34-L56) // Note: we could/should probably just patch readFileSync here or something! const manifestJsons = globSync( - normalizePath(join(config.paths.output.standaloneAppDotNext, "**", "*-manifest.json")) + normalizePath(join(config.paths.output.standaloneAppDotNext, "**/*-manifest.json")) ).map((file) => normalizePath(file).replace(normalizePath(config.paths.output.standaloneApp) + posix.sep, "") ); diff --git a/packages/cloudflare/src/cli/build/patches/to-investigate/wrangler-deps.ts b/packages/cloudflare/src/cli/build/patches/to-investigate/wrangler-deps.ts index 11810823a..f12b9dcea 100644 --- a/packages/cloudflare/src/cli/build/patches/to-investigate/wrangler-deps.ts +++ b/packages/cloudflare/src/cli/build/patches/to-investigate/wrangler-deps.ts @@ -17,7 +17,7 @@ export function patchWranglerDeps(config: Config) { // [alias] // # critters is `require`d from `pages.runtime.prod.js` when running wrangler dev, so we need to stub it out // "critters" = "./.next/standalone/node_modules/cf/templates/shims/empty.ts" - const pagesRuntimeFile = join(distPath, "compiled", "next-server", "pages.runtime.prod.js"); + const pagesRuntimeFile = join(distPath, "compiled/next-server/pages.runtime.prod.js"); const patchedPagesRuntime = readFileSync(pagesRuntimeFile, "utf-8").replace( `e.exports=require("critters")`, @@ -38,7 +38,7 @@ export function patchWranglerDeps(config: Config) { // # try block here: https://github.com/vercel/next.js/blob/9e8266a7/packages/next/src/server/lib/trace/tracer.ts#L27-L31 // # causing the code to require the 'next/dist/compiled/@opentelemetry/api' module instead (which properly works) // #"@opentelemetry/api" = "./.next/standalone/node_modules/cf/templates/shims/throw.ts" - const tracerFile = join(distPath, "server", "lib", "trace", "tracer.js"); + const tracerFile = join(distPath, "server/lib/trace/tracer.js"); const patchedTracer = readFileSync(tracerFile, "utf-8").replaceAll( /\w+\s*=\s*require\([^/]*opentelemetry.*\)/g, @@ -63,7 +63,7 @@ export function patchWranglerDeps(config: Config) { function getDistPath(config: Config): string { for (const root of [config.paths.output.standaloneApp, config.paths.output.standaloneRoot]) { try { - const distPath = join(root, "node_modules", "next", "dist"); + const distPath = join(root, "node_modules/next/dist"); if (statSync(distPath).isDirectory()) return distPath; } catch { /* empty */ @@ -92,7 +92,7 @@ function patchRequireReactDomServerEdge(config: Config) { const distPath = getDistPath(config); // Patch .next/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js - const pagesRuntimeFile = join(distPath, "compiled", "next-server", "pages.runtime.prod.js"); + const pagesRuntimeFile = join(distPath, "compiled/next-server/pages.runtime.prod.js"); const code = readFileSync(pagesRuntimeFile, "utf-8"); const file = tsParseFile(code); diff --git a/packages/cloudflare/src/cli/build/utils/create-config-files.ts b/packages/cloudflare/src/cli/build/utils/create-config-files.ts index 53b2ef698..96d176d5f 100644 --- a/packages/cloudflare/src/cli/build/utils/create-config-files.ts +++ b/packages/cloudflare/src/cli/build/utils/create-config-files.ts @@ -41,7 +41,7 @@ export async function createWranglerConfigIfNotExistent(projectOpts: ProjectOpti return; } - let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "defaults", "wrangler.json"), "utf8"); + let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "defaults/wrangler.json"), "utf8"); const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name"; if (appName) { @@ -111,6 +111,6 @@ export async function createOpenNextConfigIfNotExistent(projectOpts: ProjectOpti throw new Error("The `open-next.config.ts` file is required, aborting!"); } - cpSync(join(getPackageTemplatesDirPath(), "defaults", "open-next.config.ts"), openNextConfigPath); + cpSync(join(getPackageTemplatesDirPath(), "defaults/open-next.config.ts"), openNextConfigPath); } } diff --git a/packages/cloudflare/src/cli/config.ts b/packages/cloudflare/src/cli/config.ts index 6f0884f22..7b683c5bf 100644 --- a/packages/cloudflare/src/cli/config.ts +++ b/packages/cloudflare/src/cli/config.ts @@ -66,7 +66,7 @@ export function getConfig(projectOpts: ProjectOptions): Config { const nodeModules = join(standaloneApp, "node_modules"); const internalPackage = join(nodeModules, ...PACKAGE_NAME.split("/")); - const internalTemplates = join(internalPackage, "cli", "templates"); + const internalTemplates = join(internalPackage, "cli/templates"); return { build: { @@ -141,7 +141,7 @@ function getNextjsApplicationPath(dotNextDir: string): string { function findServerParentPath(parentPath: string): string | undefined { try { - if (statSync(join(parentPath, ".next", "server")).isDirectory()) { + if (statSync(join(parentPath, ".next/server")).isDirectory()) { return parentPath; } } catch {