pkg icon indicating copy to clipboard operation
pkg copied to clipboard

RFC: pkg 6.0

Open jesec opened this issue 2 years ago • 5 comments

  • 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)

jesec avatar Jun 14 '22 22:06 jesec

Experimental support for ES Modules (bytecode/sourceless support not implemented yet)

YES BRO, YES.

henrycunh avatar Jun 15 '22 18:06 henrycunh

Finally, no need to rollup before compiling with ESM, nice 🚀

MidKnightXI avatar Jun 17 '22 18:06 MidKnightXI

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?

rightaway avatar Jun 20 '22 14:06 rightaway

Love it! 🚢

leerob avatar Jul 07 '22 02:07 leerob

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 avatar Aug 27 '22 18:08 si458

@si458 Awesome! ❤️

o0101 avatar Oct 01 '22 03:10 o0101

@si458 Here's a better option. Works for me perfectly.

m4heshd avatar Oct 21 '22 02:10 m4heshd

There is a compatibility issue with workers that are annoying; please consider these: https://github.com/vercel/pkg/issues/1419

saostad avatar Nov 29 '22 18:11 saostad

Is bytecode/sourceless support for ES Modules something that could be added?

rightaway avatar Dec 16 '22 04:12 rightaway

is it possible to include the ability to specify icons for mac /windows ?

rafinskipg avatar Jan 04 '23 14:01 rafinskipg

what time the v6 will release?

chenbimo avatar Jan 07 '23 12:01 chenbimo

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

xuakson avatar Jan 09 '23 20:01 xuakson

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

trizau avatar Jan 26 '23 16:01 trizau

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

Wow, life saver i will try it

xuakson avatar Jan 28 '23 14:01 xuakson


Currently I use resedit to modify icons.

can you link the github on the npm page and some description on how to use it?

rafinskipg avatar Jan 29 '23 02:01 rafinskipg


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

trizau avatar Jan 29 '23 02:01 trizau


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?

rafinskipg avatar Jan 30 '23 02:01 rafinskipg


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

trizau avatar Jan 30 '23 02:01 trizau

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

github-actions[bot] avatar May 01 '23 00:05 github-actions[bot]

I'm guessing this is not stale.

karlhorky avatar May 03 '23 07:05 karlhorky

I'm looking forward for the ESM feature :)

julianpoemp avatar Sep 16 '23 07:09 julianpoemp

@julianpoemp not sure we will ever see it. There is actually no one maintaining this project.

robertsLando avatar Sep 16 '23 16:09 robertsLando

just use bun either directly or through bkg!

worked super well for me :]

henrycunh avatar Sep 16 '23 16:09 henrycunh

just use bun either directly or through bkg!

worked super well for me :]

unfortunately bun seems not to work with NestJS

julianpoemp avatar Sep 17 '23 06:09 julianpoemp

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

robertsLando avatar Sep 18 '23 08:09 robertsLando

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

robertsLando avatar Sep 18 '23 08:09 robertsLando

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.

julianpoemp avatar Sep 28 '23 09:09 julianpoemp

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.

GabenGar avatar Sep 30 '23 04:09 GabenGar

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:

yao-pkg/pkg-fetch yao-pkg/pkg

If someone is interested in helping me create a PR or move your active PR to those repositories.

Thanks 🙏🏼

robertsLando avatar Oct 04 '23 12:10 robertsLando

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

rupurt avatar Oct 15 '23 21:10 rupurt