Skip to content

docs($api/module-methods): add eager-weak + notes to resolveWeak#1453

Merged
skipjack merged 4 commits intowebpack:masterfrom
faceyspacey:eager-resolve-weak
Aug 11, 2017
Merged

docs($api/module-methods): add eager-weak + notes to resolveWeak#1453
skipjack merged 4 commits intowebpack:masterfrom
faceyspacey:eager-resolve-weak

Conversation

@faceyspacey
Copy link
Contributor

Docs update corresponding to:

webpack/webpack#5235

@skipjack
Copy link
Contributor

skipjack commented Jul 25, 2017

@faceyspacey thanks for remembering to add documentation for this new feature. Let's wait until webpack/webpack#5235 is merged and released to merge and release this. Once the main PR is merged we should probably ping a few others for review as I'm not too familiar with this topic.

- `"lazy"` (default): Generates a lazy-loadable chunk for each `import()`ed module.
- `"lazy-once"`: Generates a single lazy-loadable chunk that can satisfy all calls to `import()`. The chunk will be fetched on the first call to `import()`, and subsequent calls to `import()` will use the same network response. Note that this only makes sense in the case of a partially dynamic statement, e.g. ``import(`./locales/${language}.json`)``, where there are multiple module paths that could potentially be requested.
- `"eager"`: Generates no extra chunk. All modules are included in the current chunk and no additional network requests are made. A `Promise` is still returned but is already resolved. In contrast to a static import, the module isn't executed until the call to `import()` is made.
- `"eager-weak"`: Generates chunks identically to `"lazy"`, but leaves the responsibility of serving the chunks to the client up to the user. A `Promise` is still returned but, only successfully resolves if the chunks are already on the client. A network request will never be performed. This is useful for universal rendering when required chunks are always manually served in initial requests (embedded within the page), but not in cases where app navigation will trigger an import not initially served.
Copy link
Member

Choose a reason for hiding this comment

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

"weak": Tries to load the module if the module function has already been loaded in some other way (i. e. another chunk imported it or a script containing the module was loaded). A Promise is still returned but, only successfully resolves if the chunks are already on the client. If the module is not available, the Promise is rejected. A network request will never be performed. This is useful for universal rendering when required chunks are always manually served in initial requests (embedded within the page), but not in cases where app navigation will trigger an import not initially served.

@faceyspacey
Copy link
Contributor Author

@sokra's requested change has been made

@skipjack
Copy link
Contributor

skipjack commented Aug 6, 2017

@faceyspacey was this released yet? No rush, but ping me when it is so we can get this in.

@skipjack
Copy link
Contributor

Ok it seems the corresponding PR was merged a couple weeks ago and a few releases have been done since then. Merging...

@skipjack skipjack merged commit 602d77d into webpack:master Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants