standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

Not working with renderer process for Electron 6 or newer #867

Open aistrych opened 4 years ago

aistrych commented 4 years ago

After upgrading electron and esm versions to the newest ones (in https://github.com/standard-things/electron-quick-start) esm loader for renderer process stopped working with errors:

"Uncaught /path_to_my_project_dir/electron-quick-start/index.html:1 Error: Cannot find module './renderer.js' Require stack:

Requiring module from node_modules like this:

<script>
  // You can also require other files to run in this process
  require = require('esm')(module)
  require('electron')
</script>

works without issues.

Here are my changes for electron 8 (but issue exists for electron 6 and 7 as well): https://github.com/Astrych/electron-quick-start/commit/9ca5498beacf08d1572ffee05df385faad261dd0

With electron 4 and 5 everything works just fine.

toddwong commented 4 years ago

I worked it around with this

      module.id = '.';
      module.path = '.';
      require = require('esm')(module);
      require('./renderer.js')

but when I imported openlayers, stranges thing happened. it works on the first load, but fails after reload (by menu). If I keep reloading again and again, it will work, fail, work, fail, work, fail....

Update: I made it work always by disabling cache.

kylewetton commented 4 years ago

Christ, any one figure this one out? I'm running out of ideas

veeramarni commented 3 years ago

I have same issue, anyone found a solution or workaround for this issue?