Repository navigation
Next.js新分支 - #86174
Next.js新分支#86174dofaromg wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a GitHub Actions workflow for building the Next.js project using Webpack. The workflow is configured to run on pushes and pull requests to the canary branch, testing against multiple Node.js versions.
Key Changes:
- Adds automated CI/CD workflow for Webpack builds
- Configures matrix testing across Node.js versions 18.x, 20.x, and 22.x
- Implements basic build steps using npm and webpack
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Build | ||
| run: | | ||
| npm install | ||
| npx webpack |
There was a problem hiding this comment.
Update CI job to use valid build step
The new workflow runs npm install followed by npx webpack, but this repository is configured for pnpm workspaces and does not include a root-level webpack entry/config. As written the job will consistently fail on every push/PR to canary because webpack cannot find a project to build (and npm will also ignore the existing pnpm lockfile), so the workflow never succeeds.
Useful? React with 👍 / 👎.
|
• 向工作流添加 set -x(Bash 脚本)以调试。
• 添加条件性处理 || exit 0 看是否能继续运行。
取得 iOS 版 Outlook<https://aka.ms/o0ukef>
________________________________
寄件者: chatgpt-codex-connector[bot] ***@***.***>
寄件日期: Sunday, November 16, 2025 11:24:47 AM
收件者: vercel/next.js ***@***.***>
副本: Mr.liou ***@***.***>; Author ***@***.***>
主旨: Re: [vercel/next.js] Next.js新分支 (PR #86174)
@chatgpt-codex-connector[bot] commented on this pull request.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo<http://chatgpt.com/codex/settings/general>. Reviews are triggered when you
* Open a pull request for review
* Mark a draft as ready
* Comment ***@***.***<https://github.com/codex> review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting ***@***.***<https://github.com/codex> address that feedback".
________________________________
In .github/workflows/webpack.yml<#86174 (comment)>:
+ - name: Build
+ run: |
+ npm install
+ npx webpack
[P1 Badge]<https://camo.githubusercontent.com/c595229c0ecb6ee85b9c7804144d495f131a495ec87091fea2b262d954c9a92d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50312d6f72616e67653f7374796c653d666c6174> Update CI job to use valid build step
The new workflow runs npm install followed by npx webpack, but this repository is configured for pnpm workspaces and does not include a root-level webpack entry/config. As written the job will consistently fail on every push/PR to canary because webpack cannot find a project to build (and npm will also ignore the existing pnpm lockfile), so the workflow never succeeds.
Useful? React with 👍 / 👎.
—
Reply to this email directly, view it on GitHub<#86174 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BT3V3IGELGOG7O64YC4WZY3347U77AVCNFSM6AAAAACMHLBW2GVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTINRZGI2TANJRGA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| - name: Build | ||
| run: | | ||
| pnpm install | ||
| npx webpack |
There was a problem hiding this comment.
The direct npx webpack command may fail since it requires webpack to be installed and properly configured. Next.js projects typically use their own build system through commands like pnpm build, which would leverage the project's existing configuration. Consider replacing this with the appropriate Next.js build command to ensure compatibility with the project's build pipeline.
| npx webpack | |
| pnpm build |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Build | ||
| run: | | ||
| pnpm install | ||
| npx webpack |
There was a problem hiding this comment.
Build step invokes nonexistent webpack target
The workflow now runs npx webpack after a root pnpm install, but this repo is a pnpm/turbo monorepo without a root webpack dependency or config. On every push/PR to canary the job will fail because npx cannot find a webpack binary or project to build, so the workflow never succeeds.
Useful? React with 👍 / 👎.
| - name: Build | ||
| run: | | ||
| pnpm install | ||
| npx webpack |
There was a problem hiding this comment.
| npx webpack | |
| pnpm run test-webpack |
The workflow will fail because npx webpack is run without any configuration or entry point. Webpack won't know what to bundle and will error out.
View Details
Analysis
Webpack workflow fails with missing configuration and entry point
What fails: The GitHub Actions workflow in .github/workflows/webpack.yml executes npx webpack without any configuration file or entry point, causing the build to fail with "Module not found: Error: Can't resolve './src'"
How to reproduce:
# Clone the repo and run the workflow steps:
pnpm install
npx webpackResult:
ERROR in main
Module not found: Error: Can't resolve './src' in '/path/to/repo'
using description file: /path/to/repo/package.json (relative path: .)
using description file: /path/to/repo/package.json (relative path: ./src)
no extension
/path/to/repo/src doesn't exist
.js
/path/to/repo/src.js doesn't exist
.json
/path/to/repo/src.json doesn't exist
.wasm
/path/to/repo/src.wasm doesn't exist
as directory
/path/to/repo/src doesn't exist
webpack 5.98.0 compiled with 1 error and 1 warning in 38 ms
Expected: The workflow should successfully test webpack functionality using the existing test suite, not fail with missing module resolution.
Fix: Changed the workflow to run pnpm run test-webpack which is the appropriate webpack test command already defined in package.json. This aligns with the workflow's purpose of validating webpack compatibility while using actual project test infrastructure rather than attempting to bundle a non-existent entry point.
This workflow builds and deploys a Next.js site to GitHub Pages, handling package manager detection, caching, and artifact upload.
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v2 | ||
| with: | ||
| version: 8 | ||
|
|
||
| - name: Build | ||
| run: | | ||
| pnpm install | ||
| npx webpack |
There was a problem hiding this comment.
The webpack workflow is missing pnpm store caching, which will cause significantly slower builds since dependencies need to be re-downloaded on every run. This is inconsistent with other workflows in the repository.
View Details
📝 Patch Details
diff --git a/.github/workflows/webpack.yml b/.github/workflows/webpack.yml
index 3b68272b91..299d869f76 100644
--- a/.github/workflows/webpack.yml
+++ b/.github/workflows/webpack.yml
@@ -27,6 +27,18 @@ jobs:
with:
version: 8
+ - id: get-store-path
+ run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT
+
+ - uses: actions/cache@v4
+ timeout-minutes: 5
+ id: cache-pnpm-store
+ with:
+ path: ${{ steps.get-store-path.outputs.STORE_PATH }}
+ key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: |
+ pnpm-store-
+
- name: Build
run: |
pnpm install
Analysis
Missing pnpm store caching in webpack.yml workflow
What fails: The webpack.yml GitHub Actions workflow does not cache the pnpm store, resulting in dependencies being re-downloaded on every workflow run, while other workflows in the repository (build_and_deploy.yml and create_release_branch.yml) explicitly cache the pnpm store. This creates inconsistency and slower build times.
How to reproduce:
- Check .github/workflows/webpack.yml lines 25-33 - no pnpm store caching is present
- Compare with .github/workflows/build_and_deploy.yml lines 97-104 and .github/workflows/create_release_branch.yml lines 62-71 - both have explicit pnpm store caching using
get-store-pathandactions/cache@v4 - Run the webpack workflow - each execution will re-download all pnpm dependencies instead of using cached versions
Expected behavior: Per pnpm continuous integration documentation and GitHub Actions setup-node documentation, the workflow should cache the pnpm store path to avoid re-downloading dependencies. The pattern used in other workflows in this repository adds a get-store-path step that retrieves the pnpm store location, then caches it with actions/cache@v4 using the pnpm-lock.yaml hash as the cache key.
Fix applied: Added pnpm store caching steps matching the established pattern in other workflows, improving build performance and maintaining consistency across the repository.
| run: | | ||
| if [ -f "${{ github.workspace }}/yarn.lock" ]; then | ||
| echo "manager=yarn" >> $GITHUB_OUTPUT | ||
| echo "command=install" >> $GITHUB_OUTPUT | ||
| echo "runner=yarn" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| elif [ -f "${{ github.workspace }}/package.json" ]; then | ||
| echo "manager=npm" >> $GITHUB_OUTPUT | ||
| echo "command=ci" >> $GITHUB_OUTPUT | ||
| echo "runner=npx --no-install" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| else | ||
| echo "Unable to determine package manager" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
The package manager detection script is missing support for pnpm, which appears to be the project's actual package manager (as evidenced by the webpack.yml workflow). Consider adding pnpm detection before the yarn check:
if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=pnpm" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
# existing yarn detectionThis ensures the workflow will correctly identify and use pnpm when appropriate.
| run: | | |
| if [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=yarn" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/package.json" ]; then | |
| echo "manager=npm" >> $GITHUB_OUTPUT | |
| echo "command=ci" >> $GITHUB_OUTPUT | |
| echo "runner=npx --no-install" >> $GITHUB_OUTPUT | |
| exit 0 | |
| else | |
| echo "Unable to determine package manager" | |
| exit 1 | |
| fi | |
| run: | | |
| if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then | |
| echo "manager=pnpm" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=pnpm" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| echo "runner=yarn" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/package.json" ]; then | |
| echo "manager=npm" >> $GITHUB_OUTPUT | |
| echo "command=ci" >> $GITHUB_OUTPUT | |
| echo "runner=npx --no-install" >> $GITHUB_OUTPUT | |
| exit 0 | |
| else | |
| echo "Unable to determine package manager" | |
| exit 1 | |
| fi |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
| - name: Install dependencies | ||
| run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} | ||
| - name: Build with Next.js | ||
| run: ${{ steps.detect-package-manager.outputs.runner }} next build |
There was a problem hiding this comment.
This workflow will fail when attempting to build and deploy because it's configured for a single Next.js app but this is a monorepo, and the expected output directory doesn't match the configuration.
View Details
📝 Patch Details
diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml
index 1e301087fa..6984d4ace0 100644
--- a/.github/workflows/nextjs.yml
+++ b/.github/workflows/nextjs.yml
@@ -39,6 +39,11 @@ jobs:
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
+ elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
+ echo "manager=pnpm" >> $GITHUB_OUTPUT
+ echo "command=install" >> $GITHUB_OUTPUT
+ echo "runner=pnpm exec" >> $GITHUB_OUTPUT
+ exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
@@ -74,11 +79,11 @@ jobs:
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
- run: ${{ steps.detect-package-manager.outputs.runner }} next build
+ run: cd apps/bundle-analyzer && ${{ steps.detect-package-manager.outputs.runner }} next build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
- path: ./out
+ path: ./apps/bundle-analyzer/dist
# Deployment job
deploy:
Analysis
GitHub Actions workflow fails due to incompatible package manager detection and missing Next.js app at root
What fails: The .github/workflows/nextjs.yml workflow fails at the "Install dependencies" step when run on the canary branch because:
- The package manager detection script does not check for
pnpm-lock.yaml, causing it to incorrectly detect this pnpm monorepo as an npm project - The workflow attempts to run
npm ciagainst apnpm-lock.yamlfile, which fails with: "Thenpm cicommand can only install with an existing package-lock.json or npm-shrinkwrap.json" - Even if dependencies installed successfully,
npx --no-install next buildat the repository root fails because there is no Next.js app at the root level and nonext.config.jsfile
How to reproduce:
# The workflow runs this detection logic:
if [ -f "yarn.lock" ]; then
# ... yarn
elif [ -f "package.json" ]; then
# Incorrectly chooses npm, even with pnpm-lock.yaml present
manager=npm
command=ci
fi
# Then attempts:
npm ci # Fails: no package-lock.json existsResult: Workflow execution terminates at "Install dependencies" step with error: "The npm ci command can only install with an existing package-lock.json". If that were to pass, subsequent build step would also fail because next build at the root requires either a next.config.js file or a Next.js app.
Expected behavior:
- The package manager detection should recognize
pnpm-lock.yamland usepnpm install - The build step should target a specific Next.js app in the monorepo (e.g.,
apps/bundle-analyzer) - The artifact upload should use the correct output directory from that app
Changes:
- Added
pnpm-lock.yamldetection to the package manager detection script (before npm fallback) - Changed build step to target
apps/bundle-analyzerwhich has Next.js configured withoutput: 'export'anddistDir: 'dist' - Updated artifact upload path from
./outto./apps/bundle-analyzer/distto match the configured output directory
This fix aligns with Next.js documentation on static exports and the GitHub Pages artifact action.
No description provided.