Skip to content

docs(guides): add import.defer() context module example to lazy loadi…#7982

Merged
alexander-akait merged 3 commits into
webpack:mainfrom
ryzrr:docs/lazy-loading-import-defer-context-example
Mar 11, 2026
Merged

docs(guides): add import.defer() context module example to lazy loadi…#7982
alexander-akait merged 3 commits into
webpack:mainfrom
ryzrr:docs/lazy-loading-import-defer-context-example

Conversation

@ryzrr
Copy link
Copy Markdown
Member

@ryzrr ryzrr commented Mar 11, 2026

Summary

This PR replaces the incomplete import.defer() context module example in the lazy loading guide as the previous code block contained a commented out call (// const modules = import.defer(...)) that was never finished, leaving the section without a working example. The new example shows deferred evaluation of locale modules selected via a dynamic path expression, demonstrating how webpack includes all matching modules in the module graph while deferring execution until a property is first accessed.

What kind of change does this PR introduce?

Docs change

Did you add tests for your changes?

No

Does this PR introduce a breaking change?

No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

The import.defer() context module support was shipped in webpack 5.105 and documented in the release blog post, but the corresponding section in the lazy loading guide was left with a stub example and this PR closes that gap directly in the guide.

Use of AI

N/A

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-js-org Ready Ready Preview, Comment Mar 11, 2026 1:46pm

Request Review

});
```

In this example, the locale module is loaded and parsed, but its evaluation is deferred until you access the namespace object. This allows you to load multiple locale files without executing them immediately.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before description was more useful, I think better to rewrite it union your and this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I combined the previous explanation with the updated wording.

@ryzrr
Copy link
Copy Markdown
Member Author

ryzrr commented Mar 11, 2026

Commited some changes regarding fixing the lint issue test due to import.defer().

@alexander-akait alexander-akait merged commit a6e02a7 into webpack:main Mar 11, 2026
8 of 9 checks passed
pranjalisr pushed a commit to pranjalisr/webpack.js.org that referenced this pull request Mar 12, 2026
webpack#7982)

* docs(guides): add import.defer() context module example to lazy loading guide

* docs(guides): fix eslint error and address maintainer review on closing sentence

* docs(guides): use text fence for import.defer() block to fix eslint parse error
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.

2 participants