serializer.unstable_getAsyncDependencyPath: Allow integrators to supply custom path types to __loadBundleAsync. - #1855
Closed
robhogan wants to merge 1 commit into
Closed
serializer.unstable_getAsyncDependencyPath: Allow integrators to supply custom path types to __loadBundleAsync.#1855robhogan wants to merge 1 commit into
__loadBundleAsync.#1855robhogan wants to merge 1 commit into
Conversation
…ly custom path types to `__loadBundleAsync`. Summary: Async dependency `paths` are a property of Metro's `_$$_DEPENDENCY_MAP` passed to `__loadBundleAsync`, used to implement lazy edges - conceptually they are a pointer to the (usually remote) location of an async-loadable segment. As an implementation detail, lazy dev bundling uses strings - relative URLs - in `paths`, and these are passed to `fetch`. See the original RFC: https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md At Meta, Metro-Buck, with its custom serialiser, populates `paths` not with strings but with objects containing the data needed to construct URLs. This extends the core serialiser with a hook that may be used to provide custom `paths`, so that Metro-Buck can implement its logic on top of the OSS serialiser rather than forking it. The integrator is responsible for both sides of this serialiser <-> runtime contract: - `unstable_getAsyncDependencyPath` allows the integrator to return any JSON-serialisable value. Metro encodes these into the bundle. - `__loadBundleAsync` at runtime accepts the same type. This change is non-breaking in itself - the argument to `__loadBundleAsync` does not change unless the user supplies `unstable_getAsyncDependencyPath`. Changelog: ``` - **[Experimental]**: Add `serializer.unstable_getAsyncDependencyPath` to supply custom `paths` to framework-defined `__loadBundleAsync` ``` Reviewed By: huntie Differential Revision: D112630265
Contributor
|
@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D112630265. |
Contributor
|
This pull request has been merged in eb085e9. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Async dependency
pathsare a property of Metro's_$$_DEPENDENCY_MAPpassed to__loadBundleAsync, used to implement lazy edges - conceptually they are a pointer to the (usually remote) location of an async-loadable segment. As an implementation detail, lazy dev bundling uses strings - relative URLs - inpaths, and these are passed tofetch.See the original RFC: https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md
At Meta, Metro-Buck, with its custom serialiser, populates
pathsnot with strings but with objects containing the data needed to construct URLs.This extends the core serialiser with a hook that may be used to provide custom
paths, so that Metro-Buck can implement its logic on top of the OSS serialiser rather than forking it.The integrator is responsible for both sides of this serialiser <-> runtime contract:
unstable_getAsyncDependencyPathallows the integrator to return any JSON-serialisable value. Metro encodes these into the bundle.__loadBundleAsyncat runtime accepts the same type.This change is non-breaking in itself - the argument to
__loadBundleAsyncdoes not change unless the user suppliesunstable_getAsyncDependencyPath.Changelog:
Reviewed By: huntie
Differential Revision: D112630265