-
-
Notifications
You must be signed in to change notification settings - Fork 92
fix(loadable-components): Support aliased loadable imports #585
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?
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