<p dir="auto">Electron version: <code class="notranslate">v0.36.7</code><br>
OS: linux</p>
<p dir="auto">Code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;
class GetterTest {
    get foo() {
        return &quot;bar&quot;
    }
}

global.foo = new GetterTest();

console.log(global.foo.foo)

const electron = require(&quot;electron&quot;);
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

var window = null;

app.on(&quot;ready&quot;, () =&gt; {
    window = new BrowserWindow();

    window.loadURL(`file://${__dirname}/index.html`);
});"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>
<span class="pl-k">class</span> <span class="pl-v">GetterTest</span> <span class="pl-kos">{</span>
    <span class="pl-k">get</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-s">"bar"</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">foo</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">GetterTest</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">foo</span><span class="pl-kos">.</span><span class="pl-c1">foo</span><span class="pl-kos">)</span>

<span class="pl-k">const</span> <span class="pl-s1">electron</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"electron"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">app</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-v">BrowserWindow</span> <span class="pl-c1">=</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">BrowserWindow</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">window</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span><span class="pl-kos">;</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">"ready"</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-s1">window</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">BrowserWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-s1">window</span><span class="pl-kos">.</span><span class="pl-en">loadURL</span><span class="pl-kos">(</span><span class="pl-s">`file://<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">__dirname</span><span class="pl-kos">}</span></span>/index.html`</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;html&gt;
    &lt;head&gt;
    &lt;script&gt;
var remote = require(&quot;remote&quot;);
var foo = remote.getGlobal(&quot;foo&quot;);

console.log(foo.foo);
    &lt;/script&gt;
    &lt;/head&gt;
&lt;/html&gt;"><pre class="notranslate"><span class="pl-kos">&lt;</span><span class="pl-ent">html</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">head</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>
<span class="pl-k">var</span> <span class="pl-s1">remote</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"remote"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-s1">remote</span><span class="pl-kos">.</span><span class="pl-en">getGlobal</span><span class="pl-kos">(</span><span class="pl-s">"foo"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">foo</span><span class="pl-kos">.</span><span class="pl-c1">foo</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;/</span><span class="pl-ent">head</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">html</span><span class="pl-kos">&gt;</span></pre></div>
<p dir="auto">Expected: both <code class="notranslate">console.log</code> statements print "bar".</p>
<p dir="auto">Actual: only <code class="notranslate">console.log</code> on main process prints "bar", the chrome debug console shows "undefined".</p>
<p dir="auto">ES6 classes treat member functions as non-enumerable in the instantiated class. However remote currently only works with enumerable properties, which means I have to use the old school prototype style to define classes for remote use. I find it a little bit inconvenient.</p>
<p dir="auto">Here is an example:</p>
<p dir="auto">in main process</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class ClientSocket {
    connect() {
        //..
    }
}
app.clientSocket = new ClientSocket();"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">ClientSocket</span> <span class="pl-kos">{</span>
    <span class="pl-en">connect</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-c">//..</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-c1">clientSocket</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">ClientSocket</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">in render process</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const clientSocket = remote.app.clientSocket;
clientSocket.connect() // this doesn't work because connect() is not enumerable."><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">clientSocket</span> <span class="pl-c1">=</span> <span class="pl-s1">remote</span><span class="pl-kos">.</span><span class="pl-c1">app</span><span class="pl-kos">.</span><span class="pl-c1">clientSocket</span><span class="pl-kos">;</span>
<span class="pl-s1">clientSocket</span><span class="pl-kos">.</span><span class="pl-en">connect</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c">// this doesn't work because connect() is not enumerable.</span></pre></div>
<p dir="auto">I mostly write new code in ES6 style and I'd like to keep my code style consistent. Is there any way to enable remote for ES6 class?</p>