Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Electron [renderer] #1636

Open
oniseijin opened this issue Jan 12, 2016 · 3 comments
Open

Integration with Electron [renderer] #1636

oniseijin opened this issue Jan 12, 2016 · 3 comments
Assignees

Comments

@oniseijin
Copy link
Contributor

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
Copy link
Contributor

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

@Aivarass
Copy link

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

@oniseijin
Copy link
Contributor Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants