Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: callstack/react-native-builder-bob
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: create-react-native-library@0.50.2
Choose a base ref
...
head repository: callstack/react-native-builder-bob
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: create-react-native-library@0.50.3
Choose a head ref
  • 14 commits
  • 51 files changed
  • 3 contributors

Commits on May 5, 2025

  1. fix: add additional check for codegenNativeComponent

    satya164 committed May 5, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cc93396 View commit details
  2. chore: publish

     - react-native-builder-bob@0.40.10
    satya164 committed May 5, 2025
    Copy the full SHA
    d9cd3e4 View commit details

Commits on May 8, 2025

  1. docs: mention module-sync condition

    satya164 committed May 8, 2025
    Copy the full SHA
    4c062bd View commit details

Commits on May 9, 2025

  1. chore: update eslint config

    satya164 committed May 9, 2025
    Copy the full SHA
    9a8db8d View commit details

Commits on May 10, 2025

  1. chore: fix lint issues

    satya164 committed May 10, 2025
    Copy the full SHA
    07ba55f View commit details

Commits on May 11, 2025

  1. docs: document app.plugin.js in package.json exports (#834)

    As people start using package.json exports more, it might be worth
    highlighting the "usual" exports people might want to have, which
    includes expo config plugin files (app.plugin.js).
    
    Feel free to close if you see this being out of scope.
    
    Thank you :)
    
    Co-authored-by: Satyajit Sahoo <satyajit.happy@gmail.com>
    vonovak and satya164 authored May 11, 2025
    Copy the full SHA
    79f2a68 View commit details

Commits on May 13, 2025

  1. ci: fix nitro modules build and add js library build (#836)

    atlj authored May 13, 2025
    Copy the full SHA
    506c11e View commit details

Commits on May 14, 2025

  1. chore: improve eslint rules and fix issues

    satya164 committed May 14, 2025
    Copy the full SHA
    fc386e4 View commit details
  2. fix: fix nitro module versions

    satya164 committed May 14, 2025
    Copy the full SHA
    0f6f749 View commit details

Commits on May 15, 2025

  1. refactor: use react-native-monorepo-config in the example

    satya164 committed May 15, 2025
    Copy the full SHA
    ebe4512 View commit details
  2. fix: enable package exports for metro. fixes #842 (#843)

    satya164 authored May 15, 2025
    Copy the full SHA
    72d95df View commit details
  3. Copy the full SHA
    7dada27 View commit details
  4. chore: upgrade lerna-lite

    satya164 committed May 15, 2025
    Copy the full SHA
    be05fd2 View commit details
  5. chore: publish

     - docs@0.6.7
     - create-react-native-library@0.50.3
     - react-native-builder-bob@0.40.11
    satya164 committed May 15, 2025
    Copy the full SHA
    d02ae54 View commit details
Showing with 2,937 additions and 1,680 deletions.
  1. +16 −10 .github/workflows/build-templates.yml
  2. +4 −0 docs/CHANGELOG.md
  3. +1 −1 docs/package.json
  4. +19 −5 docs/pages/esm.md
  5. +19 −24 eslint.config.mjs
  6. +9 −7 package.json
  7. +8 −0 packages/create-react-native-library/CHANGELOG.md
  8. +0 −1 packages/create-react-native-library/bin/create-react-native-library
  9. +1 −1 packages/create-react-native-library/package.json
  10. +1 −1 packages/create-react-native-library/src/constants.ts
  11. +11 −3 packages/create-react-native-library/src/exampleApp/generateExampleApp.ts
  12. +2 −5 packages/create-react-native-library/src/index.ts
  13. +11 −6 packages/create-react-native-library/src/input.ts
  14. +7 −5 packages/create-react-native-library/src/template.ts
  15. +2 −2 packages/create-react-native-library/src/utils/local.ts
  16. +5 −6 packages/create-react-native-library/src/utils/prompt.ts
  17. +3 −1 packages/create-react-native-library/src/utils/resolveNpmPackageVersion.ts
  18. +2 −0 packages/create-react-native-library/src/utils/sortObjectKeys.ts
  19. +2 −2 packages/create-react-native-library/src/utils/spawn.ts
  20. +5 −5 packages/create-react-native-library/templates/common/$package.json
  21. +3 −3 packages/create-react-native-library/templates/example-common/example/metro.config.js
  22. +7 −3 packages/create-react-native-library/templates/expo-library/example/metro.config.js
  23. +10 −0 packages/react-native-builder-bob/CHANGELOG.md
  24. +3 −1 packages/react-native-builder-bob/babel-preset.js
  25. +0 −1 packages/react-native-builder-bob/bin/bob
  26. +4 −1 packages/react-native-builder-bob/metro-config.js
  27. +1 −1 packages/react-native-builder-bob/package.json
  28. +2 −0 packages/react-native-builder-bob/src/__fixtures__/project/MyNativeComponent.js
  29. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/MyNativeComponent.jsx
  30. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/MyNativeComponent.ts
  31. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/MyNativeComponent.tsx
  32. +6 −6 packages/react-native-builder-bob/src/__fixtures__/project/code/$exports-output.ts
  33. +6 −6 packages/react-native-builder-bob/src/__fixtures__/project/code/$imports-output.ts
  34. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/code/MyNativeComponent.js
  35. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/code/MyNativeComponent.jsx
  36. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/code/MyNativeComponent.ts
  37. +1 −0 packages/react-native-builder-bob/src/__fixtures__/project/code/MyNativeComponent.tsx
  38. +23 −20 packages/react-native-builder-bob/src/__tests__/init.test.ts
  39. +6 −3 packages/react-native-builder-bob/src/build.ts
  40. +1 −2 packages/react-native-builder-bob/src/index.ts
  41. +12 −5 packages/react-native-builder-bob/src/init.ts
  42. +8 −8 packages/react-native-builder-bob/src/schema.ts
  43. +2 −2 packages/react-native-builder-bob/src/targets/codegen/patches/removeCodegenAppLevelCode.ts
  44. +2 −2 packages/react-native-builder-bob/src/targets/typescript.ts
  45. +76 −73 packages/react-native-builder-bob/src/utils/compile.ts
  46. +18 −5 packages/react-native-builder-bob/src/utils/isCodegenSpec.ts
  47. +1 −1 packages/react-native-builder-bob/src/utils/prompts.ts
  48. +3 −3 packages/react-native-builder-bob/src/utils/spawn.ts
  49. +3 −2 packages/react-native-builder-bob/src/utils/workerize.ts
  50. +2 −0 tsconfig.json
  51. +2,603 −1,447 yarn.lock
26 changes: 16 additions & 10 deletions .github/workflows/build-templates.yml
Original file line number Diff line number Diff line change
@@ -22,16 +22,16 @@ on:
jobs:
build:
env:
XCODE_VERSION: 16.2
XCODE_VERSION: 16.3
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
- ubuntu-latest
- macos-15
type:
- name: turbo-module
language: kotlin-objc
@@ -40,15 +40,16 @@ jobs:
- name: nitro-module
language: kotlin-swift
include:
- os: ubuntu
type.name: library
type.language: js
- os: ubuntu-latest
type:
name: library
language: js

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}
cancel-in-progress: true

runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
@@ -130,14 +131,14 @@ jobs:
working-directory: ${{ env.work_dir }}
run: |
# Build Android for only some matrices to skip redundant builds
if [[ ${{ matrix.os }} == ubuntu ]]; then
if [[ ${{ matrix.os }} =~ ubuntu ]]; then
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == *-objc ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == *-objc ]]; then
echo "android_build=1" >> $GITHUB_ENV
fi
fi
# Build iOS for only some matrices to skip redundant builds
if [[ ${{ matrix.os }} == macos ]]; then
if [[ ${{ matrix.os }} =~ macos ]]; then
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == kotlin-* ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == kotlin-* ]]; then
echo "ios_build=1" >> $GITHUB_ENV
fi
@@ -192,6 +193,10 @@ jobs:
working-directory: ${{ env.work_dir }}
if: matrix.type.language == 'js'
run: |
# Clean up built JS files
# So we test that bundling works without any pre-built files
rm -rf lib/*
yarn example expo export --platform web
- name: Install JDK
@@ -239,8 +244,9 @@ jobs:
path: |
${{ env.work_dir }}/**/ios/Pods
${{ env.work_dir }}/**/ios/Podfile.lock
key: ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
key: ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}-${{ hashFiles(format('{0}/**/*ViewNativeComponent.ts', env.work_dir), format('{0}/**/Native*.ts', env.work_dir), format('{0}/**/*.nitro.ts', env.work_dir)) }}
restore-keys: |
${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}-
${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-
${{ runner.os }}-library-cocoapods-
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.6.7](https://github.com/callstack/react-native-builder-bob/compare/docs@0.6.6...docs@0.6.7) (2025-05-15)

**Note:** Version bump only for package docs

## [0.6.6](https://github.com/callstack/react-native-builder-bob/compare/docs@0.6.5...docs@0.6.6) (2025-05-04)

### Bug Fixes
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.6.6",
"version": "0.6.7",
"private": true,
"description": "Documentation for react-native-builder-bob",
"scripts": {
24 changes: 19 additions & 5 deletions docs/pages/esm.md
Original file line number Diff line number Diff line change
@@ -64,8 +64,22 @@ The `./package.json` field is used to point to the library's `package.json` file

Using the `exports` field has a few benefits, such as:

- It [restricts access to the library's internals](https://nodejs.org/api/packages.html#main-entry-point-export) by default. You can explicitly specify which files are accessible with [subpath exports](https://nodejs.org/api/packages.html#subpath-exports).
- It allows you to specify different entry points for different environments with [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) (e.g. `node`, `browser`, `module`, `react-native`, `production`, `development` etc.).
- It [restricts access to the library's internals](https://nodejs.org/api/packages.html#main-entry-point-export) by default. You can explicitly specify which files are accessible with [subpath exports](https://nodejs.org/api/packages.html#subpath-exports).

So make sure to explicitly specify any files that need to be readable by other tools, e.g. `./app.plugin.js` if you provide a [Expo Config plugin](https://docs.expo.dev/config-plugins/plugins-and-mods/#apppluginjs):

```diff
"exports": {
".": {
"source": "./src/index.tsx",
"types": "./lib/typescript/src/index.d.ts",
"default": "./lib/module/index.js"
},
"./package.json": "./package.json",
+ "./app.plugin.js": "./app.plugin.js"
},
```

### A note on `import.meta`

@@ -202,11 +216,11 @@ For example, here is a setup that uses ESM for Webpack, Vite, Rollup, Metro (Rea
"types": "./lib/typescript/module/src/index.d.ts",
"default": "./lib/module/index.js"
},
"node": {
"module": {
"types": "./lib/typescript/module/src/index.d.ts",
"default": "./lib/module/index.js"
},
"module": {
"module-sync": {
"types": "./lib/typescript/module/src/index.d.ts",
"default": "./lib/module/index.js"
},
@@ -223,8 +237,8 @@ For example, here is a setup that uses ESM for Webpack, Vite, Rollup, Metro (Rea
Here, we specify 4 conditions:

- `react-native`: Used when the library is imported in a React Native environment with Metro.
- `node`: Used when the library is imported in Node.js.
- `module`: Used when the library is imported in a bundler such as Webpack, Vite or Rollup.
- `module`: Used when the library is imported in some bundler ssuch as Webpack, Vite or Rollup.
- `module-sync`: Used when the library is imported on Node.js 22.10.0+ - regardless of whether it's imported with `import` or `require`.
- `default`: Fallback used when the library is imported in an environment that doesn't support the other conditions.

One thing to note is that TypeScript may need to be configured to resolve to the appropriate condition. It's pre-configured for React Native apps, but in other scenarios, it maybe necessary to specify [`customConditions`](https://www.typescriptlang.org/tsconfig/#customConditions) in the `tsconfig.json` file:
43 changes: 19 additions & 24 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
// eslint-disable-next-line import-x/extensions,import-x/no-unresolved
import { defineConfig, globalIgnores } from 'eslint/config';
import satya164 from 'eslint-config-satya164';
import vitest from '@vitest/eslint-plugin';
import { recommended, vitest, typechecked } from 'eslint-config-satya164';

export default defineConfig([
satya164,
export default defineConfig(
recommended,
vitest,
typechecked,

{
files: ['**/*.{spec,test}.{js,ts,tsx}', '**/__tests__/**/*.{js,ts,tsx}'],

plugins: {
vitest,
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},

rules: {
...vitest.configs.recommended.rules,

'vitest/consistent-test-it': ['error', { fn: 'test' }],
'vitest/expect-expect': 'error',
'vitest/no-disabled-tests': 'error',
'vitest/no-duplicate-hooks': 'error',
'vitest/no-test-prefixes': 'error',
'vitest/no-test-return-statement': 'error',
'vitest/prefer-to-be': 'error',
'vitest/prefer-todo': 'error',
'vitest/require-to-throw-message': 'error',

'jest/no-deprecated-functions': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
},
},

@@ -37,8 +31,9 @@ export default defineConfig([
'**/.vscode/',
'**/node_modules/',
'**/coverage/',
'**/out/',
'**/lib/',
'**/templates/',
'**/__fixtures__/',
]),
]);
])
);
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -16,24 +16,26 @@
"typecheck": "tsc --noEmit",
"watch": "concurrently 'yarn typecheck --watch' 'lerna run --parallel prepare -- --watch'",
"test": "yarn workspace react-native-builder-bob test",
"docs": "yarn workspace docs"
"docs": "yarn workspace docs",
"release": "lerna publish"
},
"devDependencies": {
"@commitlint/config-conventional": "^17.0.2",
"@eslint/compat": "^1.2.7",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"@evilmartians/lefthook": "^1.5.0",
"@lerna-lite/cli": "^1.13.0",
"@lerna-lite/run": "^1.13.0",
"@lerna-lite/cli": "^4.1.2",
"@lerna-lite/publish": "^4.1.2",
"@lerna-lite/run": "^4.1.2",
"@vitest/eslint-plugin": "^1.1.39",
"commitlint": "^17.0.2",
"concurrently": "^7.2.2",
"eslint": "^9.23.0",
"eslint-config-satya164": "^4.0.1",
"eslint": "^9.26.0",
"eslint-config-satya164": "^5.1.1",
"globals": "^16.0.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"prettier": "^3.5.3",
"typescript": "^5.8.3"
},
"commitlint": {
"extends": [
8 changes: 8 additions & 0 deletions packages/create-react-native-library/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.50.3](https://github.com/callstack/react-native-builder-bob/compare/create-react-native-library@0.50.2...create-react-native-library@0.50.3) (2025-05-15)

### Bug Fixes

- add --only-version to release-it to skip unnecessary prompts ([7dada27](https://github.com/callstack/react-native-builder-bob/commit/7dada27143c09c8c703e9b5f7bb8e877a7e6f25b)) - by @
- enable package exports for metro. fixes [#842](https://github.com/callstack/react-native-builder-bob/issues/842) ([#843](https://github.com/callstack/react-native-builder-bob/issues/843)) ([72d95df](https://github.com/callstack/react-native-builder-bob/commit/72d95df655e6dbc7e982ee3790263236f13b2f71)) - by @satya164
- fix nitro module versions ([0f6f749](https://github.com/callstack/react-native-builder-bob/commit/0f6f74989a7fef685abcea5741404dc3d1dce64b)) - by @satya164

## [0.50.2](https://github.com/callstack/react-native-builder-bob/compare/create-react-native-library@0.50.1...create-react-native-library@0.50.2) (2025-05-04)

### Bug Fixes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node

// eslint-disable-next-line import/no-commonjs
require('../lib/index');
2 changes: 1 addition & 1 deletion packages/create-react-native-library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-react-native-library",
"version": "0.50.2",
"version": "0.50.3",
"description": "CLI to scaffold React Native libraries",
"keywords": [
"react-native",
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 FALLBACK_NITRO_MODULES_VERSION = '0.25.2';
export const SUPPORTED_REACT_NATIVE_VERSION = '0.79.2';
Original file line number Diff line number Diff line change
@@ -117,6 +117,9 @@ export default async function generateExampleApp({
'blank',
];
break;
case 'none': {
// Do nothing
}
}

await spawn('npx', args, {
@@ -189,19 +192,23 @@ export default async function generateExampleApp({

const PACKAGES_TO_ADD_DEV = {
'react-native-builder-bob': `^${config.versions.bob}`,
'react-native-monorepo-config': `^0.1.9`,
};

if (config.project.moduleConfig === 'nitro-modules') {
const packagesToAddNitro = {
'react-native-nitro-modules': `^${config.versions.nitroModules}`,
'react-native-nitro-modules': `^${config.versions.nitro || 'latest'}`,
};

Object.assign(dependencies, packagesToAddNitro);
}

Object.assign(devDependencies, PACKAGES_TO_ADD_DEV);

if (config.example === 'expo') {
const sdkVersion = dependencies.expo.split('.')[0].replace(/[^\d]/, '');
const sdkVersion: string = dependencies.expo
.split('.')[0]
.replace(/[^\d]/, '');

let bundledNativeModules: Record<string, string>;

@@ -213,11 +220,12 @@ export default async function generateExampleApp({
(res) => {
let data = '';

res.on('data', (chunk) => (data += chunk));
res.on('data', (chunk: string) => (data += chunk));
res.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (e) {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject(e);
}
});
7 changes: 2 additions & 5 deletions packages/create-react-native-library/src/index.ts
Original file line number Diff line number Diff line change
@@ -38,8 +38,7 @@ type Args = Partial<Answers> & {
[key: string]: unknown;
};

// eslint-disable-next-line @typescript-eslint/no-unused-expressions
yargs
void yargs
.command('$0 [name]', 'create a react native library', acceptedArgs, create)
.demandCommand()
.recommendCommands()
@@ -82,9 +81,7 @@ async function create(_argv: Args) {
const config = generateTemplateConfiguration({
versions: {
bob: bobVersion,
nitroModules: nitroModulesVersion,
// Nitro codegen's version is always the same as nitro modules version.
nitroCodegen: nitroModulesVersion,
nitro: nitroModulesVersion,
},
basename: path.basename(answers.name ?? answers.directory),
answers,
Loading