-
Notifications
You must be signed in to change notification settings - Fork 147
feat: support nextjs pages router #650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: d0bdf71 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (23 failed)nextjs-pages (23 failed):
🌍 Community Worlds (11 failed)mongodb (1 failed):
redis (1 failed):
starter (8 failed):
turso (1 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
❌ Some E2E test jobs failed:
Check the workflow run for details. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
a524531 to
d03acf3
Compare
60a7ec9 to
0442d59
Compare
| const pagesRouterWrapper = `// biome-ignore-all lint: generated file | ||
| /* eslint-disable */ | ||
| ${PAGES_ADAPTER_CODE} | ||
| ${stepsBundle.replace(/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\};?/g, 'const POST = stepEntrypoint;')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern used to replace the steps bundle export statement is incomplete and will produce invalid JavaScript syntax. The pattern doesn't account for the from 'workflow/runtime' part of the re-export statement.
View Details
📝 Patch Details
diff --git a/packages/astro/src/builder.ts b/packages/astro/src/builder.ts
index 5237247..09dc400 100644
--- a/packages/astro/src/builder.ts
+++ b/packages/astro/src/builder.ts
@@ -91,7 +91,7 @@ export class LocalBuilder extends BaseBuilder {
// Normalize request, needed for preserving request through astro
stepsRouteContent = stepsRouteContent.replace(
- /export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}\s*;?$/m,
+ /export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}(?:\s+from\s+['"][^'"]*['"])?\s*;?$/m,
`${NORMALIZE_REQUEST_CODE}
export const POST = async ({request}) => {
const normalRequest = await normalizeRequest(request);
diff --git a/packages/next/src/builder.ts b/packages/next/src/builder.ts
index 85b7a90..174509e 100644
--- a/packages/next/src/builder.ts
+++ b/packages/next/src/builder.ts
@@ -760,7 +760,7 @@ async function sendPagesResponse(res, webResponse) {
const pagesRouterWrapper = `// biome-ignore-all lint: generated file
/* eslint-disable */
${PAGES_ADAPTER_CODE}
-${stepsBundle.replace(/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\};?/g, 'const POST = stepEntrypoint;')}
+${stepsBundle.replace(/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}(?:\s+from\s+['"][^'"]*['"])?\s*;?/g, 'const POST = stepEntrypoint;')}
export default async function handler(req, res) {
const webRequest = await convertPagesRequest(req);
diff --git a/packages/sveltekit/src/builder.ts b/packages/sveltekit/src/builder.ts
index 531c754..681e600 100644
--- a/packages/sveltekit/src/builder.ts
+++ b/packages/sveltekit/src/builder.ts
@@ -90,7 +90,7 @@ export class SvelteKitBuilder extends BaseBuilder {
// Replace the default export with SvelteKit-compatible handler
stepsRouteContent = stepsRouteContent.replace(
- /export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}\s*;?$/m,
+ /export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}(?:\s+from\s+['"][^'"]*['"])?\s*;?$/m,
`${NORMALIZE_REQUEST_CODE}
export const POST = async ({request}) => {
const normalRequest = await normalizeRequest(request);
Analysis
Incomplete regex pattern for re-export statement replacement causes invalid JavaScript syntax
What fails: The regex patterns used in pages/astro/sveltekit builders to replace export { stepEntrypoint as POST } statements do not match statements containing the from 'module' clause, resulting in malformed code like const POST = stepEntrypoint; from 'workflow/runtime';
How to reproduce:
- Build a Next.js/Astro/SvelteKit project with a workflow step
- The base builder's
createStepsBundle()method generates an entry with:export { stepEntrypoint as POST } from 'workflow/runtime'; - When this gets bundled and the Pages Router/Astro/SvelteKit handlers attempt to replace the export statement using the incomplete regex pattern, the
from 'workflow/runtime'clause is left behind - Result: Invalid JavaScript syntax that will fail to parse
Example failure:
Input:
export { stepEntrypoint as POST } from 'workflow/runtime';Old regex /export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\};?/g produces:
const POST = stepEntrypoint; from 'workflow/runtime';This is invalid JavaScript and will cause a syntax error.
Root cause: The regex patterns in three files do not account for the optional from 'module' clause that esbuild preserves in re-export statements:
packages/next/src/builder.tsline 763packages/astro/src/builder.tsline 94packages/sveltekit/src/builder.tsline 93
Solution: Updated regex patterns to optionally match and remove the from 'module' clause:
- Changed:
/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\};?/g(Next.js) - Changed:
/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}\s*;?$/m(Astro/SvelteKit) - To:
/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}(?:\s+from\s+['"][^'"]*['"])?\s*;?/g(Next.js) - To:
/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}(?:\s+from\s+['"][^'"]*['"])?\s*;?$/m(Astro/SvelteKit)
The new pattern uses a non-capturing group (?:...) with an optional modifier ? to match the from 'module' clause, handling both single and double quotes.
|
update: we just need this PR merged: vercel/vercel which adds support for the |
add nextjs pages router support
fixes #143