fix: should have js entry for importModule assets and rslib#12167
fix: should have js entry for importModule assets and rslib#12167
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where asset entries and loader importModule calls were not generating the necessary JavaScript entry files. The fix ensures that when using importModule to point to assets, or when using RslibPlugin with asset entries, a proper JavaScript module is generated instead of an empty result.
Key changes:
- Modified the
AssetParserAndGeneratorto include JavaScript source type for loader imports - Created a wrapper
RslibAssetParserAndGeneratorto customize source types for asset entry resources - Changed the
NormalModuleFactoryParserhook signature to useBox<dyn ParserAndGenerator>instead of raw reference
Reviewed Changes
Copilot reviewed 16 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_plugin_asset/src/lib.rs |
Added logic to include JavaScript source type for LoaderImport dependencies and made AssetParserAndGenerator Clone-able |
crates/rspack_plugin_rslib/src/asset.rs |
New wrapper around AssetParserAndGenerator that returns JavaScript+Asset source types for entry resources |
crates/rspack_plugin_rslib/src/plugin.rs |
Integrated RslibAssetParserAndGenerator for asset parsers |
crates/rspack_core/src/normal_module_factory.rs |
Changed parser hook parameter from mutable reference to Box |
tests/rspack-test/configCases/loader-import-module/assets/ |
Added test case for loader importModule with assets |
tests/rspack-test/configCases/rslib/asset-entry/ |
Added test case for rslib with asset entry |
| Multiple plugin files | Updated to match new parser hook signature |
crates/rspack_plugin_rslib/Cargo.toml |
Added dependencies needed for asset wrapper |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 5.38KB from 48.09MB to 48.10MB (⬆️0.01%) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CodSpeed Performance ReportMerging #12167 will not alter performanceComparing Summary
|
Summary
Should have a js module when using importModule point to assets, otherwise it will get empty result by importModule. RslibPlugin also needs this js module to implements bundleless features.
Related links
Checklist