Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add experimental sea support and drop nodejs 16 support #110

Merged
merged 13 commits into from
Oct 22, 2024

Conversation

robertsLando
Copy link
Member

@robertsLando robertsLando commented Oct 22, 2024

Adds cross-arch and cross-os node sea support with flag --sea. Limitation: accepts a single executable file as input, may require a pre-build step using esbuild for multi-file applications

BREAKING CHANGE: Drop support for NodeJS 16

@robertsLando robertsLando changed the title feat: add experimental sea support feat!: add experimental sea support and drop nodejs 16 support Oct 22, 2024
@robertsLando robertsLando merged commit 0145a94 into main Oct 22, 2024
6 checks passed
@robertsLando robertsLando deleted the sea-support branch October 22, 2024 15:35
@pmosconi
Copy link

Hi,
just tested it building with --sea -t node20-linux,node20-win,node20-mac on Windows, using bash.
All 3 executables are created, I ran both win and linux (in wsl Ubuntu and on native Ubuntu) and they work.
I couldn't test the mac one for lack thereof.

Only glitch: I got the following warning at the end of build
Warning Failed to cleanup the temp directory C:\Users\PAOLOM~1\AppData\Local\Temp\pkg-sea\1729950081989
and indeed the folder is there.

Thanks for your work!

@robertsLando
Copy link
Member Author

Hi @pmosconi and thanks for your feedback 🙏🏻 I have been able to reproduce the windows issue about directory cleanup, I sincerely have no clue why that happens, I don't have a windows pc, could you check the that? Everything is located in lib/sea.ts, it's the last function called at the end of sea function

@pmosconi
Copy link

Hi @robertsLando , I tried to reproduce the error creating a small node function but, needless to say, I've been unable.
It can be a timing issue or more likely a permission issue or the typical Windows mystery issue...
BTW looking at node fs docs I found this at fsPromises.rmdir(path[, options]):

To get a behavior similar to the rm -rf Unix command, use fsPromises.rm() with options { recursive: true, force: true }.

My 2 cents:

  1. add force: true option,
  2. trap any error and fail silently with no warning

The AppData/Local/Temp folder is full of crap and I believe that most programs (MS included) don't really bother to clean it up.

This is my test code (that cleans up after itself):

import { writeFile, rm, mkdir, copyFile } from 'fs/promises';

const TEST_DIR = '/Users/PAOLOM~1/AppData/Local/Temp/test-pkg-rm';

const test = async () => {
  await mkdir(TEST_DIR);
  await writeFile(TEST_DIR +'/test.txt', 'Hello World!');
  await mkdir(TEST_DIR +'/test1');
  await writeFile(TEST_DIR +'/test1/test1.txt', 'Hello World!');
  await copyFile('big-executable-linux', TEST_DIR +'/test1/big-executable-linux');
  await copyFile('big-executable-macos', TEST_DIR +'/test1/big-executable-macos');
  await copyFile('big-executable-win.exe', TEST_DIR +'/test1/big-executable-win.exe');
  await rm(TEST_DIR, { recursive: true });
}

test();

Best regards

@robertsLando
Copy link
Member Author

Grazie Paolo for looking at this :) Will try to add the force option! :)

@lastelok
Copy link

lastelok commented Nov 7, 2024

Hi, --sea flag not hides source code, may it be enabled?

@robertsLando
Copy link
Member Author

Not sure about that, I don't see mentions of this in docs: https://nodejs.org/api/single-executable-applications.html

@lastelok
Copy link

lastelok commented Nov 7, 2024

Not sure about that, I don't see mentions of this in docs: https://nodejs.org/api/single-executable-applications.html

Yes, seems no such option. For me pkg nice and simple way to make executable and hide source code, which is important for me. By the way, thank you very much for maintaining pkg, you do great work, appreciate it. ESM and new node version is nice 😊

@robertsLando
Copy link
Member Author

Yes, seems no such option. For me pkg nice and simple way to make executable and hide source code, which is important for me

I understand that, the problem is that keeping pkg maintained is hard because of we need to patch nodejs every time in order to make it work and this takes lot of time, sea is my bet for the future but I dunno when and if it will ever be a drop in replacement to pkg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants