Replies: 1 comment 1 reply
-
This is mentioned in https://github.com/callstack/react-native-builder-bob#why-should-i-compile-my-project-with-react-native-builder-bob To summarize:
I don't think there are any significant downsides to ship precompiled code given that it can make user's experience smoother by avoiding additional configuration and enables tools like Expo to make builds faster by skipping the compilation step altogether. It's not something strictly necessary, but anything that improves DX is a good thing.
The default setup in Bob publishes the source code as well. Not shipping the source is a deliberate decision by the library author so I think even if the default setup didn't have that, they'd configure it anyway.
The default setup in Bob also ships declaration maps so this shouldn't make any difference. This is also not a problem unless someone is accessing private files that they aren't supposed to.
Ideally, codegen would generate the bindings before publishing, instead of on the user's machine. Generating code on the user's machine has many issues but that's a separate topic. |
Beta Was this translation helpful? Give feedback.
-
Looking around third parties react-native library, most of them build the TypeScript/Javascript in a
dist
orlib
folder, but I don't understand why. It might be because of create-react-native-library and react-native-builder-bob being very popular for library maintainer.If your library need to be compatible with web (React App or simply js), then it is expected for third party maintainers to provide optimized JS bundle.
But what is the point to ship transformed js for React-Native ONLY library ?
There are many caveats to that
.d.ts
will be separated from the lib code, even if the package is written in TypeScriptpackage.json
is used as entry point for Metro, and most of the time, it points to the source code so,lib
(bundled) files can be ignored and it becomes difficult to understand what is really in our final bundleI did not find much documentation on that topic, is there something I am missing ? What is your recommendation ?
The only pro I have for shipping a react-native library with CommonJS support is for Jest, because you might need special configuration (or use
ts-jest
) when importing typescript code. Since TypeScript is the new default configuration for new react-native app, using jest with typescript will be more common.Beta Was this translation helpful? Give feedback.
All reactions