codeant-ai-for-open-source[bot] commented on code in PR #41117:
URL: https://github.com/apache/superset/pull/41117#discussion_r3421706497


##########
superset-frontend/src/extensions/ExtensionsStartup.tsx:
##########
@@ -20,6 +20,8 @@ import { useEffect, useRef } from 'react';
 import { useLocation } from 'react-router-dom';
 import { logging } from '@apache-superset/core/utils';
 import { FeatureFlag, isFeatureEnabled } from '@superset-ui/core';
+// eslint-disable-next-line no-restricted-syntax
+import * as supersetCore from '@apache-superset/core';

Review Comment:
   **Suggestion:** Using a namespace import of the whole 
`@apache-superset/core` package forces loading a much larger module surface 
than needed and defeats fine-grained tree-shaking for startup code. Since this 
runs during app boot, it adds avoidable bundle and initialization cost. Drop 
the wildcard import and only expose the already imported explicit namespaces. 
[performance]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Initial frontend bundle includes unnecessary core exports.
   - ⚠️ App boot time increases due to larger startup chunk.
   - ⚠️ Tree-shaking effectiveness reduced for extension startup path.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Build or run the frontend so that `superset-frontend/src/views/App.tsx` 
is used as the
   root; `App` imports `ExtensionsStartup` at line 42 and renders it 
unconditionally at lines
   14-24, placing it in the main initial bundle.
   
   2. `ExtensionsStartup` imports the entire `@apache-superset/core` namespace 
via `import *
   as supersetCore from '@apache-superset/core';` at
   `superset-frontend/src/extensions/ExtensionsStartup.tsx:23-24`, and then 
spreads
   `supersetCore` into `window.superset` at line 82, forcing the bundler to 
retain the whole
   namespace.
   
   3. Build the production bundle (e.g., standard Superset frontend build) and 
inspect the
   generated JS chunks: because `supersetCore` is referenced as a whole in
   `ExtensionsStartup.tsx:82`, tree-shaking cannot discard unused exports, so 
the startup
   chunk includes the full `@apache-superset/core` surface instead of only the 
explicitly
   imported host namespaces from `'src/core'`.
   
   4. Load the app in a browser and inspect the Network tab: the initial 
application bundle
   that includes `ExtensionsStartup` (and thus the wildcard core import) is 
larger and must
   be parsed and executed on every app boot, adding avoidable bundle size and 
initialization
   cost even if extensions only need the explicitly listed namespaces.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=73b9a1e7b52548dc86e990f3c5e60bc4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=73b9a1e7b52548dc86e990f3c5e60bc4&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/src/extensions/ExtensionsStartup.tsx
   **Line:** 23:24
   **Comment:**
        *Performance: Using a namespace import of the whole 
`@apache-superset/core` package forces loading a much larger module surface 
than needed and defeats fine-grained tree-shaking for startup code. Since this 
runs during app boot, it adds avoidable bundle and initialization cost. Drop 
the wildcard import and only expose the already imported explicit namespaces.
   
   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%2F41117&comment_hash=acc4bd4b561da002f55e523d6ea0e141e0540b0e9e30a68fddd1fe915147f6bc&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41117&comment_hash=acc4bd4b561da002f55e523d6ea0e141e0540b0e9e30a68fddd1fe915147f6bc&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]

Reply via email to