fix(loadable-components): Support aliased loadable imports#585
fix(loadable-components): Support aliased loadable imports#585
Conversation
Make the 'from' field in Signature optional to allow matching any import with a specific name regardless of source package. This enables support for vendored or aliased loadable implementations. - Made Signature.from an Option<Wtf8Atom> - Updated visit_mut_import_decl to skip source check when from is None - Added test case for vendored loadable imports - Updated documentation with usage examples Fixes #572 Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
|
|
Code ReviewSummaryThis PR successfully addresses issue #572 by adding support for aliased/vendored imports. The implementation allows the plugin to transform calls regardless of their import source when configured with a signature that omits the Code Quality ✅Strengths:
Observations:
Testing ✅Strengths:
Suggestions:
vec![
Signature { name: "default".into(), from: None },
Signature { name: "lazy".into(), from: Some("@loadable/component".into()) }
]
Security Considerations ✅No security concerns identified:
Performance Considerations ✅Analysis:
Potential Issues & Edge Cases
Documentation ✅Strengths:
Minor suggestion: Best Practices ✅
Recommendation: APPROVE ✅This is a well-implemented feature that:
The implementation is production-ready. The minor suggestions above are optional enhancements, not blockers. |
Code ReviewSummaryThis PR successfully addresses issue #572 by adding support for aliased/vendored loadable imports. The implementation allows the plugin to transform loadable() calls regardless of their import source when configured with a signature that omits the from field. Code Quality ✅Strengths:
Observations:
Testing ✅Strengths:
Suggestions for additional test coverage:
Security Considerations ✅No security concerns identified:
Performance Considerations ✅Analysis:
Potential Issues & Edge Cases
Documentation ✅Strengths:
Minor suggestion: Best Practices ✅
Recommendation: APPROVE ✅This is a well-implemented feature that:
The implementation is production-ready. The minor suggestions above are optional enhancements, not blockers. |
Summary
This PR fixes the issue where the @swc/plugin-loadable-components plugin would not transform
loadable()calls when imported from vendored or aliased packages.Changes
fromfield in theSignaturestruct optional (Option<Wtf8Atom>)visit_mut_import_declto skip source checking whenfromisNoneUsage
To enable aliased imports, configure with a signature that omits the
fromfield:This matches the behavior of the official Babel plugin as documented in the Loadable documentation.
Fixes #572
Generated with Claude Code) | View branch | [View job run](https://github.com/swc-project/plugins/actions/runs/21084641572