fix: empty chunk generated and imported when using advancedChunks#8625
fix: empty chunk generated and imported when using advancedChunks#8625AliceLanniste wants to merge 6 commits into
Conversation
| if !(import_str.starts_with("import") && import_str.contains("from")) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
This check will incorrectly return false for side-effect imports that don't use the from keyword:
import './side-effect-module'Such imports start with "import" but don't contain "from". This could cause modules with side-effect imports to be misclassified, potentially leading to incorrect pure re-export detection. The logic should handle all valid import statement formats including side-effect imports.
| if !(import_str.starts_with("import") && import_str.contains("from")) { | |
| return false; | |
| } | |
| if !import_str.starts_with("import") { | |
| return false; | |
| } |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
| if export_str.contains("import") { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
String pattern matching is too simplistic and will cause false positives. The check if export_str.contains("import") will incorrectly reject valid reexport statements that contain the substring "import" in identifiers (e.g., export { importantData } from './data'). This will cause modules to be incorrectly classified as non-pure-reexports, preventing proper chunk optimization.
// This check is too broad - it rejects any statement containing "import"
// even if "import" appears in a variable name like "importantData"
if export_str.contains("import") {
return false;
}Recommendation: Use proper AST-based checks instead of string matching, or use more precise regex patterns that match only the import keyword.
| if export_str.contains("import") { | |
| return false; | |
| } | |
| if export_str.contains(" import ") || export_str.starts_with("import ") { | |
| return false; | |
| } |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
d6991a2 to
2c42605
Compare
related #6677