-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Cache frontend build across setup runs #4404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1f075a9
5e36f09
153c203
21de1c5
21e549c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,13 +41,27 @@ if [[ "$keynames" == *$'\nCOLAB_'* ]]; then | |||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # ── Detect whether frontend needs building ── | ||||||||||||||
| # Only skip when BOTH conditions are true: | ||||||||||||||
| # 1. We're inside site-packages (PyPI / pip install, not editable) | ||||||||||||||
| # 2. dist/ already exists (pre-built in the wheel) | ||||||||||||||
| # Otherwise always (re)build — handles upgrades, editable installs, and | ||||||||||||||
| # pip-from-source where dist/ was never built. | ||||||||||||||
| if [[ "$SCRIPT_DIR" == */site-packages/* ]] && [ -d "$SCRIPT_DIR/frontend/dist" ]; then | ||||||||||||||
| echo "✅ Frontend pre-built (PyPI) — skipping Node/npm check." | ||||||||||||||
| # Skip if dist/ exists AND no tracked input is newer than dist/. | ||||||||||||||
| # Checks top-level config/entry files and src/, public/ recursively. | ||||||||||||||
| # This handles: PyPI installs (dist/ bundled), repeat runs (no changes), | ||||||||||||||
| # and upgrades/pulls (source newer than dist/ triggers rebuild). | ||||||||||||||
| _NEED_FRONTEND_BUILD=true | ||||||||||||||
| if [ -d "$SCRIPT_DIR/frontend/dist" ]; then | ||||||||||||||
| # Check top-level config and entry files (package.json, vite.config.ts, index.html, etc.) | ||||||||||||||
| _changed=$(find "$SCRIPT_DIR/frontend" -maxdepth 1 \ | ||||||||||||||
| \( -name "*.json" -o -name "*.ts" -o -name "*.js" -o -name "*.mjs" -o -name "*.html" \) \ | ||||||||||||||
| -newer "$SCRIPT_DIR/frontend/dist" -print -quit 2>/dev/null) | ||||||||||||||
|
Comment on lines
+51
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||
| # Check src/ and public/ recursively | ||||||||||||||
| if [ -z "$_changed" ]; then | ||||||||||||||
| _changed=$(find "$SCRIPT_DIR/frontend/src" "$SCRIPT_DIR/frontend/public" \ | ||||||||||||||
| -type f -newer "$SCRIPT_DIR/frontend/dist" -print -quit 2>/dev/null) | ||||||||||||||
|
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With Useful? React with 👍 / 👎. |
||||||||||||||
| fi | ||||||||||||||
| if [ -z "$_changed" ]; then | ||||||||||||||
| _NEED_FRONTEND_BUILD=false | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
| if [ "$_NEED_FRONTEND_BUILD" = false ]; then | ||||||||||||||
| echo "✅ Frontend already built and up to date -- skipping Node/npm check." | ||||||||||||||
|
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This condition now controls the whole Node block, including the later Useful? React with 👍 / 👎. |
||||||||||||||
| else | ||||||||||||||
| NEED_NODE=true | ||||||||||||||
| if command -v node &>/dev/null && command -v npm &>/dev/null; then | ||||||||||||||
|
|
@@ -146,12 +160,17 @@ run_quiet "npm run build" npm run build | |||||||||||||
|
|
||||||||||||||
| _restore_gitignores | ||||||||||||||
| trap - EXIT | ||||||||||||||
| cd "$SCRIPT_DIR/backend/core/data_recipe/oxc-validator" | ||||||||||||||
| run_quiet "npm install (oxc validator runtime)" npm install | ||||||||||||||
| cd "$SCRIPT_DIR" | ||||||||||||||
| echo "✅ Frontend built to frontend/dist" | ||||||||||||||
|
|
||||||||||||||
| fi # end frontend dist check | ||||||||||||||
| fi # end frontend build check | ||||||||||||||
|
|
||||||||||||||
| # ── oxc-validator runtime (always install, independent of frontend build) ── | ||||||||||||||
| if [ -d "$SCRIPT_DIR/backend/core/data_recipe/oxc-validator" ] && command -v npm &>/dev/null; then | ||||||||||||||
| cd "$SCRIPT_DIR/backend/core/data_recipe/oxc-validator" | ||||||||||||||
| run_quiet "npm install (oxc validator runtime)" npm install | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This Useful? React with 👍 / 👎. |
||||||||||||||
| cd "$SCRIPT_DIR" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # ── 6. Python venv + deps ── | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new guard skips the entire frontend build whenever
frontend/distalready exists, so a developer who runssetup.sh, pulls new frontend changes, and runs setup again will keep serving stale assets from the previous commit. That can produce UI/backend contract mismatches (new backend endpoints or payloads with old JS bundle) even though setup reports success; the previous logic rebuilt for editable/source installs specifically to avoid this upgrade path regression.Useful? React with 👍 / 👎.