Skip to content

Sync AWS PRs and add coding guidelines#25

Open
conico974 wants to merge 12 commits intomainfrom
conico/port-skills
Open

Sync AWS PRs and add coding guidelines#25
conico974 wants to merge 12 commits intomainfrom
conico/port-skills

Conversation

@conico974
Copy link
Contributor

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.

Copilot AI review requested due to automatic review settings March 21, 2026 09:43
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@25
npm i https://pkg.pr.new/@opennextjs/aws@25

commit: b4463be

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in changeset description: "expend" should be "expand".

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +142 to +151
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}`,
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
}
// 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)-[^/]+)/);
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const match = from.match(/node_modules\/(.+\/)?([^/]+-(?:darwin|win32|freebsd)-[^/]+)/);
const match = from.match(
getCrossPlatformPathRegex("node_modules/(.+/)?([^/]+-(?:darwin|win32|freebsd)-[^/]+)"),
);

Copilot uses AI. Check for mistakes.
`;

// Make `handleNextImageRequest` a no-op to avoid pulling `sharp`
// Apply to Next 14, 15, and 16
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// Apply to Next 14, 15, and 16
// Applies wherever this constructor pattern is matched

Copilot uses AI. Check for mistakes.
import fs from "node:fs";

import { compareSemver, findNextConfig } from "@opennextjs/aws/build/helper.js";
import { afterEach, vi } from "vitest";
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
import { afterEach, vi } from "vitest";
import { vi } from "vitest";

Copilot uses AI. Check for mistakes.
### Formatting

- Tabs for indentation (check .editorconfig if present)
- Single quotes for strings
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- Single quotes for strings
- Double quotes for strings

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants