electron-userland / electron-compile

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

.compilerc not respected while packaging #202

Closed sebakerckhof closed 7 years ago

sebakerckhof commented 7 years ago

I use electron-forge, which in turn uses electron-compile.

I have a .compilerc that looks like:

{
  "env": {
    "development": {
      "application/javascript": {
        "presets": [
          [
            "env",
            {
              "targets": {
                "chrome": 56
              }
            }
          ]
        ],
        "plugins": [],
        "sourceMaps": "inline"
      }
    },
    "production": {
      "application/javascript": {
        "presets": [
          [
            "env",
            {
              "targets": {
                "chrome": 56
              }
            }
          ]
        ],
        "plugins": [],
        "sourceMaps": "none"
      }
    }
  }
}

With electron-forge start I seem to be having no trouble and .compilerc is being respected. With electron-forge package. The packaged application gives me an error which I can trace back to this babel bug: https://github.com/babel/babel/issues/3930 . However, this babel plugin shouldn't even be used considering the above .compilerc.

When I look in the packaged application /resouces/app/.cache/compiler-info.json.gz I see these lines:

"text/jsx":{"name":"BabelCompiler","inputMimeTypes":["text/jsx","application/javascript"],"compilerOptions":{"presets":["es2016-node5","react"],"sourceMaps":"inline"},"compilerVersion":"6.23.1"},

"application/javascript":{"name":"BabelCompiler","inputMimeTypes":["text/jsx","application/javascript"],"compilerOptions":{"presets":["es2016-node5","react"],"sourceMaps":"inline"},"compilerVersion":"6.23.1"},

These seem to be the default options here: https://github.com/electron/electron-compile/blob/0296ef553934fc5131e586085751f092f0042950/src/config-parser.js#L359

So I have no idea why it doesn't use my .compilerc while packaging...

I also tried having a .compilerc without different environments, but no success.

MarshallOfSound commented 7 years ago

Closing in favor of the report on -forge as that is probably where it is coming from 😕

sebakerckhof commented 7 years ago

@MarshallOfSound

After looking into it more, what happens is that while packaging the app, it tries to look in the temporary packaging folder for the .compilerc file.

So for example: /tmp/electron-packager/linux-x64/my_app-linux-x64/resources/app/.compilerc However, while the package.json is copied over, the .compilerc is not and therefore it falls back to the default config...

I have no idea who should be responsible for that...

MarshallOfSound commented 7 years ago

@sebakerckhof Possibly your ignore config for electron-forge?

MarshallOfSound commented 7 years ago

Locking to stop the back and forth between issues