jhugman / uniffi-bindgen-react-native

A uniffi bindings generator for calling Rust from react-native
Other
0 stars 0 forks source link

Use of package.exports requires experimental metro config #13

Closed zzorba closed 1 month ago

zzorba commented 2 months ago

In order for metro to understand sub-package exports, users of this library have to enable the following in metro.config.js in the resolver config.

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {
  resolver: {
    unstable_enablePackageExports: true,
  },
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

In order to avoid this until it becomes non-experimental, it would be good to move to a flat package structure with a single 'main'.

I think we probably also want the package to compile to .js/.d.ts files as in https://github.com/jhugman/uniffi-bindgen-react-native/pull/12, though the build is not correctly configured yet.

zzorba commented 2 months ago

Actually, it seems like it can work just fine with the typescript files, PR #12 is probably not needed with the experimental exports after all.

zzorba commented 2 months ago

Actually, I think if we want it to be able to include uniffi-bindgen-react-native transitively, instead of as a peer dependency (that would have to be added for a user of react-native-matrix-rust-sdk), we should compile uniffi to JS files to improve distribution.

When we do that, I think we need to change the 'type' of from module to commonjs