Skip to content

Instantly share code, notes, and snippets.

View jarek-foksa's full-sized avatar

Jarek Foksa jarek-foksa

View GitHub Profile
@jarek-foksa
jarek-foksa / index.html
Last active July 7, 2020 13:42 — forked from SMotaal/README.md
Electron 2.x demo app that demonstrates how to enable ES modules support.
<!DOCTYPE html>
<html>
<head>
<base href="app://./" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' app:; object-src 'self' app:;">
<script type="module" src="./module.js"></script>
</head>
<body>
Check the console!
@SMotaal
SMotaal / README.md
Last active January 13, 2023 20:07
Loading ES Modules in Electron 2.0.0 using Protocol

Now that Electron has hit Chrome's 60s we can have proper module support. But of course, the standard (for very good reasons) prevents loading modules from file: and it makes sense for both Electron and NW.js to adhere to the statusquo.

So if you were really excited and this bums you, don't worry, you are in for awesome things.

The future Electron eco-system offers two options for native ES modules:

  1. Custom Electron protocol via Chromium's module loading subsystem

  2. Custom NodeJS loaders via Node's module loading subsystem recommended