Skip to content

Commit a169b76

Browse files
authored
Fix exports and imports for package.json for workerd (#628)
* transform package json for packages that got workerd condition * fix for wasm import without ?module * lint fix * bug fix * add e2e app for prisma * lint fix * review and e2e fix * fix e2e * changeset * add initOpenNextCloudflareForDev * lint fix
1 parent de9e05a commit a169b76

27 files changed

+7401
-74
lines changed

.changeset/dull-terms-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix issues with build conditions and wasm

examples/common/apps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const apps = [
77
"playground15",
88
"vercel-blog-starter",
99
"ssg-app",
10+
"prisma",
1011
// e2e
1112
"app-pages-router",
1213
"app-router",

examples/prisma/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
# playwright
44+
/test-results/
45+
/playwright-report/
46+
/blob-report/
47+
/playwright/.cache/

examples/prisma/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { configurePlaywright } from "../../common/config-e2e";
2+
3+
export default configurePlaywright("prisma");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { configurePlaywright } from "../../common/config-e2e";
2+
3+
export default configurePlaywright("prisma", {
4+
isCI: !!process.env.CI,
5+
isWorker: false,
6+
});

examples/prisma/e2e/prisma.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test.describe("playground/cloudflare", () => {
4+
test("Prisma doesn't crash", async ({ page }) => {
5+
await page.goto("/");
6+
const aliceName = await page.getByTestId("name-Alice").innerText();
7+
expect(aliceName).toBe("Alice");
8+
const aliceEmail = await page.getByTestId("email-Alice").innerText();
9+
expect(aliceEmail).toBe("alice@example.com");
10+
11+
const bobName = await page.getByTestId("name-Bob").innerText();
12+
expect(bobName).toBe("Bob");
13+
const bobEmail = await page.getByTestId("email-Bob").innerText();
14+
expect(bobEmail).toBe("bob@example.com");
15+
16+
const carolName = await page.getByTestId("name-Carol").innerText();
17+
expect(carolName).toBe("Carol");
18+
const carolEmail = await page.getByTestId("email-Carol").innerText();
19+
expect(carolEmail).toBe("carol@example.com");
20+
});
21+
});

examples/prisma/next.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
serverExternalPackages: ["@prisma/client", ".prisma/client"],
6+
};
7+
8+
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
9+
initOpenNextCloudflareForDev();
10+
11+
export default nextConfig;

examples/prisma/open-next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2+
3+
export default defineCloudflareConfig({});

examples/prisma/package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "prisma",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev --turbopack",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint",
10+
"prepare:db": "npx prisma generate && wrangler d1 execute db --file populate.sql",
11+
"build:worker": "pnpm prepare:db && pnpm opennextjs-cloudflare build",
12+
"preview:worker": "pnpm opennextjs-cloudflare preview",
13+
"preview": "pnpm build:worker && pnpm preview:worker",
14+
"e2e": "playwright test -c e2e/playwright.config.ts",
15+
"e2e:dev": "playwright test -c e2e/playwright.dev.config.ts",
16+
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
17+
},
18+
"dependencies": {
19+
"@opennextjs/cloudflare": "workspace:*",
20+
"@prisma/adapter-d1": "^6.7.0",
21+
"@prisma/client": "^6.7.0",
22+
"next": "catalog:e2e",
23+
"react": "catalog:e2e",
24+
"react-dom": "catalog:e2e"
25+
},
26+
"devDependencies": {
27+
"@types/node": "catalog:",
28+
"@types/react": "catalog:e2e",
29+
"@types/react-dom": "catalog:e2e",
30+
"prisma": "^6.7.0",
31+
"typescript": "catalog:",
32+
"wrangler": "catalog:"
33+
}
34+
}

0 commit comments

Comments
 (0)