BladeRunnerJS / brjs

BladeRunnerJS (BRJS) is an open source development toolkit and framework for modular construction of large single-page HTML5 apps. It consists of a set of conventions, supporting tools and micro-libraries that make it easy to develop, test, deploy and maintain complex JavaScript apps.
http://bladerunnerjs.org/
GNU Lesser General Public License v3.0
229 stars 36 forks source link

Integration with Electron [renderer] #1636

Open oniseijin opened 8 years ago

oniseijin commented 8 years ago

Electron is the evolution of Atom Shell, which puts HTML5 into Desktops.

Understood there is some "post build" activities, like wiring up ipcRenderer to communicate with the main process but was hoping a default export of a rendered page would work. However: on v 1.3 of BRJS:

loading from a browserWindow.loadURL(url)

in bundle.js:

realm.install(); // Uncaught ReferenceError: realm is not defined

in module.js:

if (!filename) {
    var err = new Error("Cannot find module '" + request + "'");
    err.code = 'MODULE_NOT_FOUND';
    throw err;
  }
  return filename;

the error being the module is not found.

It might be a challenge to support however:

  1. Electron is based on Chromium at some level, and Chrome works just fine
  2. Caplin and OpenFin seem to collaborate: https://www.caplin.com/business/news-post/caplin-and-openfin-partner-to-accelerate-html5-adoption
  3. OpenFin has moved to Electron https://openfin.co/2015/12/07/why-were-moving-to-electron/

Net: hoping Electron is supported out of the box on BladeRunner! [PhoneGap integration is obviously next ;)]

dchambers commented 8 years ago

@Aivarass, can you take a look at this please?

Aivarass commented 8 years ago

As I understand you created a package.json and main.js which points to index.html. The problem is that index.html is a switcher rather than index. You need to make a few quick changes in order to make it work.

oniseijin commented 8 years ago

Although the comments about index.jsp/jsx aren't appliable here, I did the change in bundle.js that you suggested. Loaded fine without issue, well spotted.

now it is:

var defaultRealm = new Realm(global.require || globalResolve);
    if (typeof module !== 'undefined' && !global.window) {
        // for node.js
        module.exports = defaultRealm;
    } else {
        // for the browser
        global.realm = defaultRealm;
    }