Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

FYI about ESM #2

Closed
TomasHubelbauer opened this issue Mar 4, 2021 · 3 comments
Closed

FYI about ESM #2

TomasHubelbauer opened this issue Mar 4, 2021 · 3 comments

Comments

@TomasHubelbauer
Copy link

TomasHubelbauer commented Mar 4, 2021

Hi! I just read Caxa's readme, haven't tried the project yet, but if I'm not mistaken, I think Caxa might be the only Node packaging system capable of natively supporting ESM and import.meta! At least that's what I think based on reading the readme section about how it works.

Of course any packer can support ESM and import.meta when using a bundler before packing, so here I was only looking at native support.

I'm sharing this because I think you might want to add it to the Features section, as another selling point. If Caxa truly does support this, it's amazing news for packing vanilla Node projects using ESM.

@MichaelKorn
Copy link

MichaelKorn commented Mar 7, 2021

@leafac, first of all thank you very much!
Since this package is very new and I feel like a beta tester, I would like to use this post for feedback.
I evaluated caxa in an application with the following runtime dependencies: chalk,console-table-printer,csv-parse,csv-stringify,iconv-lite,msnodesqlv8,mssql,select-shell,tmp,uuid,winston,yargs

Pros:

  • ESM works
  • binary files are embedded (Ms SQL driver, msnodesqlv8\build\Release\sqlserverv8.node)
  • can read/write files in working directory without adjustments of my code
  • with a workaround I can set node.exe flags and read the package.json (see commander package tries to use additional flags #5)
  • Size of .exe is only 33.4 MB (pkg exe has 90 MB + 1.7MB for sqlserverv8.node)

Contra

  • The entire directory is simply packed (e.g. also the .git folder). I will have to create a "release" folder. It would be better if I could specify (similar to pkg) what should (not) be included in the exe. In my case it would be just 3 folders with the entire content + package.json.
  • For me caxa builds slower than pkg. Caxa needs 44 seconds, pkg only 12.5 seconds (+ 2.5 seconds for babel because pkg does not support ESM)

@leafac
Copy link
Owner

leafac commented Mar 16, 2021

@TomasHubelbauer: 👍 ESM works. Thanks for mentioning it—I’ll add to the README. As far as I understand boxednode wouldn’t work either, because it support only a single file—you have to bundle the application before packaging.

Given caxa simple yet powerful architecture of a self-extracting archive, I expect that anything you can do when calling node will work after you package the project with caxa: ESM, fs/promises (which was a problem with pkg before I patched it), and anything that comes out in future Node.js versions!

@MichaelKorn: Thank you very much for the feedback! Let me address the contras:

  • The entire directory is simply packed (e.g. also the .git folder). I will have to create a "release" folder. It would be better if I could specify (similar to pkg) what should (not) be included in the exe. In my case it would be just 3 folders with the entire content + package.json.

I’ll add an option to let you exclude paths from the build. I’m building on GitHub Actions (see https://github.com/leafac/kill-the-newsletter/blob/94d3185fde30f233759f8a5ee31528a37289a1a3/.github/workflows/main.yml and https://github.com/courselore/courselore/blob/cb1c20c618a41827190c55622d698401e2eaac8f/.github/workflows/main.yml), which does shallow clones, so this wasn’t something I was worried about initially.

I’ll get back to you when this ships.

  • For me caxa builds slower than pkg. Caxa needs 44 seconds, pkg only 12.5 seconds (+ 2.5 seconds for babel because pkg does not support ESM)

I’ve noticed that too, and I’m working on a few ways to improve on this. First, excluding paths from the build as mentioned above should help speed things up. Also, other compression algorithms should have an impact here. We’ll see…

@leafac
Copy link
Owner

leafac commented Jan 18, 2022

@TomasHubelbauer: Thanks for tidying things up here by closing the issue.

@MichaelKorn: Version 2.0.0 includes the feature you mentioned of being able to exclude directories from the build.

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

3 participants