Skip to content

Commit 212de62

Browse files
authored
fix: fix configuration for fabric view templates (#801)
fixes #788 **fabric view** ![CleanShot 2025-03-27 at 15 35 13@2x](https://github.com/user-attachments/assets/e0da07f7-4857-4836-8c4d-345635c142b5) ![CleanShot 2025-03-27 at 15 35 52@2x](https://github.com/user-attachments/assets/738e8c1c-12e5-4e8e-a528-e1618fa9bea9) **turbo module** ![CleanShot 2025-03-27 at 15 37 29@2x](https://github.com/user-attachments/assets/db7ab41f-3504-4f73-943b-2a72f8c8fcb3) ![CleanShot 2025-03-27 at 15 39 23@2x](https://github.com/user-attachments/assets/73d2d7c0-358f-4642-bf38-5b34850cb630)
1 parent e5c386c commit 212de62

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

docs/pages/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ If you have a reason to not ship Codegen generated scaffold code with your libra
150150
]
151151
```
152152

153-
3. Add `package.json` to the `exports` field in your `package.json`:
153+
3. If you have an `exports` field in your `package.json`, ensure that it contains `./package.json`:
154154

155155
```diff
156156
"exports": {

packages/create-react-native-library/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import { getDependencyVersionsFromExampleApp } from './exampleApp/dependencies';
2121
import { printErrorHelp, printNextSteps, printUsedRNVersion } from './inform';
2222

23-
const FALLBACK_BOB_VERSION = '0.36.0';
23+
const FALLBACK_BOB_VERSION = '0.38.3';
2424
const FALLBACK_NITRO_MODULES_VERSION = '0.22.1';
2525

2626
yargs

packages/create-react-native-library/src/input.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ const TYPE_CHOICES: {
9090
value: 'turbo-module',
9191
description: 'integration for native APIs to JS',
9292
},
93+
{
94+
title: 'Fabric view',
95+
value: 'fabric-view',
96+
description: 'integration for native views to JS',
97+
},
9398
{
9499
title: 'Nitro module',
95100
value: 'nitro-module',
96101
description:
97102
'type-safe, fast integration for native APIs to JS (experimental)',
98103
},
99-
{
100-
title: 'Fabric view',
101-
value: 'fabric-view',
102-
description: 'integration for native views to JS',
103-
},
104104
{
105105
title: 'Legacy Native module',
106106
value: 'legacy-module',

packages/create-react-native-library/templates/common/$package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"types": "./lib/typescript/commonjs/src/index.d.ts",
1616
"default": "./lib/commonjs/index.js"
1717
}
18-
}
18+
},
19+
"./package.json": "./package.json"
1920
},
2021
"files": [
2122
"src",
@@ -234,6 +235,13 @@
234235
"android": {
235236
"javaPackageName": "com.<%- project.package %>"
236237
<% if (example === 'vanilla') { -%>
238+
<% if (project.viewConfig === 'fabric-view') { -%>
239+
},
240+
"ios": {
241+
"componentProvider": {
242+
"<%- project.name -%>View": "<%- project.name -%>View"
243+
}
244+
<% } -%>
237245
},
238246
"includesGeneratedCode": true
239247
<% } else { -%>

packages/react-native-builder-bob/src/__tests__/__snapshots__/init.test.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ exports[`initializes the configuration 1`] = `
1717
"types": "./lib/typescript/commonjs/src/index.d.ts",
1818
"default": "./lib/commonjs/index.js"
1919
}
20-
}
20+
},
21+
"./package.json": "./package.json"
2122
},
2223
"source": "./src/index.ts",
2324
"main": "./lib/commonjs/index.js",

packages/react-native-builder-bob/src/init.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export async function init() {
242242

243243
const exportsField = {
244244
'.': {},
245+
'./package.json': './package.json',
245246
};
246247

247248
const importField = {
@@ -265,11 +266,6 @@ export async function init() {
265266
exportsField['.'] = importField;
266267
}
267268

268-
if (pkg.codegenConfig && !pkg.codegenConfig.includesGeneratedCode) {
269-
// @ts-expect-error The exports is not strictly types therefore it doesn't know about the package.json property
270-
exportsField['./package.json'] = './package.json';
271-
}
272-
273269
if (
274270
pkg.exports &&
275271
JSON.stringify(pkg.exports) !== JSON.stringify(exportsField)

0 commit comments

Comments
 (0)