electron-userland / electron-compile

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

npm link breaks transpilation #213

Open artm opened 7 years ago

artm commented 7 years ago

Once I execute npm link WIP_MODULE babel can't load a plugin from my main package. If I unlink and npm install again all works.

Relevant portion of the package.json:

  "devDependencies": {
    "babel-plugin-transform-class-properties": "^6.23.0",
    "electron-prebuilt-compile": "^1.6.2"
  },

and .complilerc:

{
  "application/javascript": {
    "presets": ["es2016-node5", "react"],
    "plugins": [
      ["transform-class-properties", { "spec": true }]
    ],
    "sourceMaps": "inline"
  }
}

The error message I'm getting after npm link ...:

Uncaught ReferenceError: Unknown plugin "transform-class-properties" specified in "base" at 0

Can this be helped? Is there a better way to use a local unpublished dependency while developing that is compatible with electron-compile?

mnaamani commented 7 years ago

I have an almost identical config, and seeing the exact same problem, when I have a module that is npm linked.

mnaamani commented 7 years ago

@artm I removed "react-hot-loader/babel" from the plugins array in the .compilerc and the problem went away. Can you confirm that this would solve your problem too?

artm commented 7 years ago

I ended up not using npm link, I just embedded the module into the main project.

I also don't use "react-hot-loader/babel" directly.

mnaamani commented 7 years ago

I submitted a PR in electron-compilers which is one possible fix for this issue. https://github.com/electron/electron-compilers/pull/73/commits/a4cc09893a03ec50f1c61dd3450eaa66a7628f1d

joecohens commented 7 years ago

I'm having the same issue using Lerna to link libraries, I think it is related to https://github.com/zeit/next.js/commit/ca161c375f22c71549849595b68f3e43eda94a89

scvnc commented 7 years ago

Yes, I am experiencing this too. npm link WIP_MODULE initially starts complaining about missing babel plugins relative to the WIP_MODULE that I have installed for my my electron app. I can unnecessarily install them in my linked WIP_MODULE to get further, but then it complains in the browser Error: Cannot find module 'WIP_MODULE'

I will work with maintainer on this personally if needed. Although I suspect I am wasting time being bitten by this electron-compile path instead of just using webpack et al directly.