Skip to content

Commit c7b684f

Browse files
motiz88facebook-github-bot
authored andcommitted
Deprecate asyncRequireModulePath
Summary: Changelog: * **[Deprecated]**: The `transformer.asyncRequireModulePath` config option is deprecated. Use [`__loadBundleAsync`](https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md#__loadbundleasync-in-metro) instead. Deprecates `asyncRequireModulePath` - a docs-only change for now. At the moment, there is one valid use case for setting this option, namely pointing to the correct version of `metro-runtime` when `node_modules` resolution might not be reliable. The default RN Metro config does this. This use case is now considered "internal" and not publicly supported - when we fully remove the option we will also solve for reliable resolution. Reviewed By: huntie Differential Revision: D45001323 fbshipit-source-id: 17bf5997fb62853b3a87eaf0f4996dd9cb739df4
1 parent 4ef14f9 commit c7b684f

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

docs/Configuration.md

+5-14
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ In a future release of Metro, this option will become `true` by default.
387387
388388
### Transformer Options
389389
390-
#### `asyncRequireModulePath`
390+
<!-- Keep old links to `asyncRequireModulePath` working -->
391+
<a name="asyncrequiremodulepath"></a>
392+
393+
#### `asyncRequireModulePath` <div class="label deprecated">Deprecated</div>
391394
392395
Type: `string`
393396
@@ -398,19 +401,7 @@ The module named by `asyncRequireModulePath` is [resolved](./Resolution.md) rela
398401
:::
399402
400403
:::info
401-
Although Metro doesn't perform bundle splitting out of the box, a custom `asyncRequire` implementation can be used as part of a bundle splitting solution:
402-
403-
```flow
404-
// Get a reference to the dynamic `require` function provided by Metro.
405-
const dynamicRequire = (require: {importAll: mixed => mixed});
406-
407-
module.exports = async function asyncRequire(moduleID: mixed): Promise<mixed> {
408-
// 1. Do any work necessary (not detailed here) to fetch and evaluate the
409-
// module's code, as transformed by Metro.
410-
// 2. Require the module from Metro's module registry using `dynamicRequire`.
411-
return dynamicRequire.importAll(moduleID);
412-
};
413-
```
404+
In older versions of Metro, a custom `asyncRequireModulePath` could be used as part of a bundle splitting solution. This usage is now deprecated in favor of the [`__loadBundleAsync`](https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md#__loadbundleasync-in-metro) API.
414405
:::
415406
416407
#### `dynamicDepsInPackages`

0 commit comments

Comments
 (0)