Skip to content

Next.js新分支 - #86174

Closed
dofaromg wants to merge 9 commits into
vercel:canaryfrom
dofaromg:canary
Closed

dofaromg wants to merge 9 commits into
vercel:canaryfrom
dofaromg:canary

Conversation

@dofaromg

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/webpack.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +25 to +28
- name: Build
run: |
npm install
npx webpack

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@dofaromg

dofaromg commented Nov 16, 2025 via email

Copy link
Copy Markdown
Author

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- name: Build
run: |
pnpm install
npx webpack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
npx webpack
pnpm build

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +30 to +33
- name: Build
run: |
pnpm install
npx webpack

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Result:

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.

@dofaromg dofaromg left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

👍

Mr.liou added 4 commits November 18, 2025 13:20
This workflow builds and deploys a Next.js site to GitHub Pages, handling package manager detection, caching, and artifact upload.
Comment on lines +25 to +33
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Build
run: |
pnpm install
npx webpack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. Check .github/workflows/webpack.yml lines 25-33 - no pnpm store caching is present
  2. 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-path and actions/cache@v4
  3. 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.

Comment on lines +36 to +50
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 detection

This ensures the workflow will correctly identify and use pnpm when appropriate.

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

Fix in Graphite


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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. The package manager detection script does not check for pnpm-lock.yaml, causing it to incorrectly detect this pnpm monorepo as an npm project
  2. The workflow attempts to run npm ci against a pnpm-lock.yaml file, which fails with: "The npm ci command can only install with an existing package-lock.json or npm-shrinkwrap.json"
  3. Even if dependencies installed successfully, npx --no-install next build at the repository root fails because there is no Next.js app at the root level and no next.config.js file

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 exists

Result: 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:

  1. The package manager detection should recognize pnpm-lock.yaml and use pnpm install
  2. The build step should target a specific Next.js app in the monorepo (e.g., apps/bundle-analyzer)
  3. The artifact upload should use the correct output directory from that app

Changes:

  • Added pnpm-lock.yaml detection to the package manager detection script (before npm fallback)
  • Changed build step to target apps/bundle-analyzer which has Next.js configured with output: 'export' and distDir: 'dist'
  • Updated artifact upload path from ./out to ./apps/bundle-analyzer/dist to match the configured output directory

This fix aligns with Next.js documentation on static exports and the GitHub Pages artifact action.

@github-actions github-actions Bot added the locked label Dec 9, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants