ionizer
Build electron compatible modules while working in any version of nodejs.
about
your system's version of nodejs
most likely does not match the version
that electron runs behind the scenes. this can be problematic. dependencies commonly execute build process
whilst installing them. perhaps you have seen node-gyp
build addons when installing something via npm?
For example, suppose
- you are developing on nodejs
0.12.7
- your electron application under the hood runs iojs
2.5.0
- you install
npm install --save node-sass
- you
require('node-sass')
into you electron application and run it... - YOUR APP CRASHES! :(
node-sass
was built for0.12.7 (module version 14)
, not for2.5.0 (module version 44)
- you run
ionizer -q
, which rebuilds your dependencies to work with your electron version. - reload your app. all is zen!
installation
This package is hosted on npm. See the ionizer package page.
npm install --save-dev ionizer
basic usage
i recommend installing electron-prebuilt
into your package for no-brainer rebuilds.
ionizer
first tests for electron-prebuilt
in your project and will rebuild with that if present (and if you don't explicitly specify an electron-path). npm install --save electron-prebuilt
.
whenever you install a new npm package into your electron project, rerun ionizer:
// package.json{ ... scripts: { "postinstall": "ionizer -q", // or ... "postinstall": "ionizer -q --limit=leveldown,some-pkg", }}
if you want to fine tune your rebuilds, try a rebuild script!
// inside your package.json... "scripts": ...
// .ionizer.js// advanced rebuilding (see simpler package.json example above)var fs = ;var path = ;var pkg = JSON;var _ = ;var electronVersion = _ || _;electronVersion = electronVersion0;var ionizer = ;ionizer; // test if rebuilding necessaryionizer; // electron path, see node_modules/electron-prebuilt/path.txt;
options
as demonstrated above, this package supports two modes:
- cli mode
- package mode
the API when consumed as a package does not have a full doc set yet--please see the example above. the options to ionizer
are the same to the cli as they are to ionizer.rebuild
in the library. those may be found here.
note
beta
ionizer works, but it's in beta. despite the API not being published formally now, it will change in 2.0.0. expect at least new method names. the CLI options are not anticipated to change @2.0.0.
fork'n'h4ck3d
ionizer was initially a fork off of electron-rebuild, so make sure to give those guys a shout out. this package was created to improve performance, development experience, and add some features. some dependencies will build with ionizer that won't build with electron-rebuild, although windows support is still lacking in ionizer (help requested for add windows support to squish-squash). notable differences between the packages are:
- more reliable rebuilds. ionizer runs the actual electron node process when rebuilding packages
- faster rebuilds. rather than rebuilding your entire node_modules folder, you can limit the builds to certain packages. and keep a record/cache of those packages that have already been rebuilt (so as to not redundantly rebuild them)
- pure es5. no es6 compilation required for backwards compatibility
- improves testing, building, & distribution speed
- faster tests. network tests are mocked out. once basic resources are cached.
todo
- windows support (
squish-squash
) - add doc blocks and gen API docs
- fix test ECONN issue for connecting to local file server
- support building against global electron (vs. electron-prebuilt or loose binary)
- general API tidy!
changelog
1.x - release
2.0.0 - drop --verbose
in favor of --log-level=[winston-log-levels]