I have several native modules built and in my app's node_modules, i do not want these rebuilt.
electron-rebuild is also excluding my native module from being packged in the asar because it 'contains executable code'
how do i prevent that? the module needs to be packed in the asar
my dev package.json looks like
{
"build": {
"appId": "com.something.lobby",
"app-category-type": "com.something.lobby",
"npmRebuild": "false",
"win": {
"target": ["nsis"],
"icon": "resources/windows/icon.ico",
"arch": "ia32"
},
"nsis": {
"oneClick": true,
"installerHeaderIcon": "resources/windows/setup-icon.ico"
},
"mac": {
"icon": "resources/osx/icon.icns"
},
"dmg": {
"icon": "resources/osx/dmg-icon.icns",
"background": "resources/osx/dmg-background.png"
}
},
"directories": {
"buildResources": "resources",
"app": "build"
},
"devDependencies":{
...
}, "scripts":{
...
}
}
npmRebuild doesn't affect 'contains executable code'.
Please name such modules and explain why it should be packed into asar.
I'm using lzma-native, https://github.com/addaleax/lzma-native/
I'd like it packed in the asar so I can redistribute my application obviously. I'm testing electron-builder, I had been using a bunch of gulp scripts previously along with electron-packager to get everything bundled together for a release.
once lzma-native is built, there are some executables present in node_modules/lzma-native/deps/{bin_i686,bin_x64}, which is preventing it from being bundled into the asar with electron-builder.
I'd like it packed in the asar so I can redistribute my application obviously
once lzma-native is built, there are some executables present in node_modules/lzma-native/deps/{bin_i686,bin_x64}, which is preventing it from being bundled into the asar with electron-builder.
It must be unpacked if you want to execute it. But in your case you don't need to execute it, it will be used in-process, right? In this case please use files to exclude such files — to reduce your app size and to avoid auto-unpack.
Please note — asar.unpacked is a special directory for asar, in any case files will be redistributed. You don't need to worry about it.
2) npmRebuild respected and modules is not rebuilded on build, right?
No, those were two separate issues I was having. I have the npmRebuild flag set to false (as described above) and the console messages indicate that it is still rebuilding lzma-native.
Curiously, I am using another native module, keytar, and this is not being rebuilt on build.
Could you please attach build log? And project if possible? I doubt that npmRebuild is not respected.
Sure, I'm running:
build --ia32 --publish never
on electron-builder 5.12.1
with the following package.json:
{
"build": {
"appId": "com.something.lobby",
"app-category-type": "com.something.lobby",
"npmRebuild": "false",
"win": {
"target": ["nsis"],
"icon": "resources/windows/icon.ico",
"arch": "ia32"
},
"nsis": {
"oneClick": true,
"installerHeaderIcon": "resources/windows/setup-icon.ico"
},
"mac": {
"icon": "resources/osx/icon.icns"
},
"dmg": {
"icon": "resources/osx/dmg-icon.icns",
"background": "resources/osx/dmg-background.png"
}
},
"directories": {
"buildResources": "resources",
"app": "build"
},
"devDependencies": {
"chai": "^3.5.0",
"electron-builder": "^5.12.1",
"electron-mocha": "^2.0.0",
"electron-packager": "^7.0.2",
"electron-prebuilt": "^1.2.1",
"electron-rebuild": "^1.1.4",
"eslint": "^2.9.0",
"fs-jetpack": "^0.9.0",
"gulp": "^3.9.0",
"gulp-batch": "^1.0.5",
"gulp-less": "^3.0.3",
"gulp-plumber": "^1.1.0",
"gulp-util": "^3.0.6",
"gulp-watch": "^4.3.5",
"q": "^1.4.1",
"request": "^2.72.0",
"rimraf": "^2.5.1",
"rollup": "^0.26.3",
"shrinkwrap": "^0.4.0",
"tree-kill": "^0.1.1",
"xml2js": "^0.4.15",
"yargs": "^4.2.0"
},
"scripts": {
"postinstall": "install-app-deps --arch=ia32",
"release": "build --ia32 --publish never"
}
}
log:
> @ release c:\Users\test\electron-lobby
> build --ia32 --publish never
Rebuilding app dependencies for arch ia32 to c:\Users\test\electron-lobby\build
Packaging for platform win32 ia32 using electron 1.3.2 to dist\win-ia32-unpacked
node_modules\lzma-native is not packed into asar archive - contains executable code
Creating NSIS ia32 package
Building NSIS installer
I believe that changing "npmRebuild": "false" to "npmRebuild": false should make it work.
Confirmed it working for me.
Most helpful comment
I believe that changing
"npmRebuild": "false"to"npmRebuild": falseshould make it work.Confirmed it working for me.