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.

Electron Build Should Copy Lock File

See original GitHub issue

Is your feature request related to a problem? Please describe. Currently the Electron build process copies the project package.json to the build directory and performs a production install from that. If the package.json doesn’t specify exact versions of all dependencies, this can lead to the build using different versions of dependencies than dev.

In my case, one of my dependencies introduced a breaking change in a minor version (poor form, I know). My package.json specified “^2.8.0”. Running “quasar dev -m electron” resulted in using 2.8.0 from the version controlled package-lock.json and worked fine, but “quasar build -m electron” installed the latest 2.x.0 release, which produced a non-functional build.

Describe the solution you’d like Prior to the Electron package installation step, the project package-lock.json or yarn.lock, as determined by the nodePackager variable, should be copied into the electron UnPackaged build directory. I’ve verified that this results in installing just production dependencies at the locked versions for npm. I believe this should be true for yarn as well, but have not confirmed.

Describe alternatives you’ve considered If introducing the behavior specified above might cause issues I haven’t considered, the behavior could be added to the Electron documentation, perhaps with a slightly more polished version of this work around that I have successfully added to the build property in quasar.conf.js:

async beforeBuild() {
  const unpackagedPath = `${__dirname}/dist/electron/UnPackaged`;
  mkdirp.sync(unpackagedPath);
  fs.copyFileSync(`${__dirname}/package-lock.json`, `${unpackagedPath}/package-lock.json`);
},

Additional context I’m willing to try to familiarize my self a bit more with the Quasar code base and put together a PR if this feature gets a green light. If somebody already familiar can immediately point out what method would be most appropriate to extend for this, that would be helpful. I assume the method that copies package.json currently, but I haven’t tracked that down yet.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rfox12commented, Oct 26, 2021

And it seems some cool new Vite goodness on the horizon. Yep… 100% agree we can leave this to folks to figure out. For posterity two easy ways that I know of right off the bat…

  1. add a script to your package.json like this:
"build": "quasar build -m electron",
"postbuild": "node -e \"require('fs-extra').copySync('package-lock.json', '../dist/electron/package-lock.json');\"",

with whatever path you want relative to package.json. The post prefix there causes the postbuild script to run immediately after the build script automatically. or (probably better) 2) modify quasar.conf with a pre-build or post-build trigger. https://quasar.dev/app-extensions/development-guide/index-api#api-beforebuild

0reactions
rstoenescucommented, Dec 6, 2021

Enhancement will be available in “@quasar/app” v3.2.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Application Contents - electron-builder
Development dependencies are never copied in any case. You don't need to ignore it explicitly. Hidden files are not ignored by default, but...
Read more >
Working with files (I/O) in an Electron application - Medium
In this lesson, we are going to create an Electron application with a ... The user should be able to delete the file...
Read more >
node.js - How can I lock a file while writing to it asynchronously
I'd use proper-lockfile for this. You can specify an amount of retries or use a retry config object to use an exponential backoff...
Read more >
A deep dive into file locking with NodeJS - DEV Community ‍ ‍
For your suggestion I'm wondering, doesn't the “private” copy have the same lock problem? While creating/copying this private file, another ...
Read more >
Save Files in ElectronJS - GeeksforGeeks
Install Electron using npm if it is not installed. npm install electron --save. This command will also create the package-lock.json file and ...
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