Skip to content

Commit 7ac5d1a

Browse files
committed
fix: remove resolvePackageJsonImports: false since Metro supports it from 0.82.0
1 parent c9af25b commit 7ac5d1a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/pages/esm.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ The `"esm": true` option enables ESM-compatible output by adding the `.js` exten
2020

2121
For TypeScript, it also generates 2 sets of type definitions if the [`commonjs`](build.md#commonjs) target is also enabled: one for the CommonJS build and one for the ES module build.
2222

23-
It's recommended to specify `"moduleResolution": "bundler"` and `"resolvePackageJsonImports": false` in your `tsconfig.json` file to match [Metro's behavior](https://reactnative.dev/blog/2023/06/21/package-exports-support#enabling-package-exports-beta):
23+
It's recommended to specify `"moduleResolution": "bundler"` in your `tsconfig.json` file to match Metro's behavior:
2424

2525
```json
2626
{
2727
"compilerOptions": {
28-
"moduleResolution": "bundler",
29-
"resolvePackageJsonImports": false
28+
"moduleResolution": "bundler"
3029
}
3130
}
3231
```
@@ -53,7 +52,7 @@ To make use of the output files, ensure that your `package.json` file contains t
5352
},
5453
```
5554

56-
The `main` field is for tools that don't support the `exports` field (e.g. [Metro](https://metrobundler.dev/)). The `module` field is a non-standard field that some tools use to determine the ESM entry point.
55+
The `main` field is for tools that don't support the `exports` field (e.g. [Jest](https://jestjs.io)). The `module` field is a non-standard field that some tools use to determine the ESM entry point.
5756

5857
The `exports` field is used by Node.js 12+, modern browsers and tools to determine the correct entry point. The entrypoint is specified in the `.` key and will be used when the library is imported or required directly (e.g. `import 'my-library'` or `require('my-library')`).
5958

@@ -71,6 +70,8 @@ You can also specify additional conditions for different scenarios, such as `rea
7170

7271
The `./package.json` field is used to point to the library's `package.json` file. It's necessary for tools that may need to read the `package.json` file directly (e.g. [React Native Codegen](https://reactnative.dev/docs/the-new-architecture/what-is-codegen)).
7372

73+
> Note: Metro enables support for `package.json` exports by default from version [0.82.0](https://github.com/facebook/metro/releases/tag/v0.82.0). In previous versions, experimental support can be enabled by setting the `unstable_enablePackageExports` option to `true` in the [Metro configuration](https://metrobundler.dev/docs/configuration/). If this is not enabled, Metro will use the entrypoint specified in the `main` field.
74+
7475
## Guidelines
7576

7677
There are still a few things to keep in mind if you want your library to be ESM-compatible:

packages/create-react-native-library/templates/common/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"noUnusedLocals": true,
2222
"noUnusedParameters": true,
2323
"resolveJsonModule": true,
24-
"resolvePackageJsonImports": false,
2524
"skipLibCheck": true,
2625
"strict": true,
2726
"target": "ESNext",

0 commit comments

Comments
 (0)