Fix release standalone frontend path#139
Conversation
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
scripts/build-release.mjs (2)
85-90: ⚡ Quick winCache the repeated condition check.
The condition
existsSync(fromRoot("./frontend/frontend/server.js"))is evaluated twice. Cache the result to avoid redundant filesystem checks and improve maintainability.♻️ Proposed refactor
-const frontendServerPath = existsSync(fromRoot("./frontend/frontend/server.js")) - ? fromRoot("./frontend/frontend/server.js") - : fromRoot("./frontend/server.js"); -const frontendCwd = existsSync(fromRoot("./frontend/frontend/server.js")) - ? fromRoot("./frontend/frontend") - : fromRoot("./frontend"); +const hasNestedLayout = existsSync(fromRoot("./frontend/frontend/server.js")); +const frontendServerPath = hasNestedLayout + ? fromRoot("./frontend/frontend/server.js") + : fromRoot("./frontend/server.js"); +const frontendCwd = hasNestedLayout + ? fromRoot("./frontend/frontend") + : fromRoot("./frontend");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/build-release.mjs` around lines 85 - 90, The duplicate filesystem check existsSync(fromRoot("./frontend/frontend/server.js")) used to compute frontendServerPath and frontendCwd should be evaluated once and stored in a local boolean; update the code so you compute a const e.g. hasNestedFrontend = existsSync(fromRoot("./frontend/frontend/server.js")) and then use hasNestedFrontend to choose values for frontendServerPath and frontendCwd (referencing the symbols frontendServerPath, frontendCwd, existsSync, and fromRoot) to eliminate the redundant check.
235-239: ⚡ Quick winValidate that server.js exists in the fallback path.
The function returns the fallback directory without verifying that
server.jsexists there. If Next.js produces an unexpected structure, assets will be copied to the wrong location and the release will fail at runtime with unclear errors.🛡️ Proposed defensive check
function releaseFrontendAppDir() { const nested = join(packageRoot, "frontend", "frontend"); if (existsSync(join(nested, "server.js"))) return nested; - return join(packageRoot, "frontend"); + const flat = join(packageRoot, "frontend"); + if (!existsSync(join(flat, "server.js"))) { + throw new Error( + "Could not find server.js in Next standalone output. " + + "Expected either frontend/frontend/server.js or frontend/server.js." + ); + } + return flat; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/build-release.mjs` around lines 235 - 239, In releaseFrontendAppDir make the fallback path safe: after computing nested and checking existsSync(join(nested, "server.js")), also verify existsSync(join(packageRoot, "frontend", "server.js")) before returning the fallback; if that file is missing, throw or log a clear error (or exit) indicating server.js was not found in either nested or fallback so the release process stops early. Reference releaseFrontendAppDir, nested and packageRoot to locate where to add the second existsSync check and the error handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@scripts/build-release.mjs`:
- Around line 85-90: The duplicate filesystem check
existsSync(fromRoot("./frontend/frontend/server.js")) used to compute
frontendServerPath and frontendCwd should be evaluated once and stored in a
local boolean; update the code so you compute a const e.g. hasNestedFrontend =
existsSync(fromRoot("./frontend/frontend/server.js")) and then use
hasNestedFrontend to choose values for frontendServerPath and frontendCwd
(referencing the symbols frontendServerPath, frontendCwd, existsSync, and
fromRoot) to eliminate the redundant check.
- Around line 235-239: In releaseFrontendAppDir make the fallback path safe:
after computing nested and checking existsSync(join(nested, "server.js")), also
verify existsSync(join(packageRoot, "frontend", "server.js")) before returning
the fallback; if that file is missing, throw or log a clear error (or exit)
indicating server.js was not found in either nested or fallback so the release
process stops early. Reference releaseFrontendAppDir, nested and packageRoot to
locate where to add the second existsSync check and the error handling.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b92340b7-3db0-42bb-91ef-b94a2d3ed392
📒 Files selected for processing (1)
scripts/build-release.mjs
Summary
frontend/frontend/server.jsorfrontend/server.jspublicand.next/staticnext to the actual standalone server directoryCannot find module .../frontend/frontend/server.jswhen Next emits a flattened standalone layoutVerification
make -f makefiles/Makefile build-releasefrontend/frontend/server.jsin the current local buildstart.mjsincludes fallback logic for both server paths