How do I tell electron-builder to package react-native-electron instead of react-native? I could not find anything about alias in the electron-builder docs and it's also surprising because it's not a native module so it doesn't contain any .node
files, and webpack (through electon-webpack) has taken care of all the packaging.
This is on Ubuntu.
The development build using the webpack server managed by electron-webpack (with the command electron-webpack dev
) works perfectly.
If I try yarn add react-native
it does build but when I start the resulting app it opens but does nothing.
I also tried to copy the react-native-electron folder and renaming it to react-native. Then it does build but if I start it, it does not even open but I do see it doing nothing in system monitor.
When I try electron-builder install-app-deps
without react-native it errors out with:
Error: Unresolved node modules: react-native
at /media/dj/dev/scan-app-desktop/node_modules/electron-builder-lib/src/util/packageDependencies.ts:108:17
From previous event:
at Collector.resolveUnresolvedHoisted (/media/dj/dev/scan-app-desktop/node_modules/electron-builder-lib/src/util/packageDependencies.ts:164:10)
at /media/dj/dev/scan-app-desktop/node_modules/electron-builder-lib/src/util/packageDependencies.ts:82:18
at Generator.next (<anonymous>)
at runCallback (timers.js:763:18)
at tryOnImmediate (timers.js:734:5)
at processImmediate (timers.js:716:5)
From previous event:
at Collector.collect (/media/dj/dev/scan-app-desktop/node_modules/electron-builder-lib/src/util/packageDependencies.ts:84:6)
at /media/dj/dev/scan-app-desktop/node_modules/electron-builder-lib/out/util/packageDependencies.js:123:47
at Generator.next (<anonymous>)
(...)
in my package.json I have the electronWebpack config:
"electronWebpack": {
"renderer": {
"webpackConfig": "webpack.renderer.additions.js"
}
},
and in webpack.renderer.additions.js:
const path = require('path')
const resolve = {
alias: {
'react-native': path.join(__dirname, 'node_modules/react-native-electron')
}
}
module.exports = {resolve}