Skip to content

Commit

Permalink
docs: mention tsconfig and eslint related changes for esm
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 5, 2024
1 parent e8a449b commit f272770
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions docs/pages/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,29 @@ By default, the code is compiled to support the last 2 versions of modern browse

In addition, the following options are supported:

- `esm` (`boolean`): Enabling this option will output ES modules compatible code for Node.js 12+, modern browsers and other tools that support `package.json`'s `exports` field. This mainly adds file extensions to the imports and exports. Note that file extensions are not added when importing a file that may have platform-specific extensions (e.g. `.android.ts`). In addition, the generated files will have `.cjs` (commonjs) and `.mjs` (modules) extensions instead of `.js` - this is necessary to disambiguate between the two formats.
##### `esm`

- `configFile` (`boolean` | `string`): To customize the babel config used, you can pass the [`configFile`](https://babeljs.io/docs/en/options#configfile) option as `true` if you have a `babel.config.js` or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the [`react-native-builder-bob/babel-preset`](https://github.com/callstack/react-native-builder-bob/blob/main/packages/react-native-builder-bob/babel-preset.js) preset.
Setting this option to `true` will output ES modules compatible code for Node.js 12+, modern browsers and other tools that support `package.json`'s `exports` field.

- `babelrc` (`boolean`): You can set the [`babelrc`](https://babeljs.io/docs/en/options#babelrc) option to `true` to enable using `.babelrc` files.
This mainly adds file extensions to the imports and exports. Note that file extensions are not added when importing a file that may have platform-specific extensions (e.g. `.android.ts`). In addition, the generated files will have `.cjs` (commonjs) and `.mjs` (modules) extensions instead of `.js` - this is necessary to disambiguate between the two formats.

- `copyFlow` (`boolean`): If your source code is written in [Flow](http://www.typescriptlang.org/), You can specify the `copyFlow` option to copy the source files as `.js.flow` to the output folder. If the `main` entry in `package.json` points to the `index` file in the output folder, the flow type checker will pick these files up to use for type definitions.
If you use TypeScript, also make sure to set `"moduleResolution": "Bundler"` in your `tsconfig.json` file. You may also need to set `"react/react-in-jsx-scope": "off"` if you're using ESLint with the React plugin.

- `sourceMaps` (`boolean`): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the `sourceMaps` option to `false`.
##### `configFile`

To customize the babel config used, you can pass the [`configFile`](https://babeljs.io/docs/en/options#configfile) option as `true` if you have a `babel.config.js` or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the [`react-native-builder-bob/babel-preset`](https://github.com/callstack/react-native-builder-bob/blob/main/packages/react-native-builder-bob/babel-preset.js) preset.

##### `babelrc`

You can set the [`babelrc`](https://babeljs.io/docs/en/options#babelrc) option to `true` to enable using `.babelrc` files.

##### `copyFlow`

If your source code is written in [Flow](http://www.typescriptlang.org/), You can specify the `copyFlow` option to `true` to copy the source files as `.js.flow` to the output folder. If the `main` entry in `package.json` points to the `index` file in the output folder, the flow type checker will pick these files up to use for type definitions.

##### `sourceMaps`

Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the `sourceMaps` option to `false`.

Example:

Expand All @@ -198,9 +212,13 @@ Enable generating type definitions with `tsc` if your source code is written in

The following options are supported:

- `project` (`string`): By default, the `tsconfig.json` file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the `project` option. This can be useful if you need to use different configs for development and production.
##### `project`

By default, the `tsconfig.json` file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the `project` option. This can be useful if you need to use different configs for development and production.

##### `tsc`

- `tsc` (`string`): The path to the `tsc` binary is automatically detected and defaults to the one installed in your project. You can use the `tsc` option to specify a different path.
The path to the `tsc` binary is automatically detected and defaults to the one installed in your project. You can use the `tsc` option to specify a different path.

Example:

Expand Down

0 comments on commit f272770

Please sign in to comment.