Skip to content

Commit cccf357

Browse files
committed
minor fixes
1 parent 6cc9bf4 commit cccf357

36 files changed

+82
-330
lines changed

.github/workflows/playwright.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ jobs:
2222
- uses: actions/upload-artifact@v4
2323
if: always()
2424
with:
25-
name: api-nodejs-hello-world-playwright-report
26-
path: next-apps/api-nodejs-hello-world/playwright-report/
25+
name: api-playwright-report
26+
path: next-apps/api/playwright-report/
2727
retention-days: 30

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This monorepo includes a POC to see if it is possible to get a Next.js applicati
99

1010
The repository contains two directories:
1111

12-
- `nextjs-worker-builder` containing a package that can be used to build Cloudflare workers compatible output from Next.js applications
13-
- `next-apps` containing Next.js application that use the above mentioned builder (currently it only contains `api-nodejs-hello-world`)
12+
- `builder` containing a package that can be used to build Cloudflare workers compatible output from Next.js applications
13+
- `next` containing Next.js application that use the above mentioned builder (currently it only contains `api`)
1414

1515
## How to try out/develop in the repository
1616

@@ -23,23 +23,23 @@ pnpm i
2323
build the worker with:
2424

2525
```sh
26-
pnpm --filter nextjs-worker-builder build
26+
pnpm --filter builder build
2727
```
2828

2929
or in watch mode with:
3030

3131
```sh
32-
pnpm --filter nextjs-worker-builder build:watch
32+
pnpm --filter builder build:watch
3333
```
3434

35-
build and preview the worker for the `api-nodejs-hello-world` application:
35+
build and preview the worker for the `api` application:
3636

3737
```sh
38-
pnpm --filter api-nodejs-hello-world preview:worker
38+
pnpm --filter api preview:worker
3939
```
4040

4141
You can skip building the next app when it has not been modified:
4242

4343
```sh
44-
SKIP_NEXT_APP_BUILD=true pnpm --filter api-nodejs-hello-world preview:worker
44+
SKIP_NEXT_APP_BUILD=true pnpm --filter api preview:worker
4545
```
File renamed without changes.

nextjs-worker-builder/package.json renamed to builder/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "nextjs-worker-builder",
2+
"name": "builder",
33
"scripts": {
44
"build": "tsup",
55
"build:watch": "tsup --watch src"
@@ -16,4 +16,4 @@
1616
"tsup": "^8.2.4",
1717
"typescript": "^5.5.4"
1818
}
19-
}
19+
}
File renamed without changes.

nextjs-worker-builder/src/build/build-next-app.ts renamed to builder/src/build/build-next-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function runNextBuildCommand(
2626
env: {
2727
...process.env,
2828
// equivalent to: https://github.com/sst/open-next/blob/f61b0e9/packages/open-next/src/build.ts#L168-L173
29-
// Equivalent to setting `target: "standalone"` in next.config.js
29+
// Equivalent to setting `output: "standalone"` in next.config.js
3030
NEXT_PRIVATE_STANDALONE: "true",
3131
},
3232
});

nextjs-worker-builder/src/build/build-worker/index.ts renamed to builder/src/build/build-worker/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { patchFindDir } from "./patches/to-investigate/patchFindDir";
1313
import { inlineNextRequire } from "./patches/to-investigate/inlineNextRequire";
1414
import { inlineEvalManifest } from "./patches/to-investigate/inlineEvalManifest";
1515

16+
import * as url from "url";
17+
18+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
19+
1620
/**
1721
* Using the Next.js build output in the `.next` directory builds a workerd compatible output
1822
*
@@ -24,7 +28,6 @@ export async function buildWorker(
2428
nextjsAppPaths: NextjsAppPaths
2529
): Promise<void> {
2630
const repoRoot = resolve(`${__dirname}/../..`);
27-
console.log({ repoRoot });
2831

2932
const workerEntrypoint = `${__dirname}/templates/worker.ts`;
3033
const workerOutputFile = `${outputDir}/index.mjs`;
@@ -121,7 +124,6 @@ async function updateWorkerBundledCode(
121124
workerOutputFile: string,
122125
nextjsAppPaths: NextjsAppPaths
123126
): Promise<void> {
124-
console.log({ workerOutputFile });
125127
const originalCode = await readFile(workerOutputFile, "utf8");
126128

127129
let patchedCode = originalCode;
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { globSync } from "glob";
2-
import { NextjsAppPaths } from "../../../../nextjsPaths";
2+
import { NextjsAppPaths } from "builder/src/nextjsPaths";
33

44
/**
55
* `evalManifest` relies on readFileSync so we need to patch the function so that it instead returns the content of the manifest files

0 commit comments

Comments
 (0)