diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml index 044a62263..10f6ce3de 100644 --- a/.github/workflows/build-templates.yml +++ b/.github/workflows/build-templates.yml @@ -22,6 +22,7 @@ on: jobs: build: env: + XCODE_VERSION: 16.2 TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} @@ -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 @@ -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' @@ -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 }} diff --git a/docs/pages/build.md b/docs/pages/build.md index 322d6bbd8..eadb3b5d8 100644 --- a/docs/pages/build.md +++ b/docs/pages/build.md @@ -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" }, @@ -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. diff --git a/docs/pages/esm.md b/docs/pages/esm.md index 56f0cf878..83ee86d37 100644 --- a/docs/pages/esm.md +++ b/docs/pages/esm.md @@ -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" }, @@ -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. diff --git a/packages/create-react-native-library/src/constants.ts b/packages/create-react-native-library/src/constants.ts index 7f91d35f1..479bcda19 100644 --- a/packages/create-react-native-library/src/constants.ts +++ b/packages/create-react-native-library/src/constants.ts @@ -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'; diff --git a/packages/create-react-native-library/src/exampleApp/generateExampleApp.ts b/packages/create-react-native-library/src/exampleApp/generateExampleApp.ts index 6cedd73d4..f9c820f33 100644 --- a/packages/create-react-native-library/src/exampleApp/generateExampleApp.ts +++ b/packages/create-react-native-library/src/exampleApp/generateExampleApp.ts @@ -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', @@ -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')); @@ -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') { diff --git a/packages/create-react-native-library/src/input.ts b/packages/create-react-native-library/src/input.ts index d5f379107..b50377079 100644 --- a/packages/create-react-native-library/src/input.ts +++ b/packages/create-react-native-library/src/input.ts @@ -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 diff --git a/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml b/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml index 9683e30aa..50952350d 100644 --- a/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml +++ b/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml @@ -115,6 +115,7 @@ jobs: build-ios: runs-on: macos-latest env: + XCODE_VERSION: 16.2 TURBO_CACHE_DIR: .turbo/ios steps: - name: Checkout @@ -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 @@ -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' @@ -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 }}" diff --git a/packages/create-react-native-library/templates/common/$.gitignore b/packages/create-react-native-library/templates/common/$.gitignore index 4b1fbd43f..67f32126d 100644 --- a/packages/create-react-native-library/templates/common/$.gitignore +++ b/packages/create-react-native-library/templates/common/$.gitignore @@ -46,7 +46,7 @@ android.iml example/ios/Pods # Ruby -/vendor/ +example/vendor/ # node.js # diff --git a/packages/create-react-native-library/templates/common/$package.json b/packages/create-react-native-library/templates/common/$package.json index 260f7d851..f0ea9781a 100644 --- a/packages/create-react-native-library/templates/common/$package.json +++ b/packages/create-react-native-library/templates/common/$package.json @@ -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" }, diff --git a/packages/create-react-native-library/templates/common/CONTRIBUTING.md b/packages/create-react-native-library/templates/common/CONTRIBUTING.md index cc21198b0..ab5549219 100644 --- a/packages/create-react-native-library/templates/common/CONTRIBUTING.md +++ b/packages/create-react-native-library/templates/common/CONTRIBUTING.md @@ -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. diff --git a/packages/react-native-builder-bob/package.json b/packages/react-native-builder-bob/package.json index 4666e0c1e..6a5f1dbc6 100644 --- a/packages/react-native-builder-bob/package.json +++ b/packages/react-native-builder-bob/package.json @@ -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" }, diff --git a/packages/react-native-builder-bob/src/__tests__/__snapshots__/init.test.ts.snap b/packages/react-native-builder-bob/src/__tests__/__snapshots__/init.test.ts.snap index ddb9b8e93..62bb8221f 100644 --- a/packages/react-native-builder-bob/src/__tests__/__snapshots__/init.test.ts.snap +++ b/packages/react-native-builder-bob/src/__tests__/__snapshots__/init.test.ts.snap @@ -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": { diff --git a/packages/react-native-builder-bob/src/init.ts b/packages/react-native-builder-bob/src/init.ts index 5d6c9c59b..ab424cb2a 100644 --- a/packages/react-native-builder-bob/src/init.ts +++ b/packages/react-native-builder-bob/src/init.ts @@ -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 ( @@ -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; diff --git a/yarn.lock b/yarn.lock index 7abae8602..f4ed985c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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