Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
Co-authored-by: Pete Bacon Darwin <[email protected]>
  • Loading branch information
vicb and petebacondarwin committed Nov 25, 2024
1 parent 82c4caa commit f0a5f2c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";`);
Expand Down

0 comments on commit f0a5f2c

Please sign in to comment.