\ No newline at end of file
+404: This page could not be found
404
This page could not be found.
\ No newline at end of file
diff --git a/_next/static/wLvRp3IVB0wwrh1j6oo_K/_buildManifest.js b/_next/static/IREhZVUVlSWKdmMGX2tNE/_buildManifest.js
similarity index 89%
rename from _next/static/wLvRp3IVB0wwrh1j6oo_K/_buildManifest.js
rename to _next/static/IREhZVUVlSWKdmMGX2tNE/_buildManifest.js
index ee114e2ae..0163e2a54 100644
--- a/_next/static/wLvRp3IVB0wwrh1j6oo_K/_buildManifest.js
+++ b/_next/static/IREhZVUVlSWKdmMGX2tNE/_buildManifest.js
@@ -1 +1 @@
-self.__BUILD_MANIFEST=function(e,s){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[e,s,"static/chunks/pages/index-5981cefc764efe90.js"],"/_error":["static/chunks/pages/_error-c26e849581894657.js"],"/build":[e,s,"static/chunks/pages/build-31dce3fbb6085f73.js"],"/create":[e,s,"static/chunks/pages/create-beec1796b1516eda.js"],"/faq":[e,s,"static/chunks/pages/faq-53749b95b1244585.js"],sortedPages:["/","/_app","/_error","/build","/create","/faq"]}}("static/css/445c4173ffc2bf04.css","static/chunks/571-1ed7697133334290.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
\ No newline at end of file
+self.__BUILD_MANIFEST=function(e,s){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[e,s,"static/chunks/pages/index-5981cefc764efe90.js"],"/_error":["static/chunks/pages/_error-c26e849581894657.js"],"/build":[e,s,"static/chunks/pages/build-7eaa9c98f3f1ca1c.js"],"/create":[e,s,"static/chunks/pages/create-beec1796b1516eda.js"],"/faq":[e,s,"static/chunks/pages/faq-53749b95b1244585.js"],sortedPages:["/","/_app","/_error","/build","/create","/faq"]}}("static/css/445c4173ffc2bf04.css","static/chunks/571-1ed7697133334290.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
\ No newline at end of file
diff --git a/_next/static/wLvRp3IVB0wwrh1j6oo_K/_ssgManifest.js b/_next/static/IREhZVUVlSWKdmMGX2tNE/_ssgManifest.js
similarity index 100%
rename from _next/static/wLvRp3IVB0wwrh1j6oo_K/_ssgManifest.js
rename to _next/static/IREhZVUVlSWKdmMGX2tNE/_ssgManifest.js
diff --git a/_next/static/chunks/nextra-data-en-US.json b/_next/static/chunks/nextra-data-en-US.json
index b489561db..ffbb2122c 100644
--- a/_next/static/chunks/nextra-data-en-US.json
+++ b/_next/static/chunks/nextra-data-en-US.json
@@ -1 +1 @@
-{"/build":{"title":"Build a React Native library","data":{"":"When code is in non-standard syntaxes such as JSX, TypeScript etc, it needs to be compiled before it can run. Configuring this manually can be error-prone and annoying. react-native-builder-bob aims to simplify this process by wrapping babel and tsc and taking care of the configuration. See this section for a longer explanation.Supported targets are:\nGeneric CommonJS build\nES modules build for bundlers such as webpack\nTypeScript definitions\nFlow definitions (copies .js files to .flow files)\nIf you created a project with create-react-native-library, react-native-builder-bob is already pre-configured to build your project. You don't need to configure it again.The following configuration steps are for projects not created with create-react-native-library.","automatic-configuration#Automatic configuration":"To automatically configure your project to use react-native-builder-bob, open a Terminal and run:\nnpx react-native-builder-bob@latest init\nThis will ask you a few questions and add the required configuration and scripts for building the code. The code will be compiled automatically when the package is published.You can find details on what exactly it adds in the Manual configuration section.","manual-configuration#Manual configuration":"To configure your project manually, follow these steps:\nFirst, install react-native-builder-bob in your project. Open a Terminal in your project, and run:\nyarn add --dev react-native-builder-bob\nIn your package.json, specify the targets to build for:\n\"react-native-builder-bob\": {\n \"source\": \"src\",\n \"output\": \"lib\",\n \"targets\": [\n \"commonjs\",\n \"module\",\n \"typescript\",\n ]\n}\nSee the Options section for more details.\nAdd bob to your prepare or prepack step:\n\"scripts\": {\n \"prepare\": \"bob build\"\n}\nNote that there is a difference between prepare and prepack scripts:\nprepare is run when:\nThe package is published with Yarn 1 (yarn publish), npm (npm publish) or pnpm (pnpm publish)\nThe package is installed from a GIT URL with Yarn 1 (yarn add ), npm (npm install ) or pnpm (pnpm add )\nprepack is run when:\nThe package is published with any package manager (yarn publish, npm publish, pnpm publish)\nThe package is installed from a GIT URL with Yarn 4 (yarn add package-name@)\nIf you are not sure which one to use, we recommend going with prepare as it works during both publishing and installing from GIT with more package managers.\nConfigure the appropriate entry points:\n\"main\": \"lib/commonjs/index.js\",\n\"module\": \"lib/module/index.js\",\n\"types\": \"lib/typescript/src/index.d.ts\",\n\"source\": \"src/index.ts\",\n\"files\": [\n \"lib\",\n \"src\"\n]\nHere is what each of these fields mean:\nmain: The entry point for the commonjs build. This is used by Node - such as tests, SSR etc.\nmodule: The entry point for the ES module build. This is used by bundlers such as webpack.\ntypes: The entry point for the TypeScript definitions. This is used by TypeScript to type check the code using your library.\nsource: 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.\nfiles: The files to include in the package when publishing with npm.\nMake sure to change specify correct files according to the targets you have enabled.NOTE: 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).\nAdd the output directory to .gitignore and .eslintignore\n# generated files by bob\nlib/\nThis makes sure that you don't accidentally commit the generated files to git or get lint errors for them.\nAdd the output directory to jest.modulePathIgnorePatterns if you use Jest\n\"modulePathIgnorePatterns\": [\"/lib/\"]\nThis makes sure that Jest doesn't try to run the tests in the generated files.\nAnd we're done 🎉","options#Options":"The options can be specified in the package.json file under the react-native-builder-bob property, or in a bob.config.js file in your project directory.","source#source":"The name of the folder with the source code which should be compiled. The folder should include an index file.","output#output":"The name of the folder where the compiled files should be output to. It will contain separate folder for each target.","exclude#exclude":"Glob pattern to be used while filtering the unnecessary files. Defaults to '**/{__tests__,__fixtures__,__mocks__}/**' if not specified.Example:\n{\n \"exclude\": \"ignore_me/**\"\n}\nThis option only works with commonjs and module targets. To exclude files while building typescript, please see the tsconfig exclude field.","targets#targets":"Various targets to build for. The available targets are:","commonjs#commonjs":"Enable compiling source files with Babel and use commonjs module system.This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the main field of package.json.By default, the code is compiled to support last 2 versions of modern browsers. It also strips TypeScript and Flow annotations, and compiles JSX. You can customize the environments to compile for by using a browserslist config.In addition, the following options are supported:\nconfigFile (boolean | string): To customize the babel config used, you can pass the configFile option as true if you have a babel.config.js or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the react-native-builder-bob/babel-preset preset.\nbabelrc (boolean): You can set the babelrc option to true to enable using .babelrc files.\ncopyFlow (boolean): If your source code is written in Flow, You can specify the copyFlow option to copy the source files as .js.flow to the output folder. If the main entry in package.json points to the index file in the output folder, the flow type checker will pick these files up to use for type definitions.\nsourceMaps (boolean): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the sourceMaps option to false.\nExample:\n[\"commonjs\", { \"configFile\": true, \"copyFlow\": true }]","module#module":"Enable compiling source files with Babel and use ES module system. This is essentially same as the commonjs target and accepts the same options, but leaves the import/export statements in your code.This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the module field of package.json.Example:\n[\"module\", { \"configFile\": true }]","typescript#typescript":"Enable generating type definitions with tsc if your source code is written in TypeScript.The following options are supported:\nproject (string): By default, the tsconfig.json file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the project option. This can be useful if you need to use different configs for development and production.\ntsc (string): The path to the tsc binary is automatically detected and defaults to the one installed in your project. You can use the tsc option to specify a different path.\nExample:\n[\"typescript\", { \"project\": \"tsconfig.build.json\" }]","commands#Commands":"The bob CLI exposes the following commands:","init#init":"This configures an existing project to use bob by adding the required configuration and dependencies. This is usually run with npx:\nnpx react-native-builder-bob@latest init","build#build":"This builds the project according to the configuration. This is usually run as part of the package's publishing flow, i.e. in the prepare or prepack scripts.\n\"scripts\": {\n \"prepare\": \"bob build\"\n}"}},"/create":{"title":"Scaffold a React Native library","data":{"":"If you want to create your own React Native library, scaffolding the project can be a daunting task. create-react-native-library can scaffold a new project for you with all the necessary tools configured.","features#Features":"Minimal boilerplate for libraries on which you can build upon\nExample React Native app to test your library code\nTypeScript to ensure type-safe code and better DX\nSupport for Turbo Modules & Fabric\nSupport for Kotlin on Android & Swift on iOS\nSupport for C++ to write cross-platform native code\nExpo for libraries without native code and web support\nESLint, Prettier, TypeScript, Lefthook and Release It pre-configured\nreact-native-builder-bob pre-configured to compile your files\nGitHub Actions pre-configured to run tests and lint on the CI","usage#Usage":"To create new project, run the following:\nnpx create-react-native-library@latest awesome-library\nThis will ask you a few questions about your project and generate a new project in a folder named awesome-library.After the project is created, you can find the development workflow in the generated CONTRIBUTING.md file.","local-library#Local library":"While the default templates are for libraries that are published to npm, you can also create a local library that is not published but used locally in your app.You'd typically use a local library when:\nYou're building a native library for your app and don't want to publish it to npm.\nYou want to be able to easily copy the library to other projects.\nYou're in a monorepo and want to keep the library code in the same repository as the app.\nYou're using Expo, but want to use vanilla React Native API for native modules and components.\nThe structure of the app with a local library may look like this:\nMyApp\n├── node_modules\n├── modules <-- folder for your local libraries\n│ └── awesome-library <-- your local library\n├── android\n├── ios\n├── src\n├── index.js\n└── package.json\nIf you run create-react-native-library in an existing project containing a package.json, it'll be automatically detected and you'll be asked if you want to create a local library. You can also pass the --local flag to the command to explicitly create a local library:\nnpx create-react-native-library@latest awesome-library --local\nThe local library is created outside of the android and ios folders and makes use of autolinking to integrate with your app. It also doesn't include a separate example app and additional dependencies that are configured in the default templates. This is an alternative approach to the setup mentioned in React Native docs.The advantages of this approach are:\nIt's easier to upgrade React Native as you don't need to worry about custom code in android and ios folders.\nIt can be used with Expo managed projects with custom development client.\nIt's easier to copy the library to other projects or publish later if needed.\nThe boilerplate for the library doesn't need to be written from scratch.\nIt can be used with monorepos where the additional tooling in the default templates may not be needed.\nBy default, the generated library is automatically linked to the project using link: protocol when using Yarn and file: when using npm:\n\"dependencies\": {\n \"react-native-awesome-library\": \"link:./modules/awesome-library\"\n}\nThis creates a symlink to the library under node_modules which makes autolinking work. But if you're using a monorepo or have non-standard setup, you'll need to manually set up the package to be linked to your app based on your project setup.","writing-native-code#Writing native code":"Once the project is created, you can follow the official React Native docs to learn the API for writing native modules and components:\nNative Modules\nNative UI Components for Android\nNative UI Components for iOS\nTurbo Modules\nFabric Components"}},"/faq":{"title":"Frequently Asked Questions","data":{"why-should-i-compile-my-project-with-react-native-builder-bob#Why should I compile my project with react-native-builder-bob?":"We often write our library code in non-standard syntaxes such as JSX, TypeScript etc. as well as proposed syntaxes which aren't part of the standard yet. This means that our code needs to be compiled to be able to run on JavaScript engines.When using the library in a React Native app, Metro handles compiling the source code. However, it's also possible to use them in other targets such as:\nBrowsers or bundlers such as webpack (if we support Web)\nNode.js for tests or SSR etc.\nSo the code needs to be precompiled so these tools can parse it. In addition, we need to generate type definition files for TypeScript etc.To handle such multiple targets, one solution could is to have multiple babel configs (or TypeScript configs) and have a babel-cli command in our package.json for compilation. Ideally, we should also keep the configs in sync between our several projects.As an example, this is a command that we had in one of the packages:\nbabel --extensions '.js,.ts,.tsx' --no-babelrc --config-file=./babel.config.publish.js src --ignore '**/__tests__/**' --copy-files --source-maps --delete-dir-on-start --out-dir dist && del-cli 'dist/**/__tests__' && yarn tsc --emitDeclarationOnly\nAs you can see, it's quite long and hard to read. There's even a separate babel.config.publish.js file. And this only works for webpack and Metro, and will fail on Node due to ESM usage.react-native-builder-bob wraps tools such as babel and typescript to simplify these common tasks across multiple projects. While it can be used for any library, it's primarily tailored to React Native projects to minimize the configuration required.","how-do-i-add-a-react-native-library-containing-native-code-as-a-dependency-in-my-library#How do I add a react-native library containing native code as a dependency in my library?":"If your library depends on another react-native library containing native code, you should do the following:\nAdd the native library to peerDependenciesThis means that the consumer of the library will need to install the native library and add it to the dependencies section of their package.json. It makes sure that:\nThere are no version conflicts if another package also happens to use the same library, or if the user wants to use the library in their app. While there can be multiple versions of a JavaScript-only library, there can only be one version of a native library - so avoiding version conflicts is important.\nThe package manager installs it in correct location so that autolinking can work properly.\nDon't add the native library to dependencies of your library, otherwise it may cause issues for the user even if it seems to work.\nAdd the native library to devDependenciesThis makes sure that you can use it for tests, and there are no other errors such as type errors due to the missing module.\nAdd the native library to dependencies in the package.json under exampleThis is equivalent to the consumer of the library installing the dependency, and is needed so that this module is also available to the example app.","how-to-upgrade-the-react-native-version-in-the-generated-project#How to upgrade the react-native version in the generated project?":"Since this is a library, the react-native version specified in the package.json is not relevant for the consumers. It's only used for developing and testing the library. If you'd like to upgrade the react-native version to test with it, you'd need to:\nBump versions of the following packages under devDependencies in the package.json:\nreact-native\nreact\n@types/react\n@types/react-native\nIf you have any other related packages such as react-test-renderer, make sure to bump them as well.\nUpgrade react-native in the example appThe example app is a React Native app that can be updated following the same process as a regular React Native app. The process will vary depending on if it's using Expo or React Native CLI. See the official upgrade guide for more details.\nTo avoid issues, make sure that the versions of react and react-native are the same in example/package.json and the package.json at the root.","how-does-the-library-get-linked-to-the-example-app-in-the-generated-project#How does the library get linked to the example app in the generated project?":"If you generate a project with create-react-native-library, you get an example app to test your library. It's good to understand how the library gets linked to the example app in case you want to tweak how it works or if you run into issues.There are 2 parts to this process.\nAliasing the JavaScript codeThe JavaScript (or TypeScript) source code is aliased to be used by the example app. This makes it so that when you import from 'your-library-name', it imports the source code directly and avoids having to rebuild the library for JavaScript only changes. We configure several tools to make this work:\nBabel is configured to use the alias in example/babel.config.js using babel-plugin-module-resolver. This transforms the imports to point to the source code instead.\nMetro is configured to allow importing from outside of the example directory by configuring watchFolders, and to use the appropriate peer dependencies. This configuration exists in the example/metro.config.js file.\nWebpack is configured to compile the library source code when running on the Web. This configuration exists in the example/webpack.config.js file.\nTypeScript is configured to use the source code for type checking by using the paths property under compilerOptions. This configuration exists in the tsconfig.json file at the root.\nLinking the native codeBy default, React Native CLI only links the modules installed under node_module of the app. To be able to link the android and ios folders from the project root, the path is specified in the example/react-native.config.js file.","how-to-test-the-library-in-an-app-locally#How to test the library in an app locally?":"You may have come across the yarn link and npm link commands, or used npm install ../path/to/folder or yarn add ../path/to/folder to test libraries locally. These commands may work for simple packages without build process, but they have different behavior from how a published package works, e.g. .npmignore is not respected, the structure of node_modules is different, etc. So we don't recommended using these approaches to test libraries locally.For more accurate testing, there are various other approaches:\nLocal tarball with npmFirst, temporarily change the version in package.json to something like 0.0.0-local.0. This version number needs to be updated to something different every time you do this to avoid stale content.Run the following command inside your library's root:\nnpm pack\nThis will generate a file like your-library-name-0.0.0-local.0.tgz in the root of the project.Then, you can install the tarball in your app:\nyarn add ../path/to/your-library-name-0.0.0-local.0.tgz\nOr if you use npm:\nnpm install ../path/to/your-library-name-0.0.0-local.0.tgz\nYalcYalc acts as a local repository for packages that can be used to test packages locally. It's similar to the previous workflow, but more convenient to use.You can find installation and usage instructions in the Yalc documentation.\nVerdaccioVerdaccio is a lightweight private npm registry that can be used to test packages locally. The advantage of using Verdaccio is that it allows to test the complete workflow of publishing and installing a package without actually publishing it to a remote registry.You can find installation and usage instructions in the Verdaccio documentation.","users-get-a-warning-when-they-install-my-library#Users get a warning when they install my library":"If users are using Yarn 1, they may get a warning when installing your library:\nwarning Workspaces can only be enabled in private projects.\nThis is because the example app is configured as a Yarn workspace, and there is a bug in Yarn 1 which causes this warning to be shown for third-party packages. It has no impact for the consumers of the library and the warning can be ignored. If consumers would like to get rid of the warning, there are 2 options:\nDisable workspacesIf the consumer doesn't use Yarn workspaces, they can disable it by adding the following to the .yarnrc file in the root of their project:\nworkspaces-experimental false\nUpgrade to Yarn 3Yarn 1 is no longer maintained, so it's recommended to upgrade to Yarn 3. Yarn 3 works with React Native projects with the node-modules linker. To upgrade, consumers can follow the official upgrade guide.It's also necessary to use node-modules linker. To use it, consumers can add the following to the .yarnrc.yml file in the root of their project:\nnodeLinker: node-modules"}},"/":{"title":"Introduction","data":{"":"This project is a collection of tools to make it easier to build React Native libraries. It contains the following CLIs:\ncreate-react-native-library - a CLI to scaffold a React Native library.\nreact-native-builder-bob - a CLI to build React Native libraries for various targets."}}}
\ No newline at end of file
+{"/build":{"title":"Build a React Native library","data":{"":"When code is in non-standard syntaxes such as JSX, TypeScript etc, it needs to be compiled before it can run. Configuring this manually can be error-prone and annoying. react-native-builder-bob aims to simplify this process by wrapping babel and tsc and taking care of the configuration. See this section for a longer explanation.Supported targets are:\nGeneric CommonJS build\nES modules build for bundlers such as webpack\nTypeScript definitions\nFlow definitions (copies .js files to .flow files)\nIf you created a project with create-react-native-library, react-native-builder-bob is already pre-configured to build your project. You don't need to configure it again.The following configuration steps are for projects not created with create-react-native-library.","automatic-configuration#Automatic configuration":"To automatically configure your project to use react-native-builder-bob, open a Terminal and run:\nnpx react-native-builder-bob@latest init\nThis will ask you a few questions and add the required configuration and scripts for building the code. The code will be compiled automatically when the package is published.You can find details on what exactly it adds in the Manual configuration section.","manual-configuration#Manual configuration":"To configure your project manually, follow these steps:\nFirst, install react-native-builder-bob in your project. Open a Terminal in your project, and run:\nyarn add --dev react-native-builder-bob\nIn your package.json, specify the targets to build for:\n\"react-native-builder-bob\": {\n \"source\": \"src\",\n \"output\": \"lib\",\n \"targets\": [\n [\"commonjs\", { \"esm\" : true }],\n [\"module\", { \"esm\" : true }],\n \"typescript\",\n ]\n}\nSee the Options section for more details.\nAdd bob to your prepare or prepack step:\n\"scripts\": {\n \"prepare\": \"bob build\"\n}\nNote that there is a difference between prepare and prepack scripts:\nprepare is run when:\nThe package is published with Yarn 1 (yarn publish), npm (npm publish) or pnpm (pnpm publish)\nThe package is installed from a GIT URL with Yarn 1 (yarn add ), npm (npm install ) or pnpm (pnpm add )\nprepack is run when:\nThe package is published with any package manager (yarn publish, npm publish, pnpm publish)\nThe package is installed from a GIT URL with Yarn 4 (yarn add package-name@)\nIf you are not sure which one to use, we recommend going with prepare as it works during both publishing and installing from GIT with more package managers.\nConfigure the appropriate entry points:\n\"source\": \"./src/index.tsx\",\n\"main\": \"./lib/commonjs/index.cjs\",\n\"module\": \"./lib/module/index.mjs\",\n\"types\": \"./lib/typescript/src/index.d.ts\",\n\"exports\": {\n \".\": {\n \"types\": \"./typescript/src/index.d.ts\",\n \"require\": \"./commonjs/index.cjs\",\n \"import\": \"./module/index.mjs\"\n }\n},\n\"files\": [\n \"lib\",\n \"src\"\n]\nHere is what each of these fields mean:\nsource: 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.\nmain: The entry point for the commonjs build. This is used by Node - such as tests, SSR etc.\nmodule: The entry point for the ES module build. This is used by bundlers such as webpack.\ntypes: The entry point for the TypeScript definitions. This is used by TypeScript to type check the code using your library.\nfiles: The files to include in the package when publishing with npm.\nexports: The entry points for tools that support the exports field in package.json - such as Node.js 12+ & modern browsers.\nMake sure to change specify correct files according to the targets you have enabled.\nThe exports field also requires the esm option to be enabled for the commonjs and module targets. In addition, the file extensions of the generated files will be .js instead of .cjs and .mjs if the esm option is not enabled.\nIf 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).\nAdd the output directory to .gitignore and .eslintignore\n# generated files by bob\nlib/\nThis makes sure that you don't accidentally commit the generated files to git or get lint errors for them.\nAdd the output directory to jest.modulePathIgnorePatterns if you use Jest\n\"modulePathIgnorePatterns\": [\"/lib/\"]\nThis makes sure that Jest doesn't try to run the tests in the generated files.\nAnd we're done 🎉","options#Options":"The options can be specified in the package.json file under the react-native-builder-bob property, or in a bob.config.js file in your project directory.","source#source":"The name of the folder with the source code which should be compiled. The folder should include an index file.","output#output":"The name of the folder where the compiled files should be output to. It will contain separate folder for each target.","exclude#exclude":"Glob pattern to be used while filtering the unnecessary files. Defaults to '**/{__tests__,__fixtures__,__mocks__}/**' if not specified.Example:\n{\n \"exclude\": \"ignore_me/**\"\n}\nThis option only works with commonjs and module targets. To exclude files while building typescript, please see the tsconfig exclude field.","targets#targets":"Various targets to build for. The available targets are:","commonjs#commonjs":"Enable compiling source files with Babel and use commonjs module system.This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the main field and exports['.'].require (when esm: true) field of package.json.By default, the code is compiled to support the last 2 versions of modern browsers. It also strips TypeScript and Flow annotations as well as compiles JSX. You can customize the environments to compile for by using a browserslist config.In addition, the following options are supported:\nesm (boolean): Enabling this option will output ES modules compatible code for Node.js 12+, modern browsers and other tools that support package.json's exports field. This mainly adds file extensions to the imports and exports. Note that file extensions are not added when importing a file that may have platform-specific extensions (e.g. .android.ts). In addition, the generated files will have .cjs (commonjs) and .mjs (modules) extensions instead of .js - this is necessary to disambiguate between the two formats.\nconfigFile (boolean | string): To customize the babel config used, you can pass the configFile option as true if you have a babel.config.js or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the react-native-builder-bob/babel-preset preset.\nbabelrc (boolean): You can set the babelrc option to true to enable using .babelrc files.\ncopyFlow (boolean): If your source code is written in Flow, You can specify the copyFlow option to copy the source files as .js.flow to the output folder. If the main entry in package.json points to the index file in the output folder, the flow type checker will pick these files up to use for type definitions.\nsourceMaps (boolean): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the sourceMaps option to false.\nExample:\n[\"commonjs\", { \"esm\": true, \"copyFlow\": true }]","module#module":"Enable compiling source files with Babel and use ES module system. This is essentially same as the commonjs target and accepts the same options, but leaves the import/export statements in your code.This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the module field and exports['.'].import (when esm: true) field of package.json.Example:\n[\"module\", { \"esm\": true, \"sourceMaps\": false }]","typescript#typescript":"Enable generating type definitions with tsc if your source code is written in TypeScript.The following options are supported:\nproject (string): By default, the tsconfig.json file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the project option. This can be useful if you need to use different configs for development and production.\ntsc (string): The path to the tsc binary is automatically detected and defaults to the one installed in your project. You can use the tsc option to specify a different path.\nExample:\n[\"typescript\", { \"project\": \"tsconfig.build.json\" }]\nThe output file should be referenced in the types field or exports['.'].types field of package.json.","commands#Commands":"The bob CLI exposes the following commands:","init#init":"This configures an existing project to use bob by adding the required configuration and dependencies. This is usually run with npx:\nnpx react-native-builder-bob@latest init","build#build":"This builds the project according to the configuration. This is usually run as part of the package's publishing flow, i.e. in the prepare or prepack scripts.\n\"scripts\": {\n \"prepare\": \"bob build\"\n}"}},"/create":{"title":"Scaffold a React Native library","data":{"":"If you want to create your own React Native library, scaffolding the project can be a daunting task. create-react-native-library can scaffold a new project for you with all the necessary tools configured.","features#Features":"Minimal boilerplate for libraries on which you can build upon\nExample React Native app to test your library code\nTypeScript to ensure type-safe code and better DX\nSupport for Turbo Modules & Fabric\nSupport for Kotlin on Android & Swift on iOS\nSupport for C++ to write cross-platform native code\nExpo for libraries without native code and web support\nESLint, Prettier, TypeScript, Lefthook and Release It pre-configured\nreact-native-builder-bob pre-configured to compile your files\nGitHub Actions pre-configured to run tests and lint on the CI","usage#Usage":"To create new project, run the following:\nnpx create-react-native-library@latest awesome-library\nThis will ask you a few questions about your project and generate a new project in a folder named awesome-library.After the project is created, you can find the development workflow in the generated CONTRIBUTING.md file.","local-library#Local library":"While the default templates are for libraries that are published to npm, you can also create a local library that is not published but used locally in your app.You'd typically use a local library when:\nYou're building a native library for your app and don't want to publish it to npm.\nYou want to be able to easily copy the library to other projects.\nYou're in a monorepo and want to keep the library code in the same repository as the app.\nYou're using Expo, but want to use vanilla React Native API for native modules and components.\nThe structure of the app with a local library may look like this:\nMyApp\n├── node_modules\n├── modules <-- folder for your local libraries\n│ └── awesome-library <-- your local library\n├── android\n├── ios\n├── src\n├── index.js\n└── package.json\nIf you run create-react-native-library in an existing project containing a package.json, it'll be automatically detected and you'll be asked if you want to create a local library. You can also pass the --local flag to the command to explicitly create a local library:\nnpx create-react-native-library@latest awesome-library --local\nThe local library is created outside of the android and ios folders and makes use of autolinking to integrate with your app. It also doesn't include a separate example app and additional dependencies that are configured in the default templates. This is an alternative approach to the setup mentioned in React Native docs.The advantages of this approach are:\nIt's easier to upgrade React Native as you don't need to worry about custom code in android and ios folders.\nIt can be used with Expo managed projects with custom development client.\nIt's easier to copy the library to other projects or publish later if needed.\nThe boilerplate for the library doesn't need to be written from scratch.\nIt can be used with monorepos where the additional tooling in the default templates may not be needed.\nBy default, the generated library is automatically linked to the project using link: protocol when using Yarn and file: when using npm:\n\"dependencies\": {\n \"react-native-awesome-library\": \"link:./modules/awesome-library\"\n}\nThis creates a symlink to the library under node_modules which makes autolinking work. But if you're using a monorepo or have non-standard setup, you'll need to manually set up the package to be linked to your app based on your project setup.","writing-native-code#Writing native code":"Once the project is created, you can follow the official React Native docs to learn the API for writing native modules and components:\nNative Modules\nNative UI Components for Android\nNative UI Components for iOS\nTurbo Modules\nFabric Components"}},"/faq":{"title":"Frequently Asked Questions","data":{"why-should-i-compile-my-project-with-react-native-builder-bob#Why should I compile my project with react-native-builder-bob?":"We often write our library code in non-standard syntaxes such as JSX, TypeScript etc. as well as proposed syntaxes which aren't part of the standard yet. This means that our code needs to be compiled to be able to run on JavaScript engines.When using the library in a React Native app, Metro handles compiling the source code. However, it's also possible to use them in other targets such as:\nBrowsers or bundlers such as webpack (if we support Web)\nNode.js for tests or SSR etc.\nSo the code needs to be precompiled so these tools can parse it. In addition, we need to generate type definition files for TypeScript etc.To handle such multiple targets, one solution could is to have multiple babel configs (or TypeScript configs) and have a babel-cli command in our package.json for compilation. Ideally, we should also keep the configs in sync between our several projects.As an example, this is a command that we had in one of the packages:\nbabel --extensions '.js,.ts,.tsx' --no-babelrc --config-file=./babel.config.publish.js src --ignore '**/__tests__/**' --copy-files --source-maps --delete-dir-on-start --out-dir dist && del-cli 'dist/**/__tests__' && yarn tsc --emitDeclarationOnly\nAs you can see, it's quite long and hard to read. There's even a separate babel.config.publish.js file. And this only works for webpack and Metro, and will fail on Node due to ESM usage.react-native-builder-bob wraps tools such as babel and typescript to simplify these common tasks across multiple projects. While it can be used for any library, it's primarily tailored to React Native projects to minimize the configuration required.","how-do-i-add-a-react-native-library-containing-native-code-as-a-dependency-in-my-library#How do I add a react-native library containing native code as a dependency in my library?":"If your library depends on another react-native library containing native code, you should do the following:\nAdd the native library to peerDependenciesThis means that the consumer of the library will need to install the native library and add it to the dependencies section of their package.json. It makes sure that:\nThere are no version conflicts if another package also happens to use the same library, or if the user wants to use the library in their app. While there can be multiple versions of a JavaScript-only library, there can only be one version of a native library - so avoiding version conflicts is important.\nThe package manager installs it in correct location so that autolinking can work properly.\nDon't add the native library to dependencies of your library, otherwise it may cause issues for the user even if it seems to work.\nAdd the native library to devDependenciesThis makes sure that you can use it for tests, and there are no other errors such as type errors due to the missing module.\nAdd the native library to dependencies in the package.json under exampleThis is equivalent to the consumer of the library installing the dependency, and is needed so that this module is also available to the example app.","how-to-upgrade-the-react-native-version-in-the-generated-project#How to upgrade the react-native version in the generated project?":"Since this is a library, the react-native version specified in the package.json is not relevant for the consumers. It's only used for developing and testing the library. If you'd like to upgrade the react-native version to test with it, you'd need to:\nBump versions of the following packages under devDependencies in the package.json:\nreact-native\nreact\n@types/react\n@types/react-native\nIf you have any other related packages such as react-test-renderer, make sure to bump them as well.\nUpgrade react-native in the example appThe example app is a React Native app that can be updated following the same process as a regular React Native app. The process will vary depending on if it's using Expo or React Native CLI. See the official upgrade guide for more details.\nTo avoid issues, make sure that the versions of react and react-native are the same in example/package.json and the package.json at the root.","how-does-the-library-get-linked-to-the-example-app-in-the-generated-project#How does the library get linked to the example app in the generated project?":"If you generate a project with create-react-native-library, you get an example app to test your library. It's good to understand how the library gets linked to the example app in case you want to tweak how it works or if you run into issues.There are 2 parts to this process.\nAliasing the JavaScript codeThe JavaScript (or TypeScript) source code is aliased to be used by the example app. This makes it so that when you import from 'your-library-name', it imports the source code directly and avoids having to rebuild the library for JavaScript only changes. We configure several tools to make this work:\nBabel is configured to use the alias in example/babel.config.js using babel-plugin-module-resolver. This transforms the imports to point to the source code instead.\nMetro is configured to allow importing from outside of the example directory by configuring watchFolders, and to use the appropriate peer dependencies. This configuration exists in the example/metro.config.js file.\nWebpack is configured to compile the library source code when running on the Web. This configuration exists in the example/webpack.config.js file.\nTypeScript is configured to use the source code for type checking by using the paths property under compilerOptions. This configuration exists in the tsconfig.json file at the root.\nLinking the native codeBy default, React Native CLI only links the modules installed under node_module of the app. To be able to link the android and ios folders from the project root, the path is specified in the example/react-native.config.js file.","how-to-test-the-library-in-an-app-locally#How to test the library in an app locally?":"You may have come across the yarn link and npm link commands, or used npm install ../path/to/folder or yarn add ../path/to/folder to test libraries locally. These commands may work for simple packages without build process, but they have different behavior from how a published package works, e.g. .npmignore is not respected, the structure of node_modules is different, etc. So we don't recommended using these approaches to test libraries locally.For more accurate testing, there are various other approaches:\nLocal tarball with npmFirst, temporarily change the version in package.json to something like 0.0.0-local.0. This version number needs to be updated to something different every time you do this to avoid stale content.Run the following command inside your library's root:\nnpm pack\nThis will generate a file like your-library-name-0.0.0-local.0.tgz in the root of the project.Then, you can install the tarball in your app:\nyarn add ../path/to/your-library-name-0.0.0-local.0.tgz\nOr if you use npm:\nnpm install ../path/to/your-library-name-0.0.0-local.0.tgz\nYalcYalc acts as a local repository for packages that can be used to test packages locally. It's similar to the previous workflow, but more convenient to use.You can find installation and usage instructions in the Yalc documentation.\nVerdaccioVerdaccio is a lightweight private npm registry that can be used to test packages locally. The advantage of using Verdaccio is that it allows to test the complete workflow of publishing and installing a package without actually publishing it to a remote registry.You can find installation and usage instructions in the Verdaccio documentation.","users-get-a-warning-when-they-install-my-library#Users get a warning when they install my library":"If users are using Yarn 1, they may get a warning when installing your library:\nwarning Workspaces can only be enabled in private projects.\nThis is because the example app is configured as a Yarn workspace, and there is a bug in Yarn 1 which causes this warning to be shown for third-party packages. It has no impact for the consumers of the library and the warning can be ignored. If consumers would like to get rid of the warning, there are 2 options:\nDisable workspacesIf the consumer doesn't use Yarn workspaces, they can disable it by adding the following to the .yarnrc file in the root of their project:\nworkspaces-experimental false\nUpgrade to Yarn 3Yarn 1 is no longer maintained, so it's recommended to upgrade to Yarn 3. Yarn 3 works with React Native projects with the node-modules linker. To upgrade, consumers can follow the official upgrade guide.It's also necessary to use node-modules linker. To use it, consumers can add the following to the .yarnrc.yml file in the root of their project:\nnodeLinker: node-modules"}},"/":{"title":"Introduction","data":{"":"This project is a collection of tools to make it easier to build React Native libraries. It contains the following CLIs:\ncreate-react-native-library - a CLI to scaffold a React Native library.\nreact-native-builder-bob - a CLI to build React Native libraries for various targets."}}}
\ No newline at end of file
diff --git a/_next/static/chunks/pages/build-31dce3fbb6085f73.js b/_next/static/chunks/pages/build-31dce3fbb6085f73.js
deleted file mode 100644
index 99a1b8193..000000000
--- a/_next/static/chunks/pages/build-31dce3fbb6085f73.js
+++ /dev/null
@@ -1 +0,0 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[881],{7272:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/build",function(){return n(6338)}])},6338:function(e,s,n){"use strict";n.r(s),n.d(s,{__toc:function(){return a},default:function(){return p}});var i=n(4246),r=n(9304),l=n(2917),o=n(6282);n(6288);var t=n(1441),c={src:"/react-native-builder-bob//_next/static/media/react-native-builder-bob.f743a9da.svg",height:581,width:840,blurWidth:0,blurHeight:0};let a=[{depth:2,value:"Automatic configuration",id:"automatic-configuration"},{depth:2,value:"Manual configuration",id:"manual-configuration"},{depth:2,value:"Options",id:"options"},{depth:3,value:"source",id:"source"},{depth:3,value:"output",id:"output"},{depth:3,value:"exclude",id:"exclude"},{depth:3,value:"targets",id:"targets"},{depth:4,value:"commonjs",id:"commonjs"},{depth:4,value:"module",id:"module"},{depth:4,value:"typescript",id:"typescript"},{depth:2,value:"Commands",id:"commands"},{depth:3,value:"init",id:"init"},{depth:3,value:"build",id:"build"}];function d(e){let s=Object.assign({h1:"h1",p:"p",code:"code",a:"a",ul:"ul",li:"li",strong:"strong",h2:"h2",pre:"pre",span:"span",ol:"ol",h3:"h3",blockquote:"blockquote",h4:"h4",img:"img"},(0,t.a)(),e.components);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.h1,{children:"Build a React Native library"}),"\n",(0,i.jsxs)(s.p,{children:["When code is in non-standard syntaxes such as JSX, TypeScript etc, it needs to be compiled before it can run. Configuring this manually can be error-prone and annoying. ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," aims to simplify this process by wrapping ",(0,i.jsx)(s.code,{children:"babel"})," and ",(0,i.jsx)(s.code,{children:"tsc"})," and taking care of the configuration. See ",(0,i.jsx)(s.a,{href:"./faq#why-should-i-compile-my-project-with-react-native-builder-bob",children:"this section"})," for a longer explanation."]}),"\n",(0,i.jsx)(s.p,{children:"Supported targets are:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:"Generic CommonJS build"}),"\n",(0,i.jsxs)(s.li,{children:["ES modules build for bundlers such as ",(0,i.jsx)(s.a,{href:"https://webpack.js.org",children:"webpack"})]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.a,{href:"https://www.typescriptlang.org/",children:"TypeScript"})," definitions"]}),"\n",(0,i.jsx)(s.li,{children:"Flow definitions (copies .js files to .flow files)"}),"\n"]}),"\n",(0,i.jsxs)(s.p,{children:["If you created a project with ",(0,i.jsx)(s.a,{href:"./create",children:(0,i.jsx)(s.code,{children:"create-react-native-library"})}),", ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," is ",(0,i.jsx)(s.strong,{children:"already pre-configured to build your project"}),". You don't need to configure it again."]}),"\n",(0,i.jsxs)(s.p,{children:["The following configuration steps are for projects not created with ",(0,i.jsx)(s.code,{children:"create-react-native-library"}),"."]}),"\n",(0,i.jsx)(s.h2,{id:"automatic-configuration",children:"Automatic configuration"}),"\n",(0,i.jsxs)(s.p,{children:["To automatically configure your project to use ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"}),", open a Terminal and run:"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"js","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"js","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"npx react"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"-"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"native"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"-"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"builder"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"-"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"bob@latest init"})]})})}),"\n",(0,i.jsx)(s.p,{children:"This will ask you a few questions and add the required configuration and scripts for building the code. The code will be compiled automatically when the package is published."}),"\n",(0,i.jsxs)(s.p,{children:["You can find details on what exactly it adds in the ",(0,i.jsx)(s.a,{href:"#manual-configuration",children:"Manual configuration"})," section."]}),"\n",(0,i.jsx)(s.h2,{id:"manual-configuration",children:"Manual configuration"}),"\n",(0,i.jsx)(s.p,{children:"To configure your project manually, follow these steps:"}),"\n",(0,i.jsxs)(s.ol,{children:["\n",(0,i.jsxs)(s.li,{children:["First, install ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," in your project. Open a Terminal in your project, and run:"]}),"\n"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"sh","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"sh","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"yarn"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"add"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"--dev"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"react-native-builder-bob"})]})})}),"\n",(0,i.jsxs)(s.ol,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["In your ",(0,i.jsx)(s.code,{children:"package.json"}),", specify the targets to build for:"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"react-native-builder-bob"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"source"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"src"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"output"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"targets"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" ["})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"commonjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"module"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"typescript"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" ]"})}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsxs)(s.p,{children:["See the ",(0,i.jsx)(s.a,{href:"#options",children:"Options"})," section for more details."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Add ",(0,i.jsx)(s.code,{children:"bob"})," to your ",(0,i.jsx)(s.code,{children:"prepare"})," or ",(0,i.jsx)(s.code,{children:"prepack"})," step:"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"js","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"js","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"scripts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"prepare"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"bob build"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsxs)(s.p,{children:["Note that there is a difference between ",(0,i.jsx)(s.code,{children:"prepare"})," and ",(0,i.jsx)(s.code,{children:"prepack"})," scripts:"]}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"prepare"})," is run when:\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["The package is published with Yarn 1 (",(0,i.jsx)(s.code,{children:"yarn publish"}),"), npm (",(0,i.jsx)(s.code,{children:"npm publish"}),") or pnpm (",(0,i.jsx)(s.code,{children:"pnpm publish"}),")"]}),"\n",(0,i.jsxs)(s.li,{children:["The package is installed from a GIT URL with Yarn 1 (",(0,i.jsx)(s.code,{children:"yarn add "}),"), npm (",(0,i.jsx)(s.code,{children:"npm install "}),") or pnpm (",(0,i.jsx)(s.code,{children:"pnpm add "}),")"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"prepack"})," is run when:\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["The package is published with any package manager (",(0,i.jsx)(s.code,{children:"yarn publish"}),", ",(0,i.jsx)(s.code,{children:"npm publish"}),", ",(0,i.jsx)(s.code,{children:"pnpm publish"}),")"]}),"\n",(0,i.jsxs)(s.li,{children:["The package is installed from a GIT URL with Yarn 4 (",(0,i.jsx)(s.code,{children:"yarn add package-name@"}),")"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(s.p,{children:["If you are not sure which one to use, we recommend going with ",(0,i.jsx)(s.code,{children:"prepare"})," as it works during both publishing and installing from GIT with more package managers."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsx)(s.p,{children:"Configure the appropriate entry points:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"main"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib/commonjs/index.js"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"module"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib/module/index.js"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"types"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib/typescript/src/index.d.ts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"source"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"src/index.ts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"files"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": ["})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"src"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"]"})})]})}),"\n",(0,i.jsx)(s.p,{children:"Here is what each of these fields mean:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"main"}),": The entry point for the commonjs build. This is used by Node - such as tests, SSR etc."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"module"}),": The entry point for the ES module build. This is used by bundlers such as webpack."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"types"}),": The entry point for the TypeScript definitions. This is used by TypeScript to type check the code using your library."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"source"}),": The path to the source code. It is used by ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," to detect the correct output files and provide better error messages."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"files"}),": The files to include in the package when publishing with ",(0,i.jsx)(s.code,{children:"npm"}),"."]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"Make sure to change specify correct files according to the targets you have enabled."}),"\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.strong,{children:"NOTE"}),": If you're building TypeScript definition files, also make sure that the ",(0,i.jsx)(s.code,{children:"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. ",(0,i.jsx)(s.code,{children:"lib/typescript/index.d.ts"})," if you have only the ",(0,i.jsx)(s.code,{children:"src"})," directory and ",(0,i.jsx)(s.code,{children:"rootDir"})," is not set)."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Add the output directory to ",(0,i.jsx)(s.code,{children:".gitignore"})," and ",(0,i.jsx)(s.code,{children:".eslintignore"})]}),"\n",(0,i.jsx)(s.pre,{"data-language":"gitignore","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"gitignore","data-theme":"default",children:[(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"# generated files by bob"})}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"lib/"})})]})}),"\n",(0,i.jsx)(s.p,{children:"This makes sure that you don't accidentally commit the generated files to git or get lint errors for them."}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Add the output directory to ",(0,i.jsx)(s.code,{children:"jest.modulePathIgnorePatterns"})," if you use ",(0,i.jsx)(s.a,{href:"https://jestjs.io",children:"Jest"})]}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"modulePathIgnorePatterns"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": ["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"/lib/"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"]"})]})})}),"\n",(0,i.jsx)(s.p,{children:"This makes sure that Jest doesn't try to run the tests in the generated files."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"And we're done \uD83C\uDF89"}),"\n",(0,i.jsx)(s.h2,{id:"options",children:"Options"}),"\n",(0,i.jsxs)(s.p,{children:["The options can be specified in the ",(0,i.jsx)(s.code,{children:"package.json"})," file under the ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," property, or in a ",(0,i.jsx)(s.code,{children:"bob.config.js"})," file in your project directory."]}),"\n",(0,i.jsx)(s.h3,{id:"source",children:(0,i.jsx)(s.code,{children:"source"})}),"\n",(0,i.jsxs)(s.p,{children:["The name of the folder with the source code which should be compiled. The folder should include an ",(0,i.jsx)(s.code,{children:"index"})," file."]}),"\n",(0,i.jsx)(s.h3,{id:"output",children:(0,i.jsx)(s.code,{children:"output"})}),"\n",(0,i.jsx)(s.p,{children:"The name of the folder where the compiled files should be output to. It will contain separate folder for each target."}),"\n",(0,i.jsx)(s.h3,{id:"exclude",children:(0,i.jsx)(s.code,{children:"exclude"})}),"\n",(0,i.jsxs)(s.p,{children:["Glob pattern to be used while filtering the unnecessary files. Defaults to ",(0,i.jsx)(s.code,{children:"'**/{__tests__,__fixtures__,__mocks__}/**'"})," if not specified."]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"{"})}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"exclude"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"ignore_me/**"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["This option only works with ",(0,i.jsx)(s.code,{children:"commonjs"})," and ",(0,i.jsx)(s.code,{children:"module"})," targets. To exclude files while building ",(0,i.jsx)(s.code,{children:"typescript"}),", please see ",(0,i.jsx)(s.a,{href:"https://www.typescriptlang.org/tsconfig#exclude",children:"the tsconfig exclude field"}),"."]}),"\n"]}),"\n",(0,i.jsx)(s.h3,{id:"targets",children:(0,i.jsx)(s.code,{children:"targets"})}),"\n",(0,i.jsx)(s.p,{children:"Various targets to build for. The available targets are:"}),"\n",(0,i.jsx)(s.h4,{id:"commonjs",children:(0,i.jsx)(s.code,{children:"commonjs"})}),"\n",(0,i.jsx)(s.p,{children:"Enable compiling source files with Babel and use commonjs module system."}),"\n",(0,i.jsxs)(s.p,{children:["This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the ",(0,i.jsx)(s.code,{children:"main"})," field of ",(0,i.jsx)(s.code,{children:"package.json"}),"."]}),"\n",(0,i.jsxs)(s.p,{children:["By default, the code is compiled to support last 2 versions of modern browsers. It also strips TypeScript and Flow annotations, and compiles JSX. You can customize the environments to compile for by using a ",(0,i.jsx)(s.a,{href:"https://github.com/browserslist/browserslist#config-file",children:"browserslist config"}),"."]}),"\n",(0,i.jsx)(s.p,{children:"In addition, the following options are supported:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"configFile"})," (",(0,i.jsx)(s.code,{children:"boolean"})," | ",(0,i.jsx)(s.code,{children:"string"}),"): To customize the babel config used, you can pass the ",(0,i.jsx)(s.a,{href:"https://babeljs.io/docs/en/options#configfile",children:(0,i.jsx)(s.code,{children:"configFile"})})," option as ",(0,i.jsx)(s.code,{children:"true"})," if you have a ",(0,i.jsx)(s.code,{children:"babel.config.js"})," or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the ",(0,i.jsx)(s.a,{href:"https://github.com/callstack/react-native-builder-bob/blob/main/packages/react-native-builder-bob/babel-preset.js",children:(0,i.jsx)(s.code,{children:"react-native-builder-bob/babel-preset"})})," preset."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"babelrc"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): You can set the ",(0,i.jsx)(s.a,{href:"https://babeljs.io/docs/en/options#babelrc",children:(0,i.jsx)(s.code,{children:"babelrc"})})," option to ",(0,i.jsx)(s.code,{children:"true"})," to enable using ",(0,i.jsx)(s.code,{children:".babelrc"})," files."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"copyFlow"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): If your source code is written in ",(0,i.jsx)(s.a,{href:"http://www.typescriptlang.org/",children:"Flow"}),", You can specify the ",(0,i.jsx)(s.code,{children:"copyFlow"})," option to copy the source files as ",(0,i.jsx)(s.code,{children:".js.flow"})," to the output folder. If the ",(0,i.jsx)(s.code,{children:"main"})," entry in ",(0,i.jsx)(s.code,{children:"package.json"})," points to the ",(0,i.jsx)(s.code,{children:"index"})," file in the output folder, the flow type checker will pick these files up to use for type definitions."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"sourceMaps"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the ",(0,i.jsx)(s.code,{children:"sourceMaps"})," option to ",(0,i.jsx)(s.code,{children:"false"}),"."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"commonjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"configFile"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"copyFlow"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"})]})})}),"\n",(0,i.jsx)(s.h4,{id:"module",children:(0,i.jsx)(s.code,{children:"module"})}),"\n",(0,i.jsxs)(s.p,{children:["Enable compiling source files with Babel and use ES module system. This is essentially same as the ",(0,i.jsx)(s.code,{children:"commonjs"})," target and accepts the same options, but leaves the ",(0,i.jsx)(s.code,{children:"import"}),"/",(0,i.jsx)(s.code,{children:"export"})," statements in your code."]}),"\n",(0,i.jsxs)(s.p,{children:["This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the ",(0,i.jsx)(s.code,{children:"module"})," field of ",(0,i.jsx)(s.code,{children:"package.json"}),"."]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"module"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"configFile"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"})]})})}),"\n",(0,i.jsx)(s.h4,{id:"typescript",children:(0,i.jsx)(s.code,{children:"typescript"})}),"\n",(0,i.jsxs)(s.p,{children:["Enable generating type definitions with ",(0,i.jsx)(s.code,{children:"tsc"})," if your source code is written in ",(0,i.jsx)(s.a,{href:"http://www.typescriptlang.org/",children:"TypeScript"}),"."]}),"\n",(0,i.jsx)(s.p,{children:"The following options are supported:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"project"})," (",(0,i.jsx)(s.code,{children:"string"}),"): By default, the ",(0,i.jsx)(s.code,{children:"tsconfig.json"})," file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the ",(0,i.jsx)(s.code,{children:"project"})," option. This can be useful if you need to use different configs for development and production."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"tsc"})," (",(0,i.jsx)(s.code,{children:"string"}),"): The path to the ",(0,i.jsx)(s.code,{children:"tsc"})," binary is automatically detected and defaults to the one installed in your project. You can use the ",(0,i.jsx)(s.code,{children:"tsc"})," option to specify a different path."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"typescript"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"project"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"tsconfig.build.json"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"})]})})}),"\n",(0,i.jsx)(s.h2,{id:"commands",children:"Commands"}),"\n",(0,i.jsxs)(s.p,{children:["The ",(0,i.jsx)(s.code,{children:"bob"})," CLI exposes the following commands:"]}),"\n",(0,i.jsx)(s.h3,{id:"init",children:(0,i.jsx)(s.code,{children:"init"})}),"\n",(0,i.jsxs)(s.p,{children:["This configures an existing project to use ",(0,i.jsx)(s.code,{children:"bob"})," by adding the required configuration and dependencies. This is usually run with ",(0,i.jsx)(s.code,{children:"npx"}),":"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"sh","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"sh","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"npx"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"react-native-builder-bob@latest"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"init"})]})})}),"\n",(0,i.jsx)(s.h3,{id:"build",children:(0,i.jsx)(s.code,{children:"build"})}),"\n",(0,i.jsxs)(s.p,{children:["This builds the project according to the configuration. This is usually run as part of the package's publishing flow, i.e. in the ",(0,i.jsx)(s.code,{children:"prepare"})," or ",(0,i.jsx)(s.code,{children:"prepack"})," scripts."]}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"scripts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"prepare"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"bob build"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"Demo",src:c})})]})}let h={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}=Object.assign({},(0,t.a)(),e.components);return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(d,{...e})}):d(e)},pageOpts:{filePath:"pages/build.md",route:"/build",pageMap:[{kind:"Meta",data:{index:"Introduction",create:"Scaffold a library",build:"Build a library",faq:"FAQ"}},{kind:"MdxPage",name:"build",route:"/build"},{kind:"MdxPage",name:"create",route:"/create"},{kind:"MdxPage",name:"faq",route:"/faq"},{kind:"MdxPage",name:"index",route:"/"}],flexsearch:{codeblocks:!0},title:"Build a React Native library",headings:a},pageNextRoute:"/build",nextraLayout:l.ZP,themeConfig:o.Z};var p=(0,r.j)(h)},6282:function(e,s,n){"use strict";var i=n(4246);n(7378),s.Z={primaryHue:30,logo:(0,i.jsx)("span",{style:{fontSize:"32px"},children:"\uD83D\uDC77♂️"}),project:{link:"https://github.com/callstack/react-native-builder-bob"},docsRepositoryBase:"https://github.com/callstack/react-native-builder-bob/tree/main/docs",head:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1.0"}),(0,i.jsx)("meta",{property:"og:description",content:"Bob - Create and build React Native libraries with ease"})]}),faviconGlyph:"\uD83D\uDC77♂️",footer:{text:(0,i.jsxs)("span",{children:["Copyright \xa9 ",new Date().getFullYear()," ",(0,i.jsx)("a",{href:"https://www.callstack.com/",target:"_blank",rel:"noreferrer",children:"Callstack Open Source"}),"."]})},useNextSeoProps:()=>({titleTemplate:"%s – Bob"})}}},function(e){e.O(0,[774,571,888,179],function(){return e(e.s=7272)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/_next/static/chunks/pages/build-7eaa9c98f3f1ca1c.js b/_next/static/chunks/pages/build-7eaa9c98f3f1ca1c.js
new file mode 100644
index 000000000..e96120a82
--- /dev/null
+++ b/_next/static/chunks/pages/build-7eaa9c98f3f1ca1c.js
@@ -0,0 +1 @@
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[881],{7272:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/build",function(){return n(6338)}])},6338:function(e,s,n){"use strict";n.r(s),n.d(s,{__toc:function(){return a},default:function(){return p}});var i=n(4246),r=n(9304),o=n(2917),l=n(6282);n(6288);var t=n(1441),c={src:"/react-native-builder-bob//_next/static/media/react-native-builder-bob.f743a9da.svg",height:581,width:840,blurWidth:0,blurHeight:0};let a=[{depth:2,value:"Automatic configuration",id:"automatic-configuration"},{depth:2,value:"Manual configuration",id:"manual-configuration"},{depth:2,value:"Options",id:"options"},{depth:3,value:"source",id:"source"},{depth:3,value:"output",id:"output"},{depth:3,value:"exclude",id:"exclude"},{depth:3,value:"targets",id:"targets"},{depth:4,value:"commonjs",id:"commonjs"},{depth:4,value:"module",id:"module"},{depth:4,value:"typescript",id:"typescript"},{depth:2,value:"Commands",id:"commands"},{depth:3,value:"init",id:"init"},{depth:3,value:"build",id:"build"}];function d(e){let s=Object.assign({h1:"h1",p:"p",code:"code",a:"a",ul:"ul",li:"li",strong:"strong",h2:"h2",pre:"pre",span:"span",ol:"ol",blockquote:"blockquote",h3:"h3",h4:"h4",img:"img"},(0,t.a)(),e.components);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.h1,{children:"Build a React Native library"}),"\n",(0,i.jsxs)(s.p,{children:["When code is in non-standard syntaxes such as JSX, TypeScript etc, it needs to be compiled before it can run. Configuring this manually can be error-prone and annoying. ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," aims to simplify this process by wrapping ",(0,i.jsx)(s.code,{children:"babel"})," and ",(0,i.jsx)(s.code,{children:"tsc"})," and taking care of the configuration. See ",(0,i.jsx)(s.a,{href:"./faq#why-should-i-compile-my-project-with-react-native-builder-bob",children:"this section"})," for a longer explanation."]}),"\n",(0,i.jsx)(s.p,{children:"Supported targets are:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:"Generic CommonJS build"}),"\n",(0,i.jsxs)(s.li,{children:["ES modules build for bundlers such as ",(0,i.jsx)(s.a,{href:"https://webpack.js.org",children:"webpack"})]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.a,{href:"https://www.typescriptlang.org/",children:"TypeScript"})," definitions"]}),"\n",(0,i.jsx)(s.li,{children:"Flow definitions (copies .js files to .flow files)"}),"\n"]}),"\n",(0,i.jsxs)(s.p,{children:["If you created a project with ",(0,i.jsx)(s.a,{href:"./create",children:(0,i.jsx)(s.code,{children:"create-react-native-library"})}),", ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," is ",(0,i.jsx)(s.strong,{children:"already pre-configured to build your project"}),". You don't need to configure it again."]}),"\n",(0,i.jsxs)(s.p,{children:["The following configuration steps are for projects not created with ",(0,i.jsx)(s.code,{children:"create-react-native-library"}),"."]}),"\n",(0,i.jsx)(s.h2,{id:"automatic-configuration",children:"Automatic configuration"}),"\n",(0,i.jsxs)(s.p,{children:["To automatically configure your project to use ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"}),", open a Terminal and run:"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"js","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"js","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"npx react"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"-"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"native"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"-"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"builder"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:"-"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"bob@latest init"})]})})}),"\n",(0,i.jsx)(s.p,{children:"This will ask you a few questions and add the required configuration and scripts for building the code. The code will be compiled automatically when the package is published."}),"\n",(0,i.jsxs)(s.p,{children:["You can find details on what exactly it adds in the ",(0,i.jsx)(s.a,{href:"#manual-configuration",children:"Manual configuration"})," section."]}),"\n",(0,i.jsx)(s.h2,{id:"manual-configuration",children:"Manual configuration"}),"\n",(0,i.jsx)(s.p,{children:"To configure your project manually, follow these steps:"}),"\n",(0,i.jsxs)(s.ol,{children:["\n",(0,i.jsxs)(s.li,{children:["First, install ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," in your project. Open a Terminal in your project, and run:"]}),"\n"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"sh","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"sh","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"yarn"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"add"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"--dev"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"react-native-builder-bob"})]})})}),"\n",(0,i.jsxs)(s.ol,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["In your ",(0,i.jsx)(s.code,{children:"package.json"}),", specify the targets to build for:"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"react-native-builder-bob"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"source"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"src"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"output"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"targets"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" ["})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" ["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"commonjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"esm"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" ["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"module"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"esm"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"typescript"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" ]"})}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsxs)(s.p,{children:["See the ",(0,i.jsx)(s.a,{href:"#options",children:"Options"})," section for more details."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Add ",(0,i.jsx)(s.code,{children:"bob"})," to your ",(0,i.jsx)(s.code,{children:"prepare"})," or ",(0,i.jsx)(s.code,{children:"prepack"})," step:"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"js","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"js","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"scripts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"prepare"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"bob build"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsxs)(s.p,{children:["Note that there is a difference between ",(0,i.jsx)(s.code,{children:"prepare"})," and ",(0,i.jsx)(s.code,{children:"prepack"})," scripts:"]}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"prepare"})," is run when:\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["The package is published with Yarn 1 (",(0,i.jsx)(s.code,{children:"yarn publish"}),"), npm (",(0,i.jsx)(s.code,{children:"npm publish"}),") or pnpm (",(0,i.jsx)(s.code,{children:"pnpm publish"}),")"]}),"\n",(0,i.jsxs)(s.li,{children:["The package is installed from a GIT URL with Yarn 1 (",(0,i.jsx)(s.code,{children:"yarn add "}),"), npm (",(0,i.jsx)(s.code,{children:"npm install "}),") or pnpm (",(0,i.jsx)(s.code,{children:"pnpm add "}),")"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"prepack"})," is run when:\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["The package is published with any package manager (",(0,i.jsx)(s.code,{children:"yarn publish"}),", ",(0,i.jsx)(s.code,{children:"npm publish"}),", ",(0,i.jsx)(s.code,{children:"pnpm publish"}),")"]}),"\n",(0,i.jsxs)(s.li,{children:["The package is installed from a GIT URL with Yarn 4 (",(0,i.jsx)(s.code,{children:"yarn add package-name@"}),")"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(s.p,{children:["If you are not sure which one to use, we recommend going with ",(0,i.jsx)(s.code,{children:"prepare"})," as it works during both publishing and installing from GIT with more package managers."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsx)(s.p,{children:"Configure the appropriate entry points:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"source"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./src/index.tsx"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"main"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./lib/commonjs/index.cjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"module"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./lib/module/index.mjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"types"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./lib/typescript/src/index.d.ts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"exports"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"."'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"types"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./typescript/src/index.d.ts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"require"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./commonjs/index.cjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"import"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"./module/index.mjs"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }"})}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"},"})}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"files"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": ["})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"lib"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"src"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"]"})})]})}),"\n",(0,i.jsx)(s.p,{children:"Here is what each of these fields mean:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"source"}),": The path to the source code. It is used by ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," to detect the correct output files and provide better error messages."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"main"}),": The entry point for the commonjs build. This is used by Node - such as tests, SSR etc."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"module"}),": The entry point for the ES module build. This is used by bundlers such as webpack."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"types"}),": The entry point for the TypeScript definitions. This is used by TypeScript to type check the code using your library."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"files"}),": The files to include in the package when publishing with ",(0,i.jsx)(s.code,{children:"npm"}),"."]}),"\n",(0,i.jsxs)(s.li,{children:[(0,i.jsx)(s.code,{children:"exports"}),": The entry points for tools that support the ",(0,i.jsx)(s.code,{children:"exports"})," field in ",(0,i.jsx)(s.code,{children:"package.json"})," - such as Node.js 12+ & modern browsers."]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"Make sure to change specify correct files according to the targets you have enabled."}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["The ",(0,i.jsx)(s.code,{children:"exports"})," field also requires the ",(0,i.jsx)(s.code,{children:"esm"})," option to be enabled for the ",(0,i.jsx)(s.a,{href:"#commonjs",children:(0,i.jsx)(s.code,{children:"commonjs"})})," and ",(0,i.jsx)(s.a,{href:"#module",children:(0,i.jsx)(s.code,{children:"module"})})," targets. In addition, the file extensions of the generated files will be ",(0,i.jsx)(s.code,{children:".js"})," instead of ",(0,i.jsx)(s.code,{children:".cjs"})," and ",(0,i.jsx)(s.code,{children:".mjs"})," if the ",(0,i.jsx)(s.code,{children:"esm"})," option is not enabled."]}),"\n"]}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["If you're building TypeScript definition files, also make sure that the ",(0,i.jsx)(s.code,{children:"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. ",(0,i.jsx)(s.code,{children:"lib/typescript/index.d.ts"})," if you have only the ",(0,i.jsx)(s.code,{children:"src"})," directory and ",(0,i.jsx)(s.code,{children:"rootDir"})," is not set)."]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Add the output directory to ",(0,i.jsx)(s.code,{children:".gitignore"})," and ",(0,i.jsx)(s.code,{children:".eslintignore"})]}),"\n",(0,i.jsx)(s.pre,{"data-language":"gitignore","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"gitignore","data-theme":"default",children:[(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"# generated files by bob"})}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"lib/"})})]})}),"\n",(0,i.jsx)(s.p,{children:"This makes sure that you don't accidentally commit the generated files to git or get lint errors for them."}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:["Add the output directory to ",(0,i.jsx)(s.code,{children:"jest.modulePathIgnorePatterns"})," if you use ",(0,i.jsx)(s.a,{href:"https://jestjs.io",children:"Jest"})]}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"modulePathIgnorePatterns"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": ["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"/lib/"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"]"})]})})}),"\n",(0,i.jsx)(s.p,{children:"This makes sure that Jest doesn't try to run the tests in the generated files."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"And we're done \uD83C\uDF89"}),"\n",(0,i.jsx)(s.h2,{id:"options",children:"Options"}),"\n",(0,i.jsxs)(s.p,{children:["The options can be specified in the ",(0,i.jsx)(s.code,{children:"package.json"})," file under the ",(0,i.jsx)(s.code,{children:"react-native-builder-bob"})," property, or in a ",(0,i.jsx)(s.code,{children:"bob.config.js"})," file in your project directory."]}),"\n",(0,i.jsx)(s.h3,{id:"source",children:(0,i.jsx)(s.code,{children:"source"})}),"\n",(0,i.jsxs)(s.p,{children:["The name of the folder with the source code which should be compiled. The folder should include an ",(0,i.jsx)(s.code,{children:"index"})," file."]}),"\n",(0,i.jsx)(s.h3,{id:"output",children:(0,i.jsx)(s.code,{children:"output"})}),"\n",(0,i.jsx)(s.p,{children:"The name of the folder where the compiled files should be output to. It will contain separate folder for each target."}),"\n",(0,i.jsx)(s.h3,{id:"exclude",children:(0,i.jsx)(s.code,{children:"exclude"})}),"\n",(0,i.jsxs)(s.p,{children:["Glob pattern to be used while filtering the unnecessary files. Defaults to ",(0,i.jsx)(s.code,{children:"'**/{__tests__,__fixtures__,__mocks__}/**'"})," if not specified."]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"{"})}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"exclude"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"ignore_me/**"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["This option only works with ",(0,i.jsx)(s.code,{children:"commonjs"})," and ",(0,i.jsx)(s.code,{children:"module"})," targets. To exclude files while building ",(0,i.jsx)(s.code,{children:"typescript"}),", please see ",(0,i.jsx)(s.a,{href:"https://www.typescriptlang.org/tsconfig#exclude",children:"the tsconfig exclude field"}),"."]}),"\n"]}),"\n",(0,i.jsx)(s.h3,{id:"targets",children:(0,i.jsx)(s.code,{children:"targets"})}),"\n",(0,i.jsx)(s.p,{children:"Various targets to build for. The available targets are:"}),"\n",(0,i.jsx)(s.h4,{id:"commonjs",children:(0,i.jsx)(s.code,{children:"commonjs"})}),"\n",(0,i.jsx)(s.p,{children:"Enable compiling source files with Babel and use commonjs module system."}),"\n",(0,i.jsxs)(s.p,{children:["This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the ",(0,i.jsx)(s.code,{children:"main"})," field and ",(0,i.jsx)(s.code,{children:"exports['.'].require"})," (when ",(0,i.jsx)(s.code,{children:"esm: true"}),") field of ",(0,i.jsx)(s.code,{children:"package.json"}),"."]}),"\n",(0,i.jsxs)(s.p,{children:["By default, the code is compiled to support the last 2 versions of modern browsers. It also strips TypeScript and Flow annotations as well as compiles JSX. You can customize the environments to compile for by using a ",(0,i.jsx)(s.a,{href:"https://github.com/browserslist/browserslist#config-file",children:"browserslist config"}),"."]}),"\n",(0,i.jsx)(s.p,{children:"In addition, the following options are supported:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"esm"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): Enabling this option will output ES modules compatible code for Node.js 12+, modern browsers and other tools that support ",(0,i.jsx)(s.code,{children:"package.json"}),"'s ",(0,i.jsx)(s.code,{children:"exports"})," field. This mainly adds file extensions to the imports and exports. Note that file extensions are not added when importing a file that may have platform-specific extensions (e.g. ",(0,i.jsx)(s.code,{children:".android.ts"}),"). In addition, the generated files will have ",(0,i.jsx)(s.code,{children:".cjs"})," (commonjs) and ",(0,i.jsx)(s.code,{children:".mjs"})," (modules) extensions instead of ",(0,i.jsx)(s.code,{children:".js"})," - this is necessary to disambiguate between the two formats."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"configFile"})," (",(0,i.jsx)(s.code,{children:"boolean"})," | ",(0,i.jsx)(s.code,{children:"string"}),"): To customize the babel config used, you can pass the ",(0,i.jsx)(s.a,{href:"https://babeljs.io/docs/en/options#configfile",children:(0,i.jsx)(s.code,{children:"configFile"})})," option as ",(0,i.jsx)(s.code,{children:"true"})," if you have a ",(0,i.jsx)(s.code,{children:"babel.config.js"})," or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the ",(0,i.jsx)(s.a,{href:"https://github.com/callstack/react-native-builder-bob/blob/main/packages/react-native-builder-bob/babel-preset.js",children:(0,i.jsx)(s.code,{children:"react-native-builder-bob/babel-preset"})})," preset."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"babelrc"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): You can set the ",(0,i.jsx)(s.a,{href:"https://babeljs.io/docs/en/options#babelrc",children:(0,i.jsx)(s.code,{children:"babelrc"})})," option to ",(0,i.jsx)(s.code,{children:"true"})," to enable using ",(0,i.jsx)(s.code,{children:".babelrc"})," files."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"copyFlow"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): If your source code is written in ",(0,i.jsx)(s.a,{href:"http://www.typescriptlang.org/",children:"Flow"}),", You can specify the ",(0,i.jsx)(s.code,{children:"copyFlow"})," option to copy the source files as ",(0,i.jsx)(s.code,{children:".js.flow"})," to the output folder. If the ",(0,i.jsx)(s.code,{children:"main"})," entry in ",(0,i.jsx)(s.code,{children:"package.json"})," points to the ",(0,i.jsx)(s.code,{children:"index"})," file in the output folder, the flow type checker will pick these files up to use for type definitions."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"sourceMaps"})," (",(0,i.jsx)(s.code,{children:"boolean"}),"): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the ",(0,i.jsx)(s.code,{children:"sourceMaps"})," option to ",(0,i.jsx)(s.code,{children:"false"}),"."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"commonjs"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"esm"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"copyFlow"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"})]})})}),"\n",(0,i.jsx)(s.h4,{id:"module",children:(0,i.jsx)(s.code,{children:"module"})}),"\n",(0,i.jsxs)(s.p,{children:["Enable compiling source files with Babel and use ES module system. This is essentially same as the ",(0,i.jsx)(s.code,{children:"commonjs"})," target and accepts the same options, but leaves the ",(0,i.jsx)(s.code,{children:"import"}),"/",(0,i.jsx)(s.code,{children:"export"})," statements in your code."]}),"\n",(0,i.jsxs)(s.p,{children:["This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the ",(0,i.jsx)(s.code,{children:"module"})," field and ",(0,i.jsx)(s.code,{children:"exports['.'].import"})," (when ",(0,i.jsx)(s.code,{children:"esm: true"}),") field of ",(0,i.jsx)(s.code,{children:"package.json"}),"."]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"module"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"esm"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"sourceMaps"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-constant)"},children:"false"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"})]})})}),"\n",(0,i.jsx)(s.h4,{id:"typescript",children:(0,i.jsx)(s.code,{children:"typescript"})}),"\n",(0,i.jsxs)(s.p,{children:["Enable generating type definitions with ",(0,i.jsx)(s.code,{children:"tsc"})," if your source code is written in ",(0,i.jsx)(s.a,{href:"http://www.typescriptlang.org/",children:"TypeScript"}),"."]}),"\n",(0,i.jsx)(s.p,{children:"The following options are supported:"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"project"})," (",(0,i.jsx)(s.code,{children:"string"}),"): By default, the ",(0,i.jsx)(s.code,{children:"tsconfig.json"})," file in the root of your project is used to generate the type definitions. You can specify a path to a different config by using the ",(0,i.jsx)(s.code,{children:"project"})," option. This can be useful if you need to use different configs for development and production."]}),"\n"]}),"\n",(0,i.jsxs)(s.li,{children:["\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"tsc"})," (",(0,i.jsx)(s.code,{children:"string"}),"): The path to the ",(0,i.jsx)(s.code,{children:"tsc"})," binary is automatically detected and defaults to the one installed in your project. You can use the ",(0,i.jsx)(s.code,{children:"tsc"})," option to specify a different path."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:"Example:"}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"["}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"typescript"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" { "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"project"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"tsconfig.build.json"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" }]"})]})})}),"\n",(0,i.jsxs)(s.p,{children:["The output file should be referenced in the ",(0,i.jsx)(s.code,{children:"types"})," field or ",(0,i.jsx)(s.code,{children:"exports['.'].types"})," field of ",(0,i.jsx)(s.code,{children:"package.json"}),"."]}),"\n",(0,i.jsx)(s.h2,{id:"commands",children:"Commands"}),"\n",(0,i.jsxs)(s.p,{children:["The ",(0,i.jsx)(s.code,{children:"bob"})," CLI exposes the following commands:"]}),"\n",(0,i.jsx)(s.h3,{id:"init",children:(0,i.jsx)(s.code,{children:"init"})}),"\n",(0,i.jsxs)(s.p,{children:["This configures an existing project to use ",(0,i.jsx)(s.code,{children:"bob"})," by adding the required configuration and dependencies. This is usually run with ",(0,i.jsx)(s.code,{children:"npx"}),":"]}),"\n",(0,i.jsx)(s.pre,{"data-language":"sh","data-theme":"default",children:(0,i.jsx)(s.code,{"data-language":"sh","data-theme":"default",children:(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-function)"},children:"npx"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"react-native-builder-bob@latest"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string)"},children:"init"})]})})}),"\n",(0,i.jsx)(s.h3,{id:"build",children:(0,i.jsx)(s.code,{children:"build"})}),"\n",(0,i.jsxs)(s.p,{children:["This builds the project according to the configuration. This is usually run as part of the package's publishing flow, i.e. in the ",(0,i.jsx)(s.code,{children:"prepare"})," or ",(0,i.jsx)(s.code,{children:"prepack"})," scripts."]}),"\n",(0,i.jsx)(s.pre,{"data-language":"json","data-theme":"default",children:(0,i.jsxs)(s.code,{"data-language":"json","data-theme":"default",children:[(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"scripts"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:": {"})]}),"\n",(0,i.jsxs)(s.span,{className:"line",children:[(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-keyword)"},children:'"prepare"'}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,i.jsx)(s.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"bob build"'})]}),"\n",(0,i.jsx)(s.span,{className:"line",children:(0,i.jsx)(s.span,{style:{color:"var(--shiki-color-text)"},children:"}"})})]})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"Demo",src:c})})]})}let h={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}=Object.assign({},(0,t.a)(),e.components);return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(d,{...e})}):d(e)},pageOpts:{filePath:"pages/build.md",route:"/build",pageMap:[{kind:"Meta",data:{index:"Introduction",create:"Scaffold a library",build:"Build a library",faq:"FAQ"}},{kind:"MdxPage",name:"build",route:"/build"},{kind:"MdxPage",name:"create",route:"/create"},{kind:"MdxPage",name:"faq",route:"/faq"},{kind:"MdxPage",name:"index",route:"/"}],flexsearch:{codeblocks:!0},title:"Build a React Native library",headings:a},pageNextRoute:"/build",nextraLayout:o.ZP,themeConfig:l.Z};var p=(0,r.j)(h)},6282:function(e,s,n){"use strict";var i=n(4246);n(7378),s.Z={primaryHue:30,logo:(0,i.jsx)("span",{style:{fontSize:"32px"},children:"\uD83D\uDC77♂️"}),project:{link:"https://github.com/callstack/react-native-builder-bob"},docsRepositoryBase:"https://github.com/callstack/react-native-builder-bob/tree/main/docs",head:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1.0"}),(0,i.jsx)("meta",{property:"og:description",content:"Bob - Create and build React Native libraries with ease"})]}),faviconGlyph:"\uD83D\uDC77♂️",footer:{text:(0,i.jsxs)("span",{children:["Copyright \xa9 ",new Date().getFullYear()," ",(0,i.jsx)("a",{href:"https://www.callstack.com/",target:"_blank",rel:"noreferrer",children:"Callstack Open Source"}),"."]})},useNextSeoProps:()=>({titleTemplate:"%s – Bob"})}}},function(e){e.O(0,[774,571,888,179],function(){return e(e.s=7272)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/build.html b/build.html
index a9271bf34..c3eb1e6a4 100644
--- a/build.html
+++ b/build.html
@@ -11,7 +11,7 @@
--nextra-primary-hue: 30deg;
--nextra-primary-saturation: 100%;
}
-
Build a library
Build a React Native library
+
Build a library
Build a React Native library
When code is in non-standard syntaxes such as JSX, TypeScript etc, it needs to be compiled before it can run. Configuring this manually can be error-prone and annoying. react-native-builder-bob aims to simplify this process by wrapping babel and tsc and taking care of the configuration. See this section for a longer explanation.
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 the commonjs build. This is used by Node - such as tests, SSR etc.
module: The entry point for the ES module build. This is used by bundlers such as webpack.
types: The entry point for the TypeScript definitions. This is used by TypeScript to type check the code using your library.
-
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.
files: The files to include in the package when publishing with npm.
+
exports: The entry points for tools that support the exports field in package.json - such as Node.js 12+ & modern browsers.
Make sure to change specify correct files according to the targets you have enabled.
-
NOTE: 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).
+
+
The exports field also requires the esm option to be enabled for the commonjs and module targets. In addition, the file extensions of the generated files will be .js instead of .cjs and .mjs if the esm option is not enabled.
+
+
+
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).
+
Add the output directory to .gitignore and .eslintignore
@@ -122,11 +135,14 @@
Various targets to build for. The available targets are:
commonjs
Enable compiling source files with Babel and use commonjs module system.
-
This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the main field of package.json.
-
By default, the code is compiled to support last 2 versions of modern browsers. It also strips TypeScript and Flow annotations, and compiles JSX. You can customize the environments to compile for by using a browserslist config (opens in a new tab).
+
This is useful for running the code in Node (SSR, tests etc.). The output file should be referenced in the main field and exports['.'].require (when esm: true) field of package.json.
+
By default, the code is compiled to support the last 2 versions of modern browsers. It also strips TypeScript and Flow annotations as well as compiles JSX. You can customize the environments to compile for by using a browserslist config (opens in a new tab).
In addition, the following options are supported:
+
esm (boolean): Enabling this option will output ES modules compatible code for Node.js 12+, modern browsers and other tools that support package.json's exports field. This mainly adds file extensions to the imports and exports. Note that file extensions are not added when importing a file that may have platform-specific extensions (e.g. .android.ts). In addition, the generated files will have .cjs (commonjs) and .mjs (modules) extensions instead of .js - this is necessary to disambiguate between the two formats.
+
+
configFile (boolean | string): To customize the babel config used, you can pass the configFile (opens in a new tab) option as true if you have a babel.config.js or a path to a custom config file. This will override the default configuration. You can extend the default configuration by using the react-native-builder-bob/babel-preset (opens in a new tab) preset.
Enable compiling source files with Babel and use ES module system. This is essentially same as the commonjs target and accepts the same options, but leaves the import/export statements in your code.
-
This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the module field of package.json.
+
This is useful for bundlers which understand ES modules and can tree-shake. The output file should be referenced in the module field and exports['.'].import (when esm: true) field of package.json.