diff --git a/packages/cloudflare/README.md b/packages/cloudflare/README.md index b5fd3fa2..deb76717 100644 --- a/packages/cloudflare/README.md +++ b/packages/cloudflare/README.md @@ -66,11 +66,11 @@ const config: OpenNextConfig = { export default config; ``` -## Know issues +## Known issues - Next cache is not supported in the experimental branch yet - `▲ [WARNING] Suspicious assignment to defined constant "process.env.NODE_ENV" [assign-to-define]` can safely be ignored -- You should test with cache disabled in the developper tools +- You should test with cache disabled in the developer tools - Maybe more, still experimental... ## Local development diff --git a/packages/cloudflare/src/cli/build/bundle-server.ts b/packages/cloudflare/src/cli/build/bundle-server.ts index 196aa0a8..514e0a66 100644 --- a/packages/cloudflare/src/cli/build/bundle-server.ts +++ b/packages/cloudflare/src/cli/build/bundle-server.ts @@ -34,7 +34,7 @@ export async function bundleServer(config: Config, openNextOptions: BuildOptions const nextConfigStr = fs - .readFileSync(path.join(config.paths.output.standaloneApp, "/server.js"), "utf8") + .readFileSync(path.join(config.paths.output.standaloneApp, "server.js"), "utf8") ?.match(/const nextConfig = ({.+?})\n/)?.[1] ?? {}; console.log(`\x1b[35m⚙️ Bundling the OpenNext server...\n\x1b[0m`); @@ -87,10 +87,11 @@ export async function bundleServer(config: Config, openNextOptions: BuildOptions // We need to set platform to node so that esbuild doesn't complain about the node imports platform: "node", banner: { - // `__dirname` is used by unbundled js files (which don't inherit the `__dirname` present in the `define` field) - // so we also need to set it on the global scope - // Note: this was hit in the `next/dist/compiled/@opentelemetry/api` module js: ` +// __dirname is used by unbundled js files (which don't inherit the __dirname present in the define field) +// so we also need to set it on the global scope +// Note: this was hit in the next/dist/compiled/@opentelemetry/api module + globalThis.__dirname ??= ""; // Do not crash on cache not supported diff --git a/packages/cloudflare/src/cli/build/open-next/createServerBundle.ts b/packages/cloudflare/src/cli/build/open-next/createServerBundle.ts index c52c4947..78005123 100644 --- a/packages/cloudflare/src/cli/build/open-next/createServerBundle.ts +++ b/packages/cloudflare/src/cli/build/open-next/createServerBundle.ts @@ -274,6 +274,7 @@ function addMonorepoEntrypoint(outputPath: string, packagePath: string) { // the root of the bundle. We will create a dummy `index.mjs` // that re-exports the real handler. + // TOOD: use helper // Always use posix path for import path const packagePosixPath = packagePath.split(path.sep).join(path.posix.sep); fs.writeFileSync(path.join(outputPath, "index.mjs"), `export * from "./${packagePosixPath}/index.mjs";`);