electron-userland / electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
1.01k stars 97 forks source link

Compiling of dynamically injected scripts? What are the technical limits of electron-compile? #152

Closed josephrocca closed 7 years ago

josephrocca commented 7 years ago

This is mostly a hypothetical question, but I'm just wondering whether it's possible. Basically, this doesn't work in electron-compile:

var script = document.createElement( 'script' );
script.innerText = `(async function() {
    console.log("1");
    await new Promise(resolve => setTimeout(resolve, 4000));
    console.log("2");
  })();`;
document.body.appendChild( script );

I didn't expect it to work, but I'm just wondering about the technical feasibility of this sort of thing? I don't now much about Chromium, but are there any hooks where dynamically injected scripts could be intercepted and compiled in real time?

Similarly, is it technically possible to intercept javascript commands entered into the DevTools console and compile them? This sort of functionality would be great for debugging, but I understand there are some limits to what's feasible.

As I said, this is really just a hypothetical - thanks so much to the contributors! This project has made my life much easier!

MarshallOfSound commented 7 years ago

I don't know about technical feasibility. But if you wait till Chromium 55 hits stable and makes it's way into Electron you won't need to compile to use async / await 👍

josephrocca commented 7 years ago

Oh, awesome - looks like it was announced yesterday! How long do you think it will take for this update to get into electron?

MarshallOfSound commented 7 years ago

@josephrocca The bump to Chromium 54 is still on-going as it is quite a major change. (Chromium changed their build system) so although normally I would say we normally target a few weeks after it hits stable, until we stabilise the new gn stuff I don't really know.

josephrocca commented 7 years ago

No worries at all - I'm just being greedy! Electron really is blowing my mind. Keep up the great work! :+1:

anaisbetts commented 7 years ago

Sadly not feasable, though you could reach into compilerHost and compile it yourself!