Skip to content
Closed
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
105 changes: 67 additions & 38 deletions packages/create-react-native-library/templates/common/$package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"cpp",
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
"nitrogen",
"nitro.json",
<% } -%>
"nitro.json",
<%
} -%>
"*.podspec",
"react-native.config.js",
"!ios/build",
Expand All @@ -38,17 +39,36 @@
"scripts": {
<% if (example !== 'none') { -%>
"example": "yarn workspace <%- project.slug -%>-example",
<% } -%>
<%
} -%>
<% if (example !== 'expo') { -%>
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
<% } else { -%>
<%
} else { -%>
"clean": "del-cli lib",
<% } -%>
<%
} -%>
"prepare": "bob build",
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
"nitrogen": "nitrogen",
<% } -%>
"typecheck": "tsc"
<%
} -%>
"typecheck": "tsc"<% if (example !== 'none' && example !== 'expo') { %>,
<%# Platform-specific IDE commands %>
<% const platform = process.platform; %>
<% if (platform === 'darwin') { %>
"open:android": "open -a \\\"Android Studio\\\" example/android",
"open:ios": "xed example/ios"
<%
} else if (platform === 'linux') { %>
"open:android": "studio example/android"
<%
} else if (platform === 'win32') { %>
"open:android": "start /d example\\\\android ."
<%
} %>
<%
} %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Trailing comma when platform is unsupported

When example !== 'none' && example !== 'expo' but process.platform is not darwin, linux, or win32 (e.g., freebsd, openbsd, sunos, aix), a comma is added after "typecheck": "tsc" on line 56, but no IDE scripts are generated by lines 59-69. This creates invalid JSON with a trailing comma before the closing brace of the scripts object.

Fix in Cursor Fix in Web

},
"keywords": [
"react-native",
Expand All @@ -71,49 +91,56 @@
"devDependencies": {
<% if (example === 'vanilla' && (project.moduleConfig === 'turbo-modules' || project.viewConfig === 'fabric-view')) { -%>
"@react-native-community/cli": "20.0.1",
<% } -%>
<%
} -%>
"@react-native/babel-preset": "0.81.1",
"@types/react": "^19.1.12",
"del-cli": "^6.0.0",
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
"nitrogen": "^<%- versions.nitro %>",
<% } -%>
<%
} -%>
"react": "19.1.0",
"react-native": "0.81.1",
"react-native-builder-bob": "^<%- versions.bob %>",
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
"react-native-nitro-modules": "^<%- versions.nitro %>",
<% } -%>
<%
} -%>
"typescript": "^5.9.2"
},
"peerDependencies": {
"react": "*",
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
"react-native": "*",
"react-native-nitro-modules": "^<%- versions.nitro %>"
<% } else { -%>
"react-native-nitro-modules": "^<%- versions.nitro %>"
<%
} else { -%>
"react-native": "*"
<% } -%>
<%
} -%>
},
<% if (example !== 'none') { -%>
"workspaces": [
"example"
],
<% } -%>
"example"
],
<%
} -%>
"packageManager": "yarn@4.11.0",
"react-native-builder-bob": {
"source": "src",
"output": "lib",
"targets": [
<% if (project.moduleConfig === "nitro-modules" || project.viewConfig === "nitro-view") { -%>
[
"custom",
{
"script": "nitrogen",
"clean": "nitrogen/"
}
],
<% } -%>
"custom",
{
"script": "nitrogen",
"clean": "nitrogen/"
}
],
<%
} -%>
[
"module",
{
Expand All @@ -128,21 +155,23 @@
]
]
<% if (project.moduleConfig === 'turbo-modules' || project.viewConfig === 'fabric-view') { -%>
},
"codegenConfig": {
"name": "<%- project.name -%><%- project.viewConfig !== null ? 'View': '' -%>Spec",
"type": "<%- project.viewConfig !== null ? 'all': 'modules' -%>",
"jsSrcsDir": "src",
"android": {
"javaPackageName": "com.<%- project.package %>"
<% if (project.viewConfig === 'fabric-view') { -%>
},
"ios": {
"componentProvider": {
"<%- project.name -%>View": "<%- project.name -%>View"
"codegenConfig": {
"name": "<%- project.name -%><%- project.viewConfig !== null ? 'View': '' -%>Spec",
"type": "<%- project.viewConfig !== null ? 'all': 'modules' -%>",
"jsSrcsDir": "src",
"android": {
"javaPackageName": "com.<%- project.package %>"
<% if (project.viewConfig === 'fabric-view') { -%>
},
"ios": {
"componentProvider": {
"<%- project.name -%>View": "<%- project.name -%>View"
}
<%
} -%>
}
<% } -%>
}
<% } -%>
<%
} -%>
}
}
}
Empty file modified packages/react-native-builder-bob/bin/bob.cmd
100644 → 100755
Empty file.