Skip to content

Commit

Permalink
Move builder into a packages/cloudflare directory to match its new pa…
Browse files Browse the repository at this point in the history
…ckage name
  • Loading branch information
petebacondarwin committed Sep 20, 2024
1 parent 47270d3 commit 0da9b6b
Show file tree
Hide file tree
Showing 41 changed files with 51 additions and 49 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [POC] Build Next.js app for cf workers

This monorepo includes a POC to see if it is possible to get a Next.js application built via `next build` (in standalone mode) to run in the Cloudflare workerd runtime.
This monorepo includes a package for adapting a Next.js application built via `next build` (in standalone mode) to run in the Cloudflare workerd runtime.

> [!NOTE]
> The code here is built based on the amazing work done by @mhart in <https://github.com/mhart/nextjs-commerce>
Expand All @@ -9,8 +9,8 @@ This monorepo includes a POC to see if it is possible to get a Next.js applicati

The repository contains two directories:

- `builder` containing a package that can be used to build Cloudflare workers compatible output from Next.js applications
- `examples` containing Next.js applications that use the above mentioned builder.
- `packages` containing a cloudflare package that can be used to build Cloudflare workers compatible output from Next.js applications
- `examples` containing Next.js applications that use the above mentioned cloudflare.

## How to try out/develop in the repository

Expand All @@ -23,13 +23,13 @@ pnpm i
build the worker with:

```sh
pnpm --filter builder build
pnpm --filter cloudflare build
```

or in watch mode with:

```sh
pnpm --filter builder build:watch
pnpm --filter cloudflare build:watch
```

build and preview the worker for the `api` application:
Expand Down
8 changes: 4 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ DONE:
experimental_assets = { directory = ".worker-next/assets", binding = "ASSETS" }
```

- Build the builder
- Build the cloudflare builder

```sh
pnpm --filter builder build:watch
pnpm --filter cloudflare build:watch
```

- To build for workers:

- Build the next app once:

```sh
node /path/to/poc-next/builder/dist/index.mjs && npx wrangler dev
node /path/to/poc-next/packages/cloudflare/dist/index.mjs && npx wrangler dev
```

- Then you can skip building the next app

```sh
SKIP_NEXT_APP_BUILD=1 node /path/to/poc-next/builder/dist/index.mjs && npx wrangler dev
SKIP_NEXT_APP_BUILD=1 node /path/to/poc-next/packages/cloudflare/dist/index.mjs && npx wrangler dev
```

## Open next [example app](https://github.com/sst/open-next/tree/main/example)
Expand Down
2 changes: 1 addition & 1 deletion examples/create-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"build:worker": "pnpm cloudflare",
"build:worker": "cloudflare",
"dev:worker": "wrangler dev --port 8771",
"preview:worker": "pnpm build:worker && pnpm dev:worker",
"e2e": "playwright test -c e2e/playwright.config.ts"
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion builder/README.md → packages/cloudflare/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Next.js builder for Cloudflare

How to update a Next.js application to run on Cloudflare.

## Configure your app

- add the following `devDependency` to the `package.json`:
- add the following `devDependencies` to the `package.json`:

```bash
pnpm add -D wrangler@latest @opennextjs/cloudflare
Expand Down
2 changes: 1 addition & 1 deletion builder/package.json → packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"repository": {
"type": "git",
"url": "https://github.com/flarelabs-net/poc-next.git",
"directory": "builder"
"directory": "packages/cloudflare"
},
"keywords": [
"cloudflare",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
72 changes: 36 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages:
- "builder"
- "packages/*"
- "examples/*"

catalog:
Expand Down

0 comments on commit 0da9b6b

Please sign in to comment.