Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/build-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
jobs:
build:
env:
XCODE_VERSION: 16.2
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

Expand Down Expand Up @@ -224,6 +225,12 @@ jobs:
run: |
yarn turbo run build:android --cache-dir=".turbo"
- name: Use appropriate Xcode version
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}

- name: Restore cocoapods
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
id: library-cocoapods-cache
Expand All @@ -238,13 +245,12 @@ jobs:
${{ runner.os }}-library-cocoapods-
- name: Install cocoapods
env:
NO_FLIPPER: 1
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
working-directory: ${{ env.work_dir }}
run: |
cd example/ios
pod install
cd example
bundle install
bundle exec pod install --project-directory=ios
- name: Cache cocoapods
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
Expand All @@ -255,12 +261,6 @@ jobs:
${{ env.work_dir }}/**/ios/Podfile.lock
key: ${{ steps.library-cocoapods-cache.outputs.cache-primary-key }}

- name: Use appropriate Xcode version
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'

- name: Build example (iOS)
if: env.ios_build == 1
working-directory: ${{ env.work_dir }}
Expand Down
3 changes: 1 addition & 2 deletions docs/pages/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ To configure your project manually, follow these steps:
4. Configure the appropriate entry points:

```json
"source": "./src/index.tsx",
"main": "./lib/module/index.js",
"types": "./lib/typescript/src/index.d.ts",
"exports": {
".": {
"source": "./src/index.tsx",
"types": "./lib/typescript/src/index.d.ts",
"default": "./lib/module/index.js"
},
Expand All @@ -91,7 +91,6 @@ To configure your project manually, follow these steps:

Here is what each of these fields mean:

- `source`: The path to the source code. It is used by `react-native-builder-bob` to detect the correct output files and provide better error messages.
- `main`: The entry point for legacy setups that don't support the `exports` field. See [Compatibility](./esm.md#compatibility) for more details.
- `types`: The entry point for the TypeScript definitions for legacy setups with `moduleResolution: node10` or `moduleResolution: node`.
- `exports`: The entry points for tools that support the `exports` field in `package.json` - such as Node.js 12+, modern browsers and tools. See [the ESM support guide](./esm.md) for more details.
Expand Down
4 changes: 3 additions & 1 deletion docs/pages/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ To make use of the output files, ensure that your `package.json` file contains t
"types": "./lib/typescript/src/index.d.ts",
"exports": {
".": {
"source": "./src/index.tsx",
"types": "./lib/typescript/src/index.d.ts",
"default": "./lib/module/index.js"
},
Expand All @@ -51,8 +52,9 @@ The `main` field is for tools that don't support the `exports` field (e.g. [Metr

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')`).

Here, we specify 2 conditions:
Here, we specify 3 conditions:

- `source`: A custom condition used by `react-native-builder-bob` to determine the source file for the library.
- `types`: Used for the TypeScript definitions.
- `default`: Used for the actual JS code when the library is imported or required.

Expand Down
2 changes: 1 addition & 1 deletion packages/create-react-native-library/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const FALLBACK_BOB_VERSION = '0.40.8';
export const FALLBACK_NITRO_MODULES_VERSION = '0.22.1';
export const SUPPORTED_REACT_NATIVE_VERSION = '0.78.2';
export const SUPPORTED_REACT_NATIVE_VERSION = '0.79.2';
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const FILES_TO_DELETE = [
'tsconfig.json',
];

const FILES_TO_MOVE = ['.bundle', 'Gemfile'];

const PACKAGES_TO_REMOVE = [
'@react-native/eslint-config',
'@tsconfig/react-native',
Expand Down Expand Up @@ -119,13 +117,6 @@ export default async function generateExampleApp({
await fs.remove(path.join(directory, file));
}

// Move files to the root
for (const file of FILES_TO_MOVE) {
if (await fs.pathExists(path.join(directory, file))) {
await fs.move(path.join(directory, file), path.join(root, file));
}
}

// Patch the example app's package.json
const pkg = await fs.readJSON(path.join(directory, 'package.json'));

Expand All @@ -142,7 +133,7 @@ export default async function generateExampleApp({
const SCRIPTS_TO_ADD = {
'build:android':
'react-native build-android --extra-params "--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a"',
'build:ios': `react-native build-ios --scheme ${config.project.name}Example --mode Debug --extra-params "-sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO"`,
'build:ios': `react-native build-ios --mode Debug`,
};

if (config.example === 'vanilla') {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-react-native-library/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const EXAMPLE_CHOICES = (
disabled: false,
},
{
title: 'React Native Test App by Microsoft',
title: 'Test App by Microsoft',
value: 'test-app',
description: "app's native code is abstracted away",
// The test app is disabled for now until proper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
build-ios:
runs-on: macos-latest
env:
XCODE_VERSION: 16.2
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
Expand Down Expand Up @@ -144,6 +145,12 @@ jobs:
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi
- name: Use appropriate Xcode version
if: env.turbo_cache_hit != 1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}

- name: Restore cocoapods
if: env.turbo_cache_hit != 1
id: cocoapods-cache
Expand All @@ -158,10 +165,9 @@ jobs:
- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd example/ios
pod install
env:
NO_FLIPPER: 1
cd example
bundle install
bundle exec pod install --project-directory=ios
- name: Cache cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
Expand All @@ -171,12 +177,6 @@ jobs:
**/ios/Pods
key: ${{ steps.cocoapods-cache.outputs.cache-key }}

- name: Use appropriate Xcode version
if: env.turbo_cache_hit != 1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'

- name: Build example for iOS
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android.iml
example/ios/Pods

# Ruby
/vendor/
example/vendor/

# node.js
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "<%- project.slug -%>",
"version": "0.1.0",
"description": "<%- project.description %>",
"source": "./src/index.tsx",
"main": "./lib/module/index.js",
"types": "./lib/typescript/src/index.d.ts",
"exports": {
".": {
"source": "./src/index.tsx",
"types": "./lib/typescript/src/index.d.ts",
"default": "./lib/module/index.js"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ To invoke **Nitrogen**, use the following command:
yarn nitrogen
```

<% } -%>
<% if (project.native) { -%>
You also need to install the required ruby gems for the iOS project with [bundler](https://bundler.io/). To install the gems, run the following command in the root directory:

```sh
bundle install
```

Now, you can install [CocoaPods](https://cocoapods.org/) for the iOS project. To do this, run the following command in the `example/ios` directory:

```sh
bundle exec pod install
```

<% } -%>
The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-builder-bob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"kleur": "^4.1.4",
"metro-config": "^0.80.9",
"prompts": "^2.4.2",
"react-native-monorepo-config": "^0.1.7",
"react-native-monorepo-config": "^0.1.8",
"which": "^2.0.2",
"yargs": "^17.5.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ exports[`initializes the configuration 1`] = `
},
"exports": {
".": {
"source": "./src/index.ts",
"types": "./lib/typescript/src/index.d.ts",
"default": "./lib/module/index.js"
},
"./package.json": "./package.json"
},
"source": "./src/index.ts",
"main": "./lib/module/index.js",
"types": "./lib/typescript/src/index.d.ts",
"scripts": {
Expand Down
17 changes: 11 additions & 6 deletions packages/react-native-builder-bob/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,20 @@ export async function init() {

if (targets.includes('commonjs') && targets.includes('module')) {
exportsField['.'] = {
source: entries.source,
import: importField,
require: requireField,
};
} else if (targets.includes('commonjs')) {
exportsField['.'] = requireField;
exportsField['.'] = {
source: entries.source,
...requireField,
};
} else if (targets.includes('module')) {
exportsField['.'] = importField;
exportsField['.'] = {
source: entries.source,
...importField,
};
}

if (
Expand All @@ -288,10 +295,8 @@ export async function init() {
}

const entryFields: {
[key in 'source' | 'main' | 'module' | 'types']?: string;
} = {
source: entries.source,
};
[key in 'main' | 'module' | 'types']?: string;
} = {};

if (targets.includes('commonjs') && targets.includes('module')) {
entryFields.main = entries.commonjs;
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12353,7 +12353,7 @@ __metadata:
mock-fs: ^5.2.0
mock-stdin: ^1.0.0
prompts: ^2.4.2
react-native-monorepo-config: ^0.1.7
react-native-monorepo-config: ^0.1.8
vitest: ^3.1.1
which: ^2.0.2
yargs: ^17.5.1
Expand All @@ -12362,13 +12362,13 @@ __metadata:
languageName: unknown
linkType: soft

"react-native-monorepo-config@npm:^0.1.7":
version: 0.1.7
resolution: "react-native-monorepo-config@npm:0.1.7"
"react-native-monorepo-config@npm:^0.1.8":
version: 0.1.8
resolution: "react-native-monorepo-config@npm:0.1.8"
dependencies:
escape-string-regexp: ^5.0.0
fast-glob: ^3.3.3
checksum: 828b8132c0121f23993b34a4a979971b80061ff8810ff1275fc26e76a264d44bad14d219990013a0f4b705ac8e64a270549fbd906bfd4217d468f6aa08ec7712
checksum: 3c9abfd2dcd7d4da0d5d8d59f1e997f68283a6dc04935c310fece2a6ab62045e2b19f976d27894243f1cba6d9b9f1c3771e9f1428cd7cb0f7e00ed9c1e7251a5
languageName: node
linkType: hard

Expand Down
Loading