Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for sibling packages (lerna + yarn workspaces) #2222

Closed
PaulLeCam opened this issue Oct 24, 2017 · 13 comments · Fixed by Thorium-Sim/thorium-kiosk#40
Closed

Support for sibling packages (lerna + yarn workspaces) #2222

PaulLeCam opened this issue Oct 24, 2017 · 13 comments · Fixed by Thorium-Sim/thorium-kiosk#40
Labels

Comments

@PaulLeCam
Copy link

  • Version: 19.40.0
  • Target: any

Hi, following the support for hoisted node_modules in lerna + yarn workspaces in v19.39.0, I'm wondering if it would also be possible to support sibling packages as defined in the lerna.json packages config and/or the root package.json workspaces please?
I currently have a setup where my electron app is using sibling packages and electron-builder throws the "Error: Unresolved node modules" error for these dependencies.
Thanks!

@develar
Copy link
Member

develar commented Oct 24, 2017

Sample project please :)

@PaulLeCam
Copy link
Author

Here it is: https://github.com/PaulLeCam/electron-builder-workspaces

I think the main issue comes from this dependency that is correctly resolved by lerna/yarn, but not by electron-builder: https://github.com/PaulLeCam/electron-builder-workspaces/blob/master/packages/app-desktop/package.json#L14

@axe312ger
Copy link

Was hoping for b0fa409 to fix this, but still not working for me. Checked out the sample project, same behavior.

The dependencies in the packages are missing, no node_modules folder present in there, only in the root directory.

Any ideas?

@develar
Copy link
Member

develar commented Oct 31, 2017

I will try to find time to investigate this issue soon.

@axe312ger
Copy link

axe312ger commented Oct 31, 2017

Thanks, found out my yarn was overwritten by an old version, I am now on yarn 1.2.1. Tuned out my old yarn did not support workspaces yet.

Will investigate further, but looks like sub-dependencies of dependencies are missing in the bundles. Running electron directly from within my lerna package works fine. Tried it with module hoisting enabled and disabled.

@axe312ger
Copy link

Okay, the repo of @PaulLeCam has the same issue:

Uncaught Exception:
Error: Cannot find module 'serve'
    at Module._resolveFilename (module.js:470:15)
    at Function.Module._resolveFilename (/Users/bene/dev/electron-builder-workspaces/packages/app-desktop/dist/mac/app-desktop.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/bene/dev/electron-builder-workspaces/packages/app-desktop/dist/mac/app-desktop.app/Contents/Resources/app.asar/node_modules/app-server/index.js:2:15)
    at Object.<anonymous> (/Users/bene/dev/electron-builder-workspaces/packages/app-desktop/dist/mac/app-desktop.app/Contents/Resources/app.asar/node_modules/app-server/index.js:6:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

serve is a dependency of package/app-server which gets not included into the electron-builder "binary".

Running electron from within the package/app-desktop via npm start works fine.

Steps to reproduce:

  • add "main": "main.js", to package.json of package/app-desktop
  • npm i
  • lerna bootstrap
  • lerna exec build
  • Run the app, on mac: open packages/app-desktop/dist/mac/app-desktop.app

screen shot 2017-11-01 at 18 27 56

@rgbkrk
Copy link

rgbkrk commented Nov 27, 2017

Same issue for us in nteract, PR to introduce hoisting back in and upgrade electron-builder: nteract/nteract#2102

We'd also love to switch to yarn workspaces, though we're running into issues with it and electron builder there too.

@ghost
Copy link

ghost commented Nov 28, 2017

Does it make sense to mention also the use case of the link: dependency such as:

    "dependencies": {
        "foobar": "link:../foobar",

Currently, I have loads of missing dependencies by using such a pattern. Whether it should be supported or not is a good question, but if it is not, at least it would be nice if there was a heads-up warning...
Cheers

@derek-duncan
Copy link

derek-duncan commented Nov 29, 2017

I'm experiencing the same issues with Unresolved node modules: when running electron-builder@19.46.9. We're using yarn workspaces to hoist dependencies/monorepo. It looks like the issue is that sub-dependencies of dependencies cannot be found or packaged into the binary, like @axe312ger pointed out.

How can we help to get this issue resolved?

@derek-duncan
Copy link

I solved this for the moment by bundling first with Webpack. Webpack can correctly resolve the dependencies, so loading in the bundled JS and setting ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=1 before running electron-builder works for now.

@develar
Copy link
Member

develar commented Dec 1, 2017

This issue will be addressed on this weekends (as we have sample project :)).

@lgeiger
Copy link
Contributor

lgeiger commented Dec 18, 2017

@develar Thanks for investigating!

Is there anything we can help to track this down?

@axe312ger
Copy link

Awesome @develar thx :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants