Skip to content

Conversation

@ahabhgk
Copy link
Contributor

@ahabhgk ahabhgk commented Jan 30, 2026

Summary

port webpack/webpack#20064

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 30, 2026 09:37
@ahabhgk ahabhgk requested a review from LingyuCoder as a code owner January 30, 2026 09:37
@ahabhgk ahabhgk enabled auto-merge (squash) January 30, 2026 09:37
@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Jan 30, 2026
Copy link
Contributor

Copilot AI left a 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_SYMBOL to DEFERRED_MODULES_ASYNC_TRANSITIVE_DEPENDENCIES_SYMBOL for better clarity
  • Enhanced runtime modules to handle async transitive dependencies in deferred imports
  • Extended parser plugins and dependency classes to support the ImportPhase parameter

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.5 KB 0
react-5k 2.7 MB 0
rome 984.2 KB 0
ui-components 2.3 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

📦 Binary Size-limit

Comparing c925c7a to fix: prevent server actions from being removed in production build (#12898) by Cong-Cong Pan

❌ Size increased by 4.50KB from 48.31MB to 48.31MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 30, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing statical-path-dyn-import-defer (c925c7a) with main (b7bcbce)

Summary

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@ahabhgk ahabhgk merged commit 953025e into main Feb 2, 2026
99 of 103 checks passed
@ahabhgk ahabhgk deleted the statical-path-dyn-import-defer branch February 2, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants