@energypatrikhu/node-exe-compile

1.0.0 • Public • Published

node-exe-compile

node-exe-compile is a small config based wrapper for @yao-pkg/pkg (fork of vercel's pkg package)

it is using esbuild to minify and bundle the script specified in the config file, then using pkg it compiles to an exe file

Warning

This package is not well tested, and may not work as expected, use at your own risk, the package was tested on Windows and Linux, but may not work on other platforms

Usage

  1. Install the package

    npm install -D @energypatrikhu/node-exe-compile
    
  2. Add the following scripts to your package.json

    {
      "scripts": {
        "compile": "node-exe-compile"
      }
    }
  3. Start the script

    this creates an example configuration file, that later can be modified to set the compiled name and others..

    npm run compile
    
  4. After that is done, you have to start node-exe-compile again

    now the script minifies and then compiles the given script to an executable

    npm run compile
    

Configuration

The generated configuration file is almost identical to the default configuration file needed for the pkg package, with a few additions

  • name: the name of the file after compiling
  • main: this is the location of the main file, commonly src/index.[ts,js]
  • bin: the path to the minified and bundled script (this most of the times does not need to be changed)
  • autoCopy: this is a boolean value, if set to true it will copy the needed files to the output directory
  • pkg: pkg options
    • targets: NodeJS version (latest == node20)
    • assets: when using packages that has .node extension the value has to be set, otherwise it may fail to start
    • outputPath: the path where the executable will be built
    • additional: this contains the additional settings for pkg
      • compress: the compression used at complile time
      • ...

Package Sidebar

Install

npm i @energypatrikhu/node-exe-compile

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

8.38 kB

Total Files

4

Last publish

Collaborators

  • energypatrikhu