electron-userland / electron-compile

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

JS file with a unique export (not default) is invalid #245

Open magne4000 opened 7 years ago

magne4000 commented 7 years ago

I have the following selectors.js file

export const isUpdateAvailable = state => state.getIn(['auto_update', 'updateAvailable']);

When I try to import it import { isUpdateAvailable } from 'selectors', electron (in a renderer) complains that it does not know export keyword.

If I try to add a second export in that file, not more error (with the same import)

export const isUpdateAvailable = state => state.getIn(['auto_update', 'updateAvailable']);

export const dummy = null;

Any ideas ?

my .compilerc

{
  "text/scss": {},
  "application/javascript": {
    "presets": [
      "react",
      "es2017-node7"
    ],
    "plugins": [
      "add-module-exports",
      "transform-async-to-generator",
      "transform-decorators-legacy"
    ],
    "env": {
      "production": {
        "plugins": [
          "babel-plugin-dev-expression"
        ]
      },
      "development": {
        "plugins": [
          "react-hot-loader/babel"
        ]
      }
    }
  }
}
liamaharon commented 6 years ago

I'm having the same issue, did you end up fixing this?

magne4000 commented 6 years ago

@liamaharon I think the issue still isn't fixed. For the project which we having the issue, we now have mostly TypeScript files now in our codebase, and those work fine.