electron-userland / electron-compile

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

start works, packaged app -> Error "...was not precompiled" #241

Open ghost opened 7 years ago

ghost commented 7 years ago

Please describe your issue:

when I start the app with

electron-forge start

I don't get any errors

Packaging the app seems to work as well.

electron-forge package
✔ Checking your system
✔ Preparing to Package Application for arch: x64
✔ Compiling Application
✔ Preparing native dependencies
✔ Packaging Application

But when I start the packaged app I get the following error in the DevTools Console

Uncaught Error: Asked for /Users/..../myElectronForgeTest.app/Contents/Resources/app/module/file.js but it was not precompiled!

I tried to run electron-compile in the root folder and copy the .cache folder into the package, but it didn't change anything.

What command line arguments are you passing?

None

What does your config.forge data in package.json look like?


  "config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {},
      "electronWinstallerConfig": {
        "name": "myElectronForgeTest"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "myElectronForgeTest"
      }
    }
  }
jhofker commented 7 years ago

I get the same thing, but only on Windows (for .jsx files in the project). On Mac, the produced application runs fine.

jhofker commented 7 years ago

@ghost Check the capitalization of things in your import statement to ensure they match what exists on the filesystem. For reference: https://github.com/electron-userland/electron-forge/issues/254

aitorpazos commented 5 years ago

I hit something similar and could workaround it with the changes introduced in #199. I was seeing:

W, dd mmm YYYY hh:mm:ss GMT electron-compile:file-change-cache cacheKey: C:/Users/<user>/git/<app-path>/resources/index.html, appRoot: c:/Users/pazosa/git/<app-path>/resources/app.asar , originalAppRoot: C:/Users/<user>/AppData/Local/Temp/electron-packager/win32-x64/<app>/resources/app
W, dd mmm YYYY hh:mm:ss GMT electron-compile:protocol-hook Failed to compile C:/Users/<user>/git/<app-path>/resources/index.html: Asked for C:/Users/<user>/git/<app-path>/resources/index.html but it was not precompiled!

And got me wondering if that appRoot: c: (notice c: capitalisation) was the source of the error.

So my workaround was to bypass the cache for good:

require('electron-compile').addBypassChecker(function (filePath){return true});

I don't understand why a caching mechanism makes an app fall-over. I think that's a but and it should log warnings if there is something wrong with the cache, but it shouldn't break the app.