Conversation
…ents-package-entrypoint
…add-js-extension, modify tsconfig and import paths
…sg/isomer-components
… in render components
…splitting-components-package-entrypoint
…splitting-components-package-entrypoint
…ent types in schemas and constants
…data handling; update ESLint config and package dependencies
packages/components/src/templates/next/layouts/DatabaseSkeleton/DatabaseSkeleton.tsx
Outdated
Show resolved
Hide resolved
…e names and implement corresponding unit tests
…or accurate rendering
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
packages/components/src/templates/next/layouts/DatabaseSkeleton/DatabaseSkeleton.tsx
Show resolved
Hide resolved
…nt path traversal vulnerabilities
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
packages/components/src/templates/next/layouts/DatabaseSkeleton/DatabaseSkeleton.tsx
Show resolved
Hide resolved
…file and enhancing file copy logic
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
packages/components/src/templates/next/layouts/DatabaseSkeleton/DatabaseSkeleton.tsx
Show resolved
Hide resolved
…g in page processing
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
|
||
| # Build the site | ||
| echo "Building site..." | ||
| # Installing dependencies |
There was a problem hiding this comment.
build.sh deletes scripts directory before build:prepare runs
High Severity
The pre-existing rm -rf scripts cleanup step (line 48) deletes the entire scripts/ directory after running generate-sitemap.js. The newly added npm run build:prepare (line 69) then tries to execute tsx scripts/analyze-sitemap.ts, tsx scripts/generate-pages.ts, and tsx scripts/update-pages.ts — but those files no longer exist. This will crash the Amplify build pipeline for every site using build.sh.
Additional Locations (1)
…in compatibility and improve comment preservation during parsing
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } catch { | ||
| if (permalink === "") { | ||
| return null | ||
| } |
There was a problem hiding this comment.
Dead code: readSchema checks empty string instead of root
Low Severity
In readSchema, the condition permalink === "" on the catch path is dead code. All permalinks from extractPages come from the sitemap and start with "/" (e.g., the root is "/"), so this condition is never true. The intended check was likely permalink === "/" to skip the redundant fallback retry for the root page, since getSchemaPath("/") already constructs the _index.json path, and the fallback constructs the identical path.
…ng page file discovery logic
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| "parentPath" in e && typeof e.parentPath === "string" ? e.parentPath : dir | ||
| return path.join(parentPath, e.name) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Incorrect nested file paths on Node 18
Medium Severity
findPageFiles checks for parentPath on Dirent entries, but this property was only added in Node 20.12/21.4. On Node 18 (which is supported per the next peer dependency ^18.18.0), parentPath doesn't exist, so the fallback uses the root dir for every entry. This causes all nested page files (e.g., app/about/page.tsx) to be incorrectly resolved to the root app/page.tsx path. The Dirent.path property (available since Node 18.17) is the correct fallback but is never checked.


Important
This is dropped because having just 2k+ pages resulted in nextjs build to spike by 10 minutes during the
Creating an optimized production build ...phase and require us bumping the CodeBuild instance size from medium to large for the increased RAM usageProblem
Closes [insert issue #]
Solution
Breaking Changes
Features:
Improvements:
Bug Fixes:
Before & After Screenshots
BEFORE:
AFTER:
Tests
New scripts:
script: script detailsNew dependencies:
dependency: dependency detailsNew dev dependencies:
dependency: dependency detailsNote
Medium Risk
Introduces a new build-time codegen pipeline that rewrites/duplicates Next.js
app/*/page.tsxfiles and prunes imports/switch cases via AST transforms, which could break routing/rendering if the analysis or transforms are wrong. Also changes public export paths for@opengovsg/isomer-components, requiring consumers to use subpath imports for correct bundling.Overview
Enables page-level renderer optimization for the Next.js base template by adding a
build:preparestep that analyzespublic/sitemap.json, generates missingapp/.../page.tsxfiles, and rewrites each page to setSTATIC_ROUTE_PERMALINKand prune unused layout/component imports and switch cases (via newscripts/analyze-sitemap.ts,generate-pages.ts,update-pages.ts+ Vitest coverage).Refactors
@opengovsg/isomer-componentsto be more tree-shakeable: adds explicit subpathexportsforengine/*,types, and Next template internals, splitsgetRobotsTxt/getSitemapXml/shouldBlockIndexinginto standalone engine modules, and extracts layout/page-content logic into reusable*Skeletonhelpers.Updates the template to stop root-importing
@opengovsg/isomer-components, adds ESLint enforcement against root imports, and wires new build steps intotooling/buildscripts and CI (new unit tests forisomer-base-template). Also bumpsnextand updates related lockfile dependencies (e.g.tsx/esbuild).Written by Cursor Bugbot for commit 69e800b. This will update automatically on new commits. Configure here.