spaceagetv / electron-bytenode-example

A basic Hello World boilerplate using Webpack to convert Electron Javascript code to binary using Bytenode and the Bytenode Webpack Plugin
66 stars 15 forks source link

empty index.html body causes error #15

Closed MetaiR closed 2 years ago

MetaiR commented 2 years ago

Hi, it looks like the bytenode cant run an empty index.html this is important since react and other frameworks will render and attach content after the js loads and during this process the HTML file is empty

here is the error:

Uncaught Error: Invalid or incompatible cached data (cachedDataRejected)
    at Object..jsc (index.js:1)
    at Module.load (node:internal/modules/cjs/loader:982)
    at Module._load (node:internal/modules/cjs/loader:823)
    at Function.c._load (node:electron/js2c/asar_bundle:5)
    at Function.o._load (node:electron/js2c/renderer_init:29)
    at Module.require (node:internal/modules/cjs/loader:1006)
    at require (node:internal/modules/cjs/helpers:93)
    at Object.<anonymous> (index.js:1)
    at t (index.js:1)
    at Object.<anonymous> (index.js:1)

remember it is only happening on production and running the program executable generated by npm run package and it is ok on the dev mode

MetaiR commented 2 years ago

the weird thing is it actually doesn't care if the body is empty or not the only thing it cares about is existing this line in the body:

<span>🚫</span>

it is super weird!!!!!! the workaround is to have it like this:

<!DOCTYPE html>
<html>

<head>
    <title>Hello World!</title>
</head>

<body>
    <span hidden>🚫</span>
</body>
</html>
jjeff commented 2 years ago

Bytenode should not be affecting the HTML files at all. It only runs on .js files (and .ts files which have been compiled to .js). However, Webpack may be trying to insert a <script> link into your HTML files. This could be a problem with improperly formatted or missing HTML files.

vmartins commented 2 years ago

Try putting meta charset in HTML

<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8" />
    <title>Hello World!</title>
  </head>

  <body>

  </body>

</html>
jjeff commented 2 years ago

I've updated the project with the meta tag. Hopefully, this will help other people who are having this problem.