Electron-builder: Ask for an advice in folder structure with external JS files

Created on 30 Oct 2016  Â·  5Comments  Â·  Source: electron-userland/electron-builder

  • Version: 7.14.2

  • Target: MacOS, Windows

Please take a look at the folder structures below:

Development folder structure (after compiled from src)

â–¾ app/
  â–¸ node_modules/
  â–¸ out/
  â–¸ workers/
    package.json

Build folder structure

â–¾ app.asar/
  â–¸ node_modules/
  â–¸ out/
  package.json
â–¾ app/
  â–¸ workers/

I'm trying to find a good way to work with external files. Due to our project's needs, we have to fork some processes from workers folder. I used extraResouces to get rid of worker folder and I got a problem since the path of worker folder is changed in the build. For instance, if I want to require blahblah-modules, I have to declare the path differently for each environment: blahblah-modules (development) and ../../app.asar/node_modules/blahblah-modules (build). I would like to ask for an advice to improve this silly path.

question

Most helpful comment

@develar That's surprising when I tried to make a sample app. I can fork the worker with the path like electron-sample.app/Contents/Resources/app.asar/workers/text-generator. Regarding this I never thought that it could work. So I don't need any workaround so far.

All 5 comments

To be clear — require from worker code, right?

Possible approach — https://github.com/electron-userland/electron-builder/wiki/Loading-App-Dependencies-Manually (about dev mode, but you can add node module search path in production as well.

@develar Thanks a lot. That seems what I'm looking for.

Probably, if you can provide sample app, I will try find free time to play with it and simplify somehow.

Maybe, electron supports this search path if your worker will use asar.unpack. I am sorry, but without sample app I will not investigate it further.

@develar That's surprising when I tried to make a sample app. I can fork the worker with the path like electron-sample.app/Contents/Resources/app.asar/workers/text-generator. Regarding this I never thought that it could work. So I don't need any workaround so far.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnWeisz picture JohnWeisz  Â·  3Comments

antonycourtney picture antonycourtney  Â·  3Comments

AidanNichol picture AidanNichol  Â·  3Comments

lbssousa picture lbssousa  Â·  3Comments

jhg picture jhg  Â·  3Comments