-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into @atlj/ship-codegen-specs
- Loading branch information
Showing
51 changed files
with
2,227 additions
and
2,094 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Pull request title | ||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
- reopened | ||
|
||
permissions: | ||
pull-requests: read | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/action-semantic-pull-request@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,24 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [0.2.0](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.2.0) (2024-08-01) | ||
|
||
### Features | ||
|
||
- add esm build option for typescript ([#603](https://github.com/callstack/react-native-builder-bob/issues/603)) ([fd43167](https://github.com/callstack/react-native-builder-bob/commit/fd4316745303fd41036e392b9fa4747f1679bacf)) - by @satya164 | ||
|
||
## [0.1.2](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.1.2) (2024-07-26) | ||
|
||
### Bug Fixes | ||
|
||
- always create package.json with type regardless of esm option ([#598](https://github.com/callstack/react-native-builder-bob/issues/598)) ([5b45554](https://github.com/callstack/react-native-builder-bob/commit/5b455542fec82fa9edfb41c0da0ddceb4e72c485)) - by @satya164 | ||
|
||
## [0.1.1](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.1.1) (2024-07-11) | ||
|
||
### Bug Fixes | ||
|
||
- use an alternative approach to support ESM ([0c5582b](https://github.com/callstack/react-native-builder-bob/commit/0c5582bb66f5581693e8e9913f80d2fd40d4d7c5)) - by @ | ||
|
||
# [0.1.0](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.1.0) (2024-07-05) | ||
|
||
### Bug Fixes | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# ESM support | ||
|
||
Libraries created with [`create-react-native-library`](./create.md) are pre-configured to work with ESM (ECMAScript Modules) out of the box. | ||
|
||
You can verify whether ESM support is enabled by checking the configuration for [`react-native-builder-bob`](./build.md) in the `package.json` file of the library: | ||
|
||
```json | ||
"react-native-builder-bob": { | ||
"source": "src", | ||
"output": "lib", | ||
"targets": [ | ||
["commonjs", { "esm": true }], | ||
["module", { "esm": true }], | ||
["typescript", { "esm": true }] | ||
] | ||
} | ||
``` | ||
|
||
The `"esm": true` option enables ESM-compatible output by adding the `.js` extension to the import statements in the generated files. For TypeScript, it also generates 2 sets of type definitions: one for the CommonJS build and one for the ES module build. | ||
|
||
It's recommended to specify `"moduleResolution": "Bundler"` in your `tsconfig.json` file as well: | ||
|
||
```json | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "Bundler" | ||
} | ||
} | ||
``` | ||
|
||
This means that you don't need to specify the file extension in the import statements. They'll be automatically added when possible during the build process. | ||
|
||
To make use of the output files, ensure that your `package.json` file contains the following fields: | ||
|
||
```json | ||
"main": "./lib/commonjs/index.js", | ||
"module": "./lib/module/index.js", | ||
"types": "./lib/typescript/commonjs/src/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./lib/typescript/module/src/index.d.ts", | ||
"default": "./lib/module/index.js" | ||
}, | ||
"require": { | ||
"types": "./lib/typescript/commonjs/src/index.d.ts", | ||
"default": "./lib/commonjs/index.js" | ||
} | ||
} | ||
}, | ||
``` | ||
|
||
The `main`, `module` and `types` fields are for legacy setups that don't support the `exports` field. See the [Manual configuration](build.md#manual-configuration) guide for more information about those fields. | ||
|
||
The `exports` field is used by modern tools and bundlers to determine the correct entry point. Here, we specify 2 conditions: | ||
|
||
- `import`: Used when the library is imported with an `import` statement or a dynamic `import()`. It should point to the ESM build. | ||
- `require`: Used when the library is required with a `require` call. It should point to the CommonJS build. | ||
|
||
Each condition has a `types` field - necessary for TypeScript to provide the appropriate definitions for the module system. The type definitions have slightly different semantics for CommonJS and ESM, so it's important to specify them separately. | ||
|
||
The `default` field is the fallback entry point for both conditions. It's used for the actual JS code when the library is imported or required. | ||
|
||
You can also specify additional conditions for different scenarios, such as `react-native`, `browser`, `production`, `development` etc. Note that support for these conditions depends on the tooling you're using. | ||
|
||
## Guidelines | ||
|
||
There are still a few things to keep in mind if you want your library to be ESM-compatible: | ||
|
||
- Avoid using default exports in your library. Named exports are recommended. Default exports produce a CommonJS module with a `default` property, which will work differently than the ESM build and can cause issues. | ||
- If the library uses platform-specific extensions (e.g., `.ios.js` or `.android.js`), the ESM output will not be compatible with Node.js. It's necessary to omit file extensions from the imports to make platform-specific extensions work, however, Node.js requires file extensions to be present. Bundlers such as Webpack (with [`resolve.fullySpecified: false`](https://webpack.js.org/configuration/module/#resolvefullyspecified)) or Metro can handle this. It's still possible to `require` the CommonJS build directly in Node.js. | ||
- Avoid using `.cjs`, `.mjs`, `.cts` or `.mts` extensions. Metro always requires file extensions in import statements when using `.cjs` or `.mjs` which breaks platform-specific extension resolution. | ||
- Avoid using `"moduleResolution": "Node16"` or `"moduleResolution": "NodeNext"` in your `tsconfig.json` file. They require file extensions in import statements which breaks platform-specific extension resolution. | ||
- If you specify a `react-native` condition in `exports`, make sure that it comes before `import` or `require`. The conditions should be ordered from the most specific to the least specific: | ||
|
||
```json | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./lib/typescript/module/src/index.d.ts", | ||
"react-native": "./lib/modules/index.native.js", | ||
"default": "./lib/module/index.js" | ||
}, | ||
"require": { | ||
"types": "./lib/typescript/commonjs/src/index.d.ts", | ||
"react-native": "./lib/commonjs/index.native.js", | ||
"default": "./lib/commonjs/index.js" | ||
} | ||
} | ||
} | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,48 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [0.40.0](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.40.0) (2024-08-01) | ||
|
||
### Bug Fixes | ||
|
||
- update babel preset to include class transforms for hermes ([#606](https://github.com/callstack/react-native-builder-bob/issues/606)) ([f0a7a2f](https://github.com/callstack/react-native-builder-bob/commit/f0a7a2f998f7d803e1faf3bc162206f3ed16e9a8)), closes [#605](https://github.com/callstack/react-native-builder-bob/issues/605) - by @satya164 | ||
|
||
### Features | ||
|
||
- add esm build option for typescript ([#603](https://github.com/callstack/react-native-builder-bob/issues/603)) ([fd43167](https://github.com/callstack/react-native-builder-bob/commit/fd4316745303fd41036e392b9fa4747f1679bacf)) - by @satya164 | ||
|
||
# [0.39.0](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.39.0) (2024-07-26) | ||
|
||
### Bug Fixes | ||
|
||
- prefetch bob version in advance to reduce timeouts ([3a67f50](https://github.com/callstack/react-native-builder-bob/commit/3a67f50e29fee3352a7f83943e1384a37e5b9122)) - by @satya164 | ||
- sort dependencies in example package.json ([6bcb6c8](https://github.com/callstack/react-native-builder-bob/commit/6bcb6c86ce3fe77cda644aeb9de99023473caeef)) - by @satya164 | ||
|
||
### Features | ||
|
||
- export babel and metro configs to reduce boilerplate ([#600](https://github.com/callstack/react-native-builder-bob/issues/600)) ([d6cb1ce](https://github.com/callstack/react-native-builder-bob/commit/d6cb1ce6c9ea15fe0c1e5623c84370bffb25878f)) - by @satya164 | ||
- use the bob preset for the library during dev ([#599](https://github.com/callstack/react-native-builder-bob/issues/599)) ([3a4e724](https://github.com/callstack/react-native-builder-bob/commit/3a4e7240e9cabcdf76f45724485dbffa79daa011)) - by @satya164 | ||
|
||
## [0.38.4](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.38.4) (2024-07-23) | ||
|
||
### Bug Fixes | ||
|
||
- add correct script on Android ([#596](https://github.com/callstack/react-native-builder-bob/issues/596)) ([bf38b29](https://github.com/callstack/react-native-builder-bob/commit/bf38b29fba5a40130615a3cbc82a40155b0ef251)) - by @szymonrybczak | ||
- exclude output folder from typescript ([7e00f2b](https://github.com/callstack/react-native-builder-bob/commit/7e00f2bb5d0f59a02b65cb53a700ed19f0de5393)) - by @satya164 | ||
|
||
## [0.38.3](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.38.3) (2024-07-22) | ||
|
||
### Bug Fixes | ||
|
||
- hide select example question when creating local library ([#594](https://github.com/callstack/react-native-builder-bob/issues/594)) ([ac95039](https://github.com/callstack/react-native-builder-bob/commit/ac9503965015ea5c65d9b7c95e7345fd4ef586ac)) - by @szymonrybczak | ||
|
||
## [0.38.2](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.38.2) (2024-07-11) | ||
|
||
### Bug Fixes | ||
|
||
- bump fallback bob version ([42efae5](https://github.com/callstack/react-native-builder-bob/commit/42efae5f63af05c6564021bbc907ce6d5a7dcc05)) - by @ | ||
- use an alternative approach to support ESM ([0c5582b](https://github.com/callstack/react-native-builder-bob/commit/0c5582bb66f5581693e8e9913f80d2fd40d4d7c5)) - by @ | ||
|
||
## [0.38.1](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.38.1) (2024-07-05) | ||
|
||
### Bug Fixes | ||
|
This file contains 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
Oops, something went wrong.