Conversation
commit: |
There was a problem hiding this comment.
Pull request overview
Ports functionality and build/test improvements from the OpenNextJS AWS repository into this monorepo, and adds contributor guidance docs for porting PRs and coding standards.
Changes:
- Preserve query parameters during i18n root-locale redirects (with trailingSlash support).
- Extend incremental cache support for Next 15+ app pages (segmentData + postponed) and add related typings/tests.
- Improve build tooling: robust Next config discovery, Next server patch to avoid pulling
sharp, and safer traced-file copying (writable perms + platform-binary filtering).
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/open-next/src/core/routing/i18n/index.ts | Updates locale redirect URL construction to preserve query params and handle trailingSlash. |
| packages/tests-unit/tests/core/routing/i18n.test.ts | Adds coverage for locale redirects preserving query params (incl. trailingSlash). |
| packages/open-next/src/adapters/cache.ts | Writes APP_PAGE cache entries including segmentData/postponed for Next 15+. |
| packages/open-next/src/types/cache.ts | Adds segmentData?: Map<string, Buffer> to APP_PAGE cache type. |
| packages/tests-unit/tests/adapters/cache.test.ts | Adds tests for APP_PAGE segmentData/postponed round-tripping. |
| packages/open-next/src/build/helper.ts | Adds findNextConfig helper to locate Next config and detect TS. |
| packages/tests-unit/tests/build/helper.test.ts | Adds unit tests for findNextConfig. |
| packages/open-next/src/build/patch/patches/patchOriginalNextConfig.ts | Uses findNextConfig for importing/compiling Next config. |
| packages/open-next/src/build/patch/patches/patchNextServer.ts | Adds AST patch rule to no-op handleNextImageRequest to avoid sharp. |
| packages/tests-unit/tests/build/patch/patches/patchNextServer.test.ts | Adds snapshot coverage for the new Next server patch rule. |
| packages/open-next/src/build/copyTracedFiles.ts | Ensures copied files are writable; filters non-Linux platform binaries; exports helper predicate. |
| packages/tests-unit/tests/build/copyTracedFiles.test.ts | Adds tests for non-Linux platform package detection. |
| packages/open-next/package.json | Updates @ast-grep/napi and AWS SDK dependencies. |
| packages/cloudflare/package.json | Updates @ast-grep/napi version. |
| AGENTS.md | Adds repository coding standards and command guidance for agents. |
| .claude/skills/port-pr/SKILL.md | Adds a documented workflow for porting PRs (skill definition). |
| .changeset/stale-schools-beam.md | Adds changeset entry for findNextConfig change. |
| .changeset/port-pr-1098.md | Adds changeset entry for the ported PR. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "@opennextjs/aws": patch | ||
| --- | ||
|
|
||
| Fix `findNextConfig` returning the incorrect result and also expend the return result to be an object with both the path and a new flag indicating whether the file is in TypeScript or not |
There was a problem hiding this comment.
Typo in changeset description: "expend" should be "expand".
| Fix `findNextConfig` returning the incorrect result and also expend the return result to be an object with both the path and a new flag indicating whether the file is in TypeScript or not | |
| Fix `findNextConfig` returning the incorrect result and also expand the return result to be an object with both the path and a new flag indicating whether the file is in TypeScript or not |
| const nextUrl = constructNextUrl( | ||
| internalEvent.url, | ||
| `/${detectedLocale}${NextConfig.trailingSlash ? "/" : ""}` | ||
| ); | ||
| const queryString = convertToQueryString(internalEvent.query); | ||
| return { | ||
| type: "core", | ||
| statusCode: 307, | ||
| headers: { | ||
| Location: constructNextUrl(internalEvent.url, `/${detectedLocale}`), | ||
| Location: `${nextUrl}${queryString}`, |
There was a problem hiding this comment.
convertToQueryString(internalEvent.query) rebuilds the query string from the parsed query object, but internalEvent.query is populated via URLSearchParams (decoded values). This can produce an invalid/changed redirect URL for values that require encoding (e.g. spaces, +, %2F). Prefer preserving the original search from internalEvent.url, or re-encoding with URLSearchParams when building the redirect URL.
| } | ||
| // Skip non-Linux platform-specific native binaries (e.g. @swc/core-darwin-arm64) | ||
| if (!process.env.OPEN_NEXT_SKIP_PLATFORM_FILTER && isNonLinuxPlatformPackage(from)) { | ||
| const match = from.match(/node_modules\/(.+\/)?([^/]+-(?:darwin|win32|freebsd)-[^/]+)/); |
There was a problem hiding this comment.
The debug from.match(/node_modules\/(.+\/)?.../) pattern uses hard-coded POSIX separators, but the filter itself is cross-platform via getCrossPlatformPathRegex. On Windows this will skip packages without emitting the intended debug message. Consider using a cross-platform regex (or normalizing the path) for the log extraction too.
| const match = from.match(/node_modules\/(.+\/)?([^/]+-(?:darwin|win32|freebsd)-[^/]+)/); | |
| const match = from.match( | |
| getCrossPlatformPathRegex("node_modules/(.+/)?([^/]+-(?:darwin|win32|freebsd)-[^/]+)"), | |
| ); |
| `; | ||
|
|
||
| // Make `handleNextImageRequest` a no-op to avoid pulling `sharp` | ||
| // Apply to Next 14, 15, and 16 |
There was a problem hiding this comment.
The comment says this handleNextImageRequest patch applies to Next 14–16, but the patch entry itself has no versions constraint. Either add an explicit version range to the patch definition or update the comment so the documented applicability matches the actual behavior.
| // Apply to Next 14, 15, and 16 | |
| // Applies wherever this constructor pattern is matched |
| import fs from "node:fs"; | ||
|
|
||
| import { compareSemver, findNextConfig } from "@opennextjs/aws/build/helper.js"; | ||
| import { afterEach, vi } from "vitest"; |
There was a problem hiding this comment.
afterEach is imported but never used. If linting is enforced for tests, this will fail the build; please remove the unused import (or add the intended cleanup in an afterEach).
| import { afterEach, vi } from "vitest"; | |
| import { vi } from "vitest"; |
| ### Formatting | ||
|
|
||
| - Tabs for indentation (check .editorconfig if present) | ||
| - Single quotes for strings |
There was a problem hiding this comment.
Formatting guidelines say to use single quotes, but the repo formatter config (.oxfmtrc.json) sets singleQuote: false (double quotes). Please update this guidance to match the enforced formatter to avoid churn in future PRs.
| - Single quotes for strings | |
| - Double quotes for strings |
This update ports several PRs from the OpenNextJS AWS repository and introduces SKILL.md for porting guidelines and AGENTS.md for coding standards. The changes enhance functionality and maintainability across the codebase.