pkg
pkg copied to clipboard
RFC: pkg 6.0
- Drop Node 8, 10, and 12
- #1225
- Experimental support for ES Modules (bytecode/sourceless support not implemented yet)
- Upstream single-executable application implementation (nodejs/node#43432)
- No longer use hardcoded position. Fixes: change icon/metadata in Windows executable (#44, #91, #105, #112, #149, #151, #212, #318, #812, #821, #918, #934, #1238, #1289, #1590), compressed Node executable (#50, #228, #281, #578, #1269)
Experimental support for ES Modules (bytecode/sourceless support not implemented yet)
YES BRO, YES.
Finally, no need to rollup before compiling with ESM, nice 🚀
Is bytecode/sourceless support for ES Modules blocked on some features in dependencies or is it something that can be implemented entirely in this package?
Love it! 🚢
https://github.com/Ylianst/Authenticode-JS this allows you to change the exe data like company name, version number, icon, sign with certificate (for antiviruses) NOTE: for the icon to change, you must change the icon of the build that gets downloaded BEFORE you build the app its all pure javascript with NO external software, could be included in upcoming release for end users to customise stuff now
sample code:
const path = require('path');
const authenticodejs = require("authenticode-js");
// load certificate into memory
const cert = authenticodejs.loadCertificates("certificates.pem");
// load icon into memory
const icon = authenticodejs.loadIcon("icon.ico");
// load exe into memory
const exehandler = authenticodejs.createAuthenticodeHandler(path.resolve('dist\\ourbackups-win.exe'));
if(exehandler == null){ console.error('error null exehandler'); return; }
// this section reads version stuff then changes and sets it
const info = exehandler.getVersionInfo();
info.FileDescription = "My Description"
info.FileVersion = "1.0.0.0";
info.ProductName = "My App";
info.ProductVersion = "1.0.0.0";
info.LegalCopyright = "My Company";
info.OriginalFilename = "";
info.CompanyName = "My Company";
exehandler.setVersionInfo(info);
// this section reads icon stuff then changes it and sets it
const icons = exehandler.getIconInfo();
icons[1] = icon;
exehandler.setIconInfo(icons);
// write the data and certificate to file
exehandler.writeExecutable({ out: 'mysigned.exe', time: "http://timestamp.sectigo.com" }, cert, (error) => {
if (error) {
console.error(error);
} else {
console.log('complete');
exehandler.close();
}
});
console.log('Writing EXE');
@si458 Awesome! ❤️
@si458 Here's a better option. Works for me perfectly.
There is a compatibility issue with workers that are annoying; please consider these: https://github.com/vercel/pkg/issues/1419
Is bytecode/sourceless support for ES Modules something that could be added?
is it possible to include the ability to specify icons for mac /windows ?
what time the v6 will release?
Lol, After changing the icon, I got this
pkg/prelude/bootstrap.js:1
ects best mime encoding for a text value
^^^^
SyntaxError: Unexpected identifier
[90m at new Script (vm.js:103:7)[39m
[90m at readPrelude (internal/bootstrap/pkg.js:29:13)[39m
[90m at internal/bootstrap/pkg.js:36:18[39m
[90m at internal/bootstrap/pkg.js:43:4[39m
[90m at internal/bootstrap/pkg.js:44:2[39m
Lol, After changing the icon, I got this
pkg/prelude/bootstrap.js:1 ects best mime encoding for a text value ^^^^ SyntaxError: Unexpected identifier �[90m at new Script (vm.js:103:7)�[39m �[90m at readPrelude (internal/bootstrap/pkg.js:29:13)�[39m �[90m at internal/bootstrap/pkg.js:36:18�[39m �[90m at internal/bootstrap/pkg.js:43:4�[39m �[90m at internal/bootstrap/pkg.js:44:2�[39m
Currently I use resedit to modify icons. After testing, it is found that this problem will occur when the icon file is larger than 100kb.
I released a pkg-edit to use in my project, use npx pkg-edit init
to generate configuration files, then npx pkg-edit build
to modify the build for release.
I use pkg 5.8.0 and it works fine
Lol, After changing the icon, I got this
pkg/prelude/bootstrap.js:1 ects best mime encoding for a text value ^^^^ SyntaxError: Unexpected identifier �[90m at new Script (vm.js:103:7)�[39m �[90m at readPrelude (internal/bootstrap/pkg.js:29:13)�[39m �[90m at internal/bootstrap/pkg.js:36:18�[39m �[90m at internal/bootstrap/pkg.js:43:4�[39m �[90m at internal/bootstrap/pkg.js:44:2�[39m
Currently I use resedit to modify icons. After testing, it is found that this problem will occur when the icon file is larger than 100kb. I released a pkg-edit to use in my project, use
npx pkg-edit init
to generate configuration files, thennpx pkg-edit build
to modify the build for release. I use pkg 5.8.0 and it works fine
Wow, life saver i will try it
Currently I use resedit to modify icons.
can you link the github on the npm page and some description on how to use it?
Currently I use resedit to modify icons.
can you link the github on the npm page and some description on how to use it?
I updated some docs explaining how I use it
Currently I use resedit to modify icons.
can you link the github on the npm page and some description on how to use it?
I updated some docs explaining how I use it
this only works for windows, right? how do you do it for mac?
Currently I use resedit to modify icons.
can you link the github on the npm page and some description on how to use it?
I updated some docs explaining how I use it
this only works for windows, right? how do you do it for mac?
It's just a wrapper around the resedit library, so it's only valid for win. For mac (my macbook hasn't been used for a month), I found some documentation: https://beebom.com/change-app-icons-to-big-sur-style-icons/amp/
https://stackoverflow.com/questions/57251019/is-it-possible-to-change-any-apps-icon-with-nodejs
https://apple.stackexchange.com/questions/6901/how-can-i-change-a-file-or-folder-icon-using-the-terminal
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
I'm guessing this is not stale.
I'm looking forward for the ESM feature :)
@julianpoemp not sure we will ever see it. There is actually no one maintaining this project.
just use bun either directly or through
bkg
!worked super well for me :]
unfortunately bun seems not to work with NestJS
Bun nodejs support is still not production ready unfortunately. Also deno supports compile: https://docs.deno.com/runtime/manual/tools/compiler
Anyway for most nodejs projects of a certain size them would be almost impossible to use at this time for compatibility issues
Also worth notice that bkg doesn't compile the source code into bytecode:
Sources are not compiled to bytecode: Bun does not expose a JavascriptCore equivalent of v8::ScriptCompiler yet, hence sources are kept intact in the compiled executable.
https://github.com/theseyan/bkg#differences-from-pkg
It actually works like caxa
if someone is facing issues with ESM modules I recommend to use ncc as a pre step before bundling with pkg. It even seems to reduce the size of the executable, in my case by 30%. Before using vercel/ncc I had to add a lot of dependencies to assets property, now it's much less.
The typescript settings it requires means it also requires a prior bundling step for ESM code, which is not a solution to the problem at hand.
For anyone that is interested in this project, giving that I don't receive any feedback from Vercel anymore, I created my own forks of both pkg and pkg-fetch:
If someone is interested in helping me create a PR or move your active PR to those repositories.
Thanks 🙏🏼
@julianpoemp can confirm using vercel/ncc
makes the build work more reliably and results in a much smaller final binary.
It's really unfortunate this project is no longer maintained by @vercel-infra. Bun is great but doesn't support Windows yet and it's very common for npm packages not to work. I feel like it's unlikely Bun and certainly Deno will achieve 1:1 compatibility with Node.JS in the near future. I've got high hopes that Bun will eventually get there though :crossed_fingers: