Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Local E2E Tests

on:
push:
branches: [main, experimental]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
PLAYWRIGHT_BROWSERS_PATH: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
core:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup
- name: Setup Playwright
uses: ./.github/actions/setup-playwright

- name: Build OpenNext packages
shell: bash
run: pnpm --filter @opennextjs/aws... run build

- name: Build examples apps with local configuration
shell: bash
run: pnpm -r openbuild:local

# Remember to add more ports here if we add new examples app
- name: Start the local OpenNext servers
shell: bash
run: |
pnpm -r openbuild:local:start &
for port in 3001 3002 3003; do
echo "Checking port $port..."
for attempt in {1..20}; do
sleep 0.5
if curl --silent --fail http://localhost:$port > /dev/null; then
echo "Server on $port is ready"
break
fi
if [ $attempt -eq 20 ]; then
echo "Server on $port failed to start"
exit 1
fi
echo "Waiting for server on $port, attempt $attempt..."
done
done
- name: Run E2E Test locally
shell: bash
run: |
pnpm e2e:test
6 changes: 3 additions & 3 deletions examples/app-pages-router/on-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const PORT = process.env.PORT ?? 3000;

// Start servers
spawn("node", [".open-next/server-functions/default/index.mjs"], {
env: { ...process.env, PORT: "3010" },
env: { ...process.env, SOME_ENV_VAR: "foo", PORT: "3010" },
stdio: "inherit",
});

Expand All @@ -19,7 +19,7 @@ spawn("node", [".open-next/server-functions/api/index.mjs"], {
const app = express();

app.use(
"/api/*",
/\/api\/.*$/,
proxy("http://localhost:3011", {
proxyReqPathResolver: (req) => req.originalUrl,
proxyReqOptDecorator: (proxyReqOpts) => {
Expand All @@ -31,7 +31,7 @@ app.use(

// Catch-all for everything else
app.use(
"*",
/.*$/,
proxy("http://localhost:3010", {
proxyReqPathResolver: (req) => req.originalUrl,
proxyReqOptDecorator: (proxyReqOpts) => {
Expand Down
34 changes: 0 additions & 34 deletions examples/app-pages-router/open-next.config.local.ts

This file was deleted.

32 changes: 26 additions & 6 deletions examples/app-pages-router/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
const config = {
default: {},
import type { OpenNextConfig, OverrideOptions } from "@opennextjs/aws/types/open-next.js";

const devOverride = {
wrapper: "express-dev",
converter: "node",
incrementalCache: "fs-dev",
queue: "direct",
tagCache: "fs-dev-nextMode",
} satisfies OverrideOptions;

export default {
default: {
override: devOverride,
},
functions: {
api: {
override: devOverride,
routes: ["app/api/client/route", "app/api/host/route", "pages/api/hello"],
patterns: ["/api/*"],
},
},
imageOptimization: {
override: {
wrapper: "dummy",
converter: "dummy",
},
loader: "fs-dev",
},
dangerous: {
enableCacheInterception: true,
useAdapterOutputs: true,
},
buildCommand: "npx turbo build",
};

module.exports = config;
// You can override the build command here so that you don't have to rebuild next every time you make a change
// buildCommand: "echo 'No build command'",
} satisfies OpenNextConfig;
5 changes: 3 additions & 2 deletions examples/app-pages-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "0.1.50",
"private": true,
"scripts": {
"openbuild": "node ../../packages/open-next/dist/index.js build --build-command \"npx turbo build\"",
"openbuild:local": "node ../../packages/open-next/dist/index.js build --config-path open-next.config.local.ts",
"openbuild:local": "node ../../packages/open-next/dist/index.js build",
"openbuild:local:start": "PORT=3003 tsx on-proxy.ts",
"dev": "next dev --turbopack --port 3003",
"build": "next build",
Expand All @@ -15,12 +14,14 @@
"dependencies": {
"@example/shared": "workspace:*",
"@opennextjs/aws": "workspace:*",
"express": "^5.2.1",
"express-http-proxy": "2.1.1",
"next": "catalog:aws",
"react": "catalog:aws",
"react-dom": "catalog:aws"
},
"devDependencies": {
"@types/express": "^5.0.6",
"@types/express-http-proxy": "1.6.7",
"@types/node": "catalog:aws",
"@types/react": "catalog:aws",
Expand Down
28 changes: 0 additions & 28 deletions examples/app-router/open-next.config.local.ts

This file was deleted.

31 changes: 22 additions & 9 deletions examples/app-router/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
const config = {
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next.js";

export default {
default: {
override: {
wrapper: "aws-lambda-streaming",
queue: "sqs-lite",
incrementalCache: "s3-lite",
tagCache: "dynamodb-lite",
wrapper: "express-dev",
converter: "node",
incrementalCache: "fs-dev",
queue: "direct",
tagCache: "fs-dev-nextMode",
},
},
functions: {},

dangerous: {
middlewareHeadersOverrideNextConfigHeaders: true,
useAdapterOutputs: true,
enableCacheInterception: true,
},

imageOptimization: {
override: {
wrapper: "dummy",
converter: "dummy",
},
loader: "fs-dev",
},
buildCommand: "npx turbo build",
};

export default config;
// You can override the build command here so that you don't have to rebuild next every time you make a change
//buildCommand: "echo 'No build command'",
} satisfies OpenNextConfig;
3 changes: 1 addition & 2 deletions examples/app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "0.1.33",
"private": true,
"scripts": {
"openbuild": "node ../../packages/open-next/dist/index.js build",
"openbuild:local": "node ../../packages/open-next/dist/index.js build --config-path open-next.config.local.ts",
"openbuild:local": "node ../../packages/open-next/dist/index.js build",
"openbuild:local:start": "PORT=3001 OPEN_NEXT_REQUEST_ID_HEADER=true node .open-next/server-functions/default/index.mjs",
"dev": "next dev --turbopack --port 3001",
"build": "next build",
Expand Down
2 changes: 0 additions & 2 deletions examples/experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"private": true,
"scripts": {
"openbuild": "node ../../packages/open-next/dist/index.js build",
"openbuild:local": "node ../../packages/open-next/dist/index.js build --config-path open-next.config.local.ts",
"openbuild:local:start": "PORT=3004 node .open-next/server-functions/default/index.mjs",
"dev": "next dev --turbopack --port 3004",
"build": "next build",
"start": "next start --port 3004",
Expand Down
2 changes: 1 addition & 1 deletion examples/pages-router/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const nextConfig: NextConfig = {
],
rewrites: async () => [
{ source: "/rewrite", destination: "/", locale: false },
{ source: "/rewriteWithQuery", destination: "/api/query?q=1" },
{ source: "/rewriteWithQuery/", destination: "/api/query?q=1" },
{
source: "/rewriteUsingQuery",
destination: "/:destination/",
Expand Down
22 changes: 0 additions & 22 deletions examples/pages-router/open-next.config.local.ts

This file was deleted.

28 changes: 22 additions & 6 deletions examples/pages-router/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
const config = {
export default {
default: {
override: {
wrapper: "aws-lambda-streaming",
wrapper: "express-dev",
converter: "node",
incrementalCache: "fs-dev",
queue: "direct",
tagCache: "dummy",
},
},
functions: {},
buildCommand: "npx turbo build",
};

module.exports = config;
imageOptimization: {
override: {
wrapper: "dummy",
converter: "dummy",
},
loader: "fs-dev",
},

dangerous: {
enableCacheInterception: true,
useAdapterOutputs: true,
},

// You can override the build command here so that you don't have to rebuild next every time you make a change
//buildCommand: "echo 'No build command'",
};
5 changes: 2 additions & 3 deletions examples/pages-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "0.1.0",
"private": true,
"scripts": {
"openbuild": "node ../../packages/open-next/dist/index.js build --build-command \"npx turbo build\"",
"openbuild:local": "node ../../packages/open-next/dist/index.js build --config-path open-next.config.local.ts",
"openbuild:local:start": "PORT=3002 node .open-next/server-functions/default/index.mjs",
"openbuild:local": "node ../../packages/open-next/dist/index.js build",
"openbuild:local:start": "SOME_PROD_VAR=bar PORT=3002 node .open-next/server-functions/default/index.mjs",
"dev": "next dev --turbopack --port 3002",
"build": "next build",
"start": "next start --port 3002",
Expand Down
12 changes: 9 additions & 3 deletions examples/pages-router/src/pages/sse/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { useEffect, useState } from "react";

type Event = {
Expand All @@ -8,7 +6,15 @@ type Event = {
body?: string;
};

export default function SSE() {
//SEEMS mandatory to have getStaticProps for SSG pages
// TODO: verify if that's the case
export async function getStaticProps() {
return {
props: {},
};
}

export default function Page() {
const [events, setEvents] = useState<Event[]>([]);
const [finished, setFinished] = useState(false);

Expand Down
3 changes: 2 additions & 1 deletion packages/cloudflare/src/cli/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ export default {
} satisfies NextAdapter;

function getAdditionalPluginsFactory(buildOpts: buildHelper.BuildOptions, ctx: BuildCompleteCtx) {
const packagePath = buildHelper.getPackagePath(buildOpts);
return (updater: ContentUpdater) => [
inlineRouteHandler(updater, ctx.outputs),
inlineRouteHandler(updater, ctx.outputs, packagePath),
//externalChunksPlugin(outputs),
inlineLoadManifest(updater, buildOpts),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function generateBundle(
if (!buildCtx) {
throw new Error("should not happen");
}
tracedFiles = await copyAdapterFiles(options, name, buildCtx.outputs);
tracedFiles = await copyAdapterFiles(options, name, packagePath, buildCtx.outputs);
//TODO: we should load manifests here
} else {
const oldTracedFileOutput = await copyTracedFiles({
Expand Down
Loading
Loading