Skip to content

Integration with Electron [renderer] #1636

Open

Description

@oniseijin

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 ;)]

Activity

  1. dchambers commented on Jan 19, 2016

    @dchambers
    Contributor

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

  2. Aivarass commented on Jan 21, 2016

    @Aivarass

    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.

    • Change your default-aspect/index.jsp to index.html. This also requires to remove any JSP lines from the file. This change is needed because Electron doesn't accept .jsx.
      After making this change generate the app again.
    • Since Electron has in built 'require' and 'define' we don't need to re-import them. Change: if (typeof module !== 'undefined'){ to if (typeof module !== 'undefined' && !global.window) { in bundle.js. I have opened a pr for this issue, so it stops re-import when using Electron in the future.
    • Finally, instead of pointing it to index.html, direct it to en.html
  3. oniseijin commented on Jan 24, 2016

    @oniseijin
    ContributorAuthor

    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;
        }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions