universal-future / vxrn

A collection of Vite packages enabling developing and building applications for React Native on web and native platforms (iOS and Android).
https://vxrn.dev
Other
636 stars 12 forks source link

Use `vxrn` instead of `metro` to build JS bundle during native build process #66

Open zetavg opened 1 month ago

zetavg commented 1 month ago

May use a react-native.config.js to override the bundle command of React Native CLI, which is called during the native build process. But this is not ideal since it depends on the order in the user's package.json for our react-native.config.js is read and defines the bundle command before react-native.

Ref: https://gist.github.com/zetavg/eacd8f8e6ec46213570ab6d1431672be

szymonrybczak commented 1 month ago

Recently for React Native Community CLI project's we've allowed for overriding commands - so right now vxrn should be able to provide a command inside react-native.config.js and it should be called instead of the default one. See here.

Ref: https://gist.github.com/zetavg/eacd8f8e6ec46213570ab6d1431672be

Nice investigation!

zetavg commented 1 month ago

Thank you @szymonrybczak, for pointing this out, and for your PR which made this possible! 💙

Well, I’m originally thinking about not having the user place a react-native.config.js in their project by themselves but making the vxrn package include a react-native.config.js which overrides the bundle command of react-native automatically. But my understanding is that there isn’t a stable way to override command from another package, if multiple packages defines the same command, the order of they being listed inside the user’s package.json will determine whose will be used.

However, I currently think it’s not bad (or even better) for the user to prepare react-native.config.js by themselves in their project since this will introduce less magic and give the user an idea of how things will work.

We can probably prepare something that the user can do this in their react-native.config.js:

module.exports = {
  commands: [...require('vxrn/rn-commands')]
}