callstack / react-native-builder-bob

👷‍♂️ Simple set of CLIs to scaffold and build React Native libraries for different targets
https://callstack.github.io/react-native-builder-bob/
2.78k stars 184 forks source link

feat: use the bob preset for the library during dev #599

Closed satya164 closed 3 months ago

satya164 commented 3 months ago

Previously the React Native Babel preset was being used t compile the library code as well. However, this preset differs from the preset used to publish the library which can introduce inconsistencies.

For example, Metro compiles modules in loose mode which can hide strict mode errors during dev, but they'll surface when consumer uses the library. With this change, we make sure that the same preset is used for dev to avoid the inconsistency.

It also adds a babel plugin to explicitly add use strict - as Metro doesn't use strict mode for ESM code which is not spec-compliant, and the behavior differs from the CommonJS build where we add use strict during publish.