├── .npmignore ├── src ├── main.js ├── cli.js └── es6-init.js ├── .babelrc ├── .jshintrc ├── .gitignore ├── README.md └── package.json /.npmignore: -------------------------------------------------------------------------------- 1 | test-dist/ 2 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // Just a sanity check, if you want the value out of `electron`, you'll need to get it yourself. 2 | import 'electron'; 3 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2016-node5", "react"], 3 | "plugins": ["transform-async-to-generator", "array-includes"], 4 | "sourceMaps": "inline" 5 | } 6 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "es5": true, 3 | "esnext": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "expr": true, 7 | "latedef": true, 8 | "onevar": true, 9 | "noarg": true, 10 | "node": true, 11 | "trailing": true, 12 | "undef": true, 13 | "unused": true, 14 | "browser": true 15 | } 16 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import electron from 'electron'; 4 | import proc from 'child_process'; 5 | 6 | let params = [require.resolve('./es6-init')].concat(process.argv.slice(2)); 7 | 8 | let child = proc.spawn(electron, params, {stdio: 'inherit'}); 9 | child.on('close', (code) => process.exit(code)); 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 27 | node_modules 28 | 29 | lib 30 | test-dist 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # electron-prebuilt-compile 2 | 3 | [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/) 4 | 5 | electron-prebuilt-compile is a drop-in replacement for [electron-prebuilt](https://github.com/mafintosh/electron-prebuilt) that natively understands ES6 + React + LESS + some other languages, powered by [electron-compile](https://github.com/electronjs/electron-compile). 6 | 7 | ## Installation 8 | 9 | Download and install the latest build of electron for your OS and add it to your projects `package.json` as a `devDependency`: 10 | 11 | ``` 12 | npm install electron-prebuilt-compile --save-dev 13 | ``` 14 | 15 | Now you can just run `electron` to run electron: 16 | 17 | ``` 18 | electron 19 | ``` 20 | 21 | Electron will now understand ES6/ES7 and React components out-of-the-box, even in inline HTML: 22 | 23 | ```html 24 | 25 | 26 | 27 | 28 | 29 | 36 | 37 | 38 | ``` 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electron-prebuilt-compile", 3 | "version": "4.0.0-beta.10", 4 | "description": "electron-prebuilt that automatically understands Babel + React + LESS", 5 | "bin": { 6 | "electron": "lib/cli.js" 7 | }, 8 | "main": "lib/main.js", 9 | "scripts": { 10 | "compile": "babel -d lib/ src/", 11 | "prepublish": "npm run compile && cp ./node_modules/electron/electron.d.ts ." 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/paulcbetts/electron-prebuilt-compile" 16 | }, 17 | "keywords": [ 18 | "electron", 19 | "electron-compile", 20 | "sass", 21 | "less", 22 | "babel", 23 | "typescript", 24 | "coffeescript", 25 | "jade", 26 | "pug" 27 | ], 28 | "author": "Paul Betts ", 29 | "license": "MIT", 30 | "bugs": { 31 | "url": "https://github.com/paulcbetts/electron-prebuilt-compile/issues" 32 | }, 33 | "homepage": "https://github.com/paulcbetts/electron-prebuilt-compile", 34 | "dependencies": { 35 | "babel-plugin-array-includes": "^2.0.3", 36 | "babel-plugin-transform-async-to-generator": "^6.24.1", 37 | "babel-preset-es2016-node5": "^1.1.2", 38 | "babel-preset-react": "^6.24.1", 39 | "electron": "4.0.0-beta.10", 40 | "electron-compile": "*", 41 | "electron-compilers": "*", 42 | "yargs": "^6.6.0" 43 | }, 44 | "devDependencies": { 45 | "babel-cli": "^6.26.0" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/es6-init.js: -------------------------------------------------------------------------------- 1 | import { app } from 'electron'; 2 | import fs from 'fs'; 3 | import path from 'path'; 4 | import {init} from 'electron-compile'; 5 | 6 | function findPackageJson(initScript) { 7 | if (initScript === '/' || initScript.match(/^[A-Za-z]:$/)) { 8 | throw new Error("Can't find package.json"); 9 | } 10 | 11 | // Walk up the parent directories until we find package.json. Make sure that 12 | // we're not actually stumbling upon a parent npm package 13 | let ret = path.join(initScript, 'package.json') 14 | if (fs.statSyncNoException(ret) && !path.resolve(path.dirname(ret), '..').match(/[\\\/]node_modules$/i)) { 15 | return ret; 16 | } 17 | 18 | return findPackageJson(path.dirname(initScript)); 19 | } 20 | 21 | /** 22 | * Some debugger environment reconstruct process argument and inject args ignoring original order, 23 | * extract to find out right path for init script. 24 | * 25 | */ 26 | function getInitScriptPath() { 27 | const rawArgv = process.argv.filter((x) => x.indexOf(`--inspect=`) === -1 && x.indexOf(`--debug-brk`))[2]; 28 | return path.resolve(rawArgv); 29 | } 30 | 31 | function main() { 32 | const initScript = getInitScriptPath(); 33 | const packageJson = findPackageJson(initScript); 34 | const appPath = path.dirname(packageJson); 35 | const packageJsonData = JSON.parse(fs.readFileSync(packageJson, 'utf8')); 36 | 37 | app.setName(packageJsonData.productName || packageJsonData.name); 38 | app.setVersion(packageJsonData.version); 39 | app.setAppPath(appPath); 40 | 41 | // Reconstitute the original arguments 42 | const args = process.argv.slice(2); 43 | process.argv = [process.argv[0]].concat(args); 44 | 45 | //passthrough electron-compile command args if it's specified 46 | const parsedArgs = require('yargs').alias('c', 'cachedir').alias('s', 'sourcemapdir').argv; 47 | init(path.dirname(packageJson), initScript, null, parsedArgs.c || null, parsedArgs.s || null); 48 | } 49 | 50 | main() 51 | --------------------------------------------------------------------------------