electron-compile icon indicating copy to clipboard operation
electron-compile copied to clipboard

npm link breaks transpilation

Open artm opened this issue 7 years ago • 6 comments

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?

artm avatar Apr 02 '17 17:04 artm

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

mnaamani avatar May 04 '17 15:05 mnaamani

@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?

mnaamani avatar May 04 '17 22:05 mnaamani

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.

artm avatar May 05 '17 05:05 artm

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

mnaamani avatar May 09 '17 08:05 mnaamani

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

joecohens avatar May 15 '17 22:05 joecohens

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.

scvnc avatar Jul 21 '17 00:07 scvnc