-
-
Notifications
You must be signed in to change notification settings - Fork 757
feat: support import.defer() for statical path
#12900
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for import.defer() with static paths, porting functionality from webpack. The feature enables deferred loading of modules without blocking the main thread, allowing for more efficient code splitting and lazy loading.
Changes:
- Added test cases for
import.defer()with both static syntax (import.defer()) and dynamic import syntax in various scenarios - Refactored runtime symbols from
MAKE_DEFERRED_NAMESPACE_OBJECT_SYMBOLtoDEFERRED_MODULES_ASYNC_TRANSITIVE_DEPENDENCIES_SYMBOLfor better clarity - Enhanced runtime modules to handle async transitive dependencies in deferred imports
- Extended parser plugins and dependency classes to support the
ImportPhaseparameter
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/configCases/defer-import/defer-runtime/all-dynamic-import-native-syntax.js | Comprehensive test suite for deferred imports covering CommonJS, ESM, and various export patterns |
| tests/rspack-test/configCases/defer-import/defer-runtime-dynamic-import-native-syntax/rspack.config.js | Configuration enabling deferImport experiment for dynamic import tests |
| tests/rspack-test/configCases/defer-import/async-in-graph-dynamic-import/webpack.config.js | Configuration for async dependency graph tests (file naming issue) |
| tests/rspack-test/configCases/defer-import/async-in-graph-dynamic-import/index.js | Test validating deferred module loading behavior with async dependencies |
| tests/rspack-test/configCases/defer-import/async-in-graph-dynamic-import/entry.js | Entry point demonstrating deferred imports with async module graph |
| crates/rspack_plugin_runtime/src/runtime_module/runtime/make_optimized_deferred_namespace_object.ejs | Updated to use renamed async transitive dependencies symbol |
| crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs | Added async transitive dependencies function and refactored deferred module handling |
| crates/rspack_plugin_rstest/src/parser_plugin.rs | Added ImportPhase parameter to dependency creation |
| crates/rspack_plugin_lazy_compilation/src/module.rs | Added ImportPhase parameter to async dependency creation |
| crates/rspack_plugin_javascript/src/parser_plugin/import_parser_plugin.rs | Added phase detection, validation, and error messages for defer imports |
| crates/rspack_plugin_javascript/src/dependency/esm/import_eager_dependency.rs | Added phase field and getter to support defer imports |
| crates/rspack_plugin_javascript/src/dependency/esm/import_dependency.rs | Added phase field and getter to support defer imports |
| crates/rspack_core/src/runtime_template.rs | Added deferred module handling logic in module_namespace_promise with async dependency tracking |
| crates/rspack_core/src/runtime_globals.rs | Renamed and added runtime globals for deferred modules async transitive dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/rspack-test/configCases/defer-import/async-in-graph-dynamic-import/rspack.config.js
Show resolved
Hide resolved
crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs
Outdated
Show resolved
Hide resolved
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 4.50KB from 48.31MB to 48.31MB (⬆️0.01%) |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
Summary
port webpack/webpack#20064
Related links
Checklist