Skip to content

Commit

Permalink
fix: add rootDir to tsconfig for consistent output folder structure (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Sep 14, 2023
1 parent 1a7f290 commit f6225fd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ yarn add --dev react-native-builder-bob
"source": "src",
"output": "lib",
"targets": [
["commonjs", {"copyFlow": true}],
"commonjs",
"module",
"typescript",
]
Expand All @@ -93,7 +93,7 @@ yarn add --dev react-native-builder-bob
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
"react-native": "src/index.ts",
"types": "lib/typescript/index.d.ts",
"types": "lib/typescript/src/index.d.ts",
"files": [
"lib/",
"src/"
Expand All @@ -104,7 +104,7 @@ yarn add --dev react-native-builder-bob

It's usually good to point to your source code with the `react-native` field to make debugging easier. Metro already supports compiling a lot of new syntaxes including JSX, Flow and TypeScript and it will use this field if present.

If you're building TypeScript definition files, also make sure that the `types` field points to a correct path. Depending on the project configuration, the path can be different for you than the example snippet (e.g. `lib/typescript/index.d.ts` if you have only the `src` directory).
If you're building TypeScript definition files, also make sure that the `types` field points to a correct path. Depending on the project configuration, the path can be different for you than the example snippet (e.g. `lib/typescript/index.d.ts` if you have only the `src` directory and `rootDir` is not set).

1. Add the output directory to `.gitignore` and `.eslintignore`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "<%- project.description %>",
"main": "lib/commonjs/index",
"module": "lib/module/index",
"types": "lib/typescript/index.d.ts",
"types": "lib/typescript/src/index.d.ts",
"react-native": "src/index",
"source": "src/index",
"files": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"baseUrl": "./",
"rootDir": ".",
"paths": {
"<%- project.slug -%>": ["./src/index"]
},
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-builder-bob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ yargs
JSON.stringify(
{
compilerOptions: {
rootDir: '.',
allowUnreachableCode: false,
allowUnusedLabels: false,
esModuleInterop: true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"paths": {
"create-react-native-library": [
"./packages/create-react-native-library/src"
Expand Down

0 comments on commit f6225fd

Please sign in to comment.