codeant-ai-for-open-source[bot] commented on code in PR #42511: URL: https://github.com/apache/superset/pull/42511#discussion_r3663520802
########## superset-frontend/scripts/bundle-size-summary.js: ########## @@ -0,0 +1,78 @@ +#!/usr/bin/env node +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +// Reduces a webpack `--json` stats file down to the handful of headline +// numbers worth tracking over time, in the flat array format +// benchmark-action/github-action-benchmark expects for its +// "customSmallerIsBetter" tool. The full stats file also includes a +// `modules`/`chunks` graph across ~15k modules, which is enormous and not +// useful for this purpose, so we only ever read `entrypoints`. +// +// Usage: node scripts/bundle-size-summary.js <path-to-stats.json> + +const fs = require('fs'); + +// Entrypoints worth tracking: the two user-facing app shells. `menu`, +// `preamble`, `theme`, and `service-worker` are small, low-variance +// infrastructure chunks, not where bundle bloat actually shows up. +const TRACKED_ENTRYPOINTS = ['spa', 'embedded']; + +function entrypointSizeByExt(entrypoint, ext) { + return (entrypoint.assets || []) + .filter(asset => asset.name.endsWith(ext)) + .reduce((total, asset) => total + asset.size, 0); +} + +function main() { + const statsPath = process.argv[2]; + if (!statsPath) { + console.error('Usage: bundle-size-summary.js <path-to-stats.json>'); + process.exit(1); + } + + const stats = JSON.parse(fs.readFileSync(statsPath, 'utf8')); + const { entrypoints } = stats; + if (!entrypoints) { + console.error( + 'stats.json has no `entrypoints` key -- was it generated with ' + + '`--stats=normal` (or richer)? `minimal`/`errors-only` stats omit it.', + ); + process.exit(1); + } + + const results = []; + TRACKED_ENTRYPOINTS.forEach(name => { + const entrypoint = entrypoints[name]; + if (!entrypoint) return; Review Comment: **Suggestion:** Missing tracked entrypoints are silently ignored, so if `spa` or `embedded` is renamed, omitted, or no longer emitted, the script exits successfully with incomplete or empty benchmark data. This prevents the CI benchmark action from detecting the missing bundle and can disable tracking without any build failure; validate that every required tracked entrypoint exists and fail the script when one is absent. [incomplete implementation] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ⚠️ Bundle history becomes incomplete after entrypoint changes. - ⚠️ CI can report success while tracking fewer bundles. - ❌ Regressions in omitted entrypoints become invisible. ``` </details> <details> <summary><b>Steps of Reproduction ✅ </b></summary> ```mdx 1. The `bundle-size` job in `.github/workflows/superset-frontend.yml:241-246` builds webpack statistics and invokes `superset-frontend/scripts/bundle-size-summary.js`. 2. Production webpack currently declares `spa` and `embedded` entries at `superset-frontend/webpack.config.js:338-339`, so both are normally present in the generated `entrypoints` object. 3. Rename either entry in `webpack.config.js` or remove it while leaving `TRACKED_ENTRYPOINTS` unchanged at `superset-frontend/scripts/bundle-size-summary.js:34`; the build can still produce a valid stats file containing the remaining entries. 4. At `superset-frontend/scripts/bundle-size-summary.js:60-62`, the missing entry is skipped instead of causing a nonzero exit. The script then writes incomplete benchmark data at line 75, and the workflow proceeds to `benchmark-action` at `.github/workflows/superset-frontend.yml:249-255` without tracking the missing bundle. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6b765c4505b74b6b8c4b07f2cdbcc90c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6b765c4505b74b6b8c4b07f2cdbcc90c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/scripts/bundle-size-summary.js **Line:** 60:62 **Comment:** *Incomplete Implementation: Missing tracked entrypoints are silently ignored, so if `spa` or `embedded` is renamed, omitted, or no longer emitted, the script exits successfully with incomplete or empty benchmark data. This prevents the CI benchmark action from detecting the missing bundle and can disable tracking without any build failure; validate that every required tracked entrypoint exists and fail the script when one is absent. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42511&comment_hash=bc8cf3abfe4a256c5bb78a1839b539b599d966daf872a9f777d04701152edc11&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42511&comment_hash=bc8cf3abfe4a256c5bb78a1839b539b599d966daf872a9f777d04701152edc11&reaction=dislike'>👎</a> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
