Skip to content

Commit

Permalink
Deprecate asyncRequireModulePath
Browse files Browse the repository at this point in the history
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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Apr 24, 2023
1 parent 4ef14f9 commit c7b684f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ In a future release of Metro, this option will become `true` by default.
### Transformer Options
#### `asyncRequireModulePath`
<!-- Keep old links to `asyncRequireModulePath` working -->
<a name="asyncrequiremodulepath"></a>
#### `asyncRequireModulePath` <div class="label deprecated">Deprecated</div>
Type: `string`
Expand All @@ -398,19 +401,7 @@ The module named by `asyncRequireModulePath` is [resolved](./Resolution.md) rela
:::
:::info
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:
```flow
// Get a reference to the dynamic `require` function provided by Metro.
const dynamicRequire = (require: {importAll: mixed => mixed});
module.exports = async function asyncRequire(moduleID: mixed): Promise<mixed> {
// 1. Do any work necessary (not detailed here) to fetch and evaluate the
// module's code, as transformed by Metro.
// 2. Require the module from Metro's module registry using `dynamicRequire`.
return dynamicRequire.importAll(moduleID);
};
```
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.
:::
#### `dynamicDepsInPackages`
Expand Down

0 comments on commit c7b684f

Please sign in to comment.