Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

RFC: pkg 6.0 #1655

Closed
jesec opened this issue Jun 14, 2022 · 29 comments
Closed

RFC: pkg 6.0 #1655

jesec opened this issue Jun 14, 2022 · 29 comments

Comments

@jesec
Copy link
Contributor

jesec commented Jun 14, 2022

@jesec jesec changed the title RFC: pkg 6. RFC: pkg 6.0 Jun 14, 2022
@jesec jesec pinned this issue Jun 14, 2022
@henrycunh
Copy link

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

YES BRO, YES.

@MidKnightXI
Copy link

MidKnightXI commented Jun 17, 2022

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

@leerob
Copy link
Member

leerob commented Jul 7, 2022

Love it! 🚢

@si458
Copy link

si458 commented Aug 27, 2022

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');

@o0101
Copy link

o0101 commented Oct 1, 2022

@si458 Awesome! ❤️

@m4heshd
Copy link

m4heshd commented Oct 21, 2022

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

@saostad
Copy link

saostad commented Nov 29, 2022

There is a compatibility issue with workers that are annoying; please consider these:
#1419

@rightaway
Copy link

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

@rafinskipg
Copy link

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

@chenbimo
Copy link

chenbimo commented Jan 7, 2023

what time the v6 will release?

@xuakson
Copy link

xuakson commented Jan 9, 2023

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

@trizau
Copy link

trizau commented Jan 26, 2023

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

@xuakson
Copy link

xuakson commented Jan 28, 2023

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

@rafinskipg
Copy link


Currently I use resedit to modify icons.

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

@trizau
Copy link

trizau commented Jan 29, 2023


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

@rafinskipg
Copy link


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?

@trizau
Copy link

trizau commented Jan 30, 2023


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

@github-actions
Copy link

github-actions bot commented May 1, 2023

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 github-actions bot added the Stale label May 1, 2023
@karlhorky
Copy link

I'm guessing this is not stale.

@github-actions github-actions bot removed the Stale label May 4, 2023
@julianpoemp
Copy link

julianpoemp commented Sep 16, 2023

I'm looking forward for the ESM feature :)

@robertsLando
Copy link
Contributor

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

@henrycunh
Copy link

just use bun either directly or through bkg!

worked super well for me :]

@julianpoemp
Copy link

just use bun either directly or through bkg!

worked super well for me :]

unfortunately bun seems not to work with NestJS

@robertsLando
Copy link
Contributor

robertsLando commented Sep 18, 2023

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
Copy link
Contributor

robertsLando commented Sep 18, 2023

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

@julianpoemp
Copy link

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.

@GabenGar
Copy link

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.

@robertsLando
Copy link
Contributor

robertsLando commented Oct 4, 2023

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 🙏🏼

@rupurt
Copy link

rupurt commented Oct 15, 2023

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

@leerob leerob unpinned this issue Jan 3, 2024
@leerob leerob closed this as completed Jan 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests