Skip to content

feat: support import defer in module graph#640

Merged
bartlomieju merged 1 commit intomainfrom
feat/import-defer
Apr 20, 2026
Merged

feat: support import defer in module graph#640
bartlomieju merged 1 commit intomainfrom
feat/import-defer

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

Include import defer and import.defer() dependencies in the module graph instead of skipping them.

Previously, deferred imports were returned from (return) in the dependency collector, meaning they were completely excluded from the module graph. This caused Loading unprepared module errors at runtime because the deferred module was never fetched or compiled.

Deferred imports need to be in the graph so they are fetched and compiled (prepared), even though evaluation is deferred until first namespace access at runtime.

Changes

  • Added ImportDefer variant to StaticDependencyKind and DynamicDependencyKind
  • Deferred imports are treated as ES module imports for graph building (same ImportKind::Es, same resolution mode)

Needed by denoland/deno#32360 (TC39 import defer proposal).

🤖 Generated with Claude Code

Include `import defer` and `import.defer()` dependencies in the module
graph instead of skipping them. Deferred imports need to be fetched and
compiled (prepared) so the runtime can instantiate them, even though
evaluation is deferred until first namespace access.

Added `ImportDefer` variant to both `StaticDependencyKind` and
`DynamicDependencyKind`. Deferred imports are treated as ES module
imports for graph building purposes (same resolution mode and import
kind as regular imports).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju merged commit e53d47d into main Apr 20, 2026
20 checks passed
@bartlomieju bartlomieju deleted the feat/import-defer branch April 20, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant