question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ask for an advice in folder structure with external JS files

See original GitHub issue
  • 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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
crashbellcommented, Oct 31, 2016

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

0reactions
develarcommented, Oct 30, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding my Javascript file that is in another folder
To import a JS file it most be in a static folder. ... Folder structure should have a static folder and should look...
Read more >
Use external js file or controller? - Hotwire Discussion
Hi I want to create a class just to call in other controller. Now which is better? 1 - create a extra folder...
Read more >
5 Tips to Organize Your JavaScript Code Without a Framework
When you're organizing JavaScript code without a framework, there are some best practices you should follow to ensure a clean structure.
Read more >
Handling common JavaScript problems - MDN Web Docs
Incorrectly using functions inside loops that iterate with a global variable (more generally "getting the scope wrong"). For example, in bad-for ...
Read more >
External JavaScript File - Javatpoint
An external JavaScript file must be saved by .js extension. It is recommended to embed all JavaScript files into a single file. It...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found