Node.js Compiler: compiling your Node.js application into a single executable

Node.js Compiler: compiling your Node.js application into a single executable

Node.js Compiler:将您的 Node.js 应用编译成单个可执行文件

https://github.com/pmq20/node-compiler

8002c84eb4c18170632f8fb7efb09288?s=128

Minqi Pan

March 01, 2017
Tweet

Transcript

  1. 4.
  2. 5.
  3. 8.

    Node.js Runtime? • Making sure your user used the correct

    Node.js • Could multiple Node.js versions co-exist? • Wish to use ECMAScript 2017?
  4. 10.
  5. 11.
  6. 12.
  7. 13.
  8. 14.
  9. 15.
  10. 16.
  11. 17.
  12. 19.
  13. 20.
  14. 21.
  15. 22.
  16. 23.
  17. 24.
  18. 25.
  19. 26.
  20. 27.
  21. 30.
  22. 33.
  23. 34.
  24. 35.
  25. 36.

    But there are so many API’s • require, require.resolve •

    fs.readFile, fs.readFileSync, fs.ReadStream • fs.readlink, fs.stat, fs.statSync, fs.readlinkSync • …
  26. 40.

    SquashFS • a compressed read-only file system • used by

    the Live CD versions of Arch Linux, Debian, Fedora, Gentoo, Mint, Salix, Ubuntu • used on OpenWrt and DD-WRT router firmware
  27. 42.

    SquashFS • Introduced in 2009 with Linux 2.6.29 • File

    format very stabilized • Unsquashfs and mksquashfs have win32 ports; 7-Zip on win32 also supports SquashFS • Part of kernel; GPL Licensed
  28. 44.

    https://github.com/pmq20/libsquash libsquash • MIT licensed • Super embeddable • 1

    dependency only, which could be statically linked • Compiles on 3 platforms, even Windows XP with VC++ 2010 • Introduces VFD - virtual file descriptor, intercepting system calls unobtrusively libsquash
  29. 51.
  30. 61.

    nodec is also enclosed Operating System Architecture Download Link Windows

    x86 https://sourceforge.net/projects/ node-compiler/files/v0.9.4/ nodec.exe/download macOS x86-64 https://sourceforge.net/projects/ node-compiler/files/v0.9.4/nodec- darwin-x64/download Linux x86-64 https://sourceforge.net/projects/ node-compiler/files/v0.9.4/nodec- linux-x64/download
  31. 62.

    Install on Windows • SquashFS Tools 4.3 • Python 2.6

    or 2.7 • Visual Studio 2015 Update 3, all editions including the Community edition (remember to select "Common Tools for Visual C++ 2015" feature during installation). • Then download the executable nodec.exe and run it from the VC++ or VS Command Prompt.
  32. 63.

    Install on macOS • SquashFS Tools 4.3: brew install squashfs

    • Xcode + Command Line Tools • Python 2.6 or 2.7 • GNU Make 3.81 or newer
  33. 65.

    Install on Linux • SquashFS Tools 4.3 • gcc and

    g++ 4.8 or newer, or • clang and clang++ 3.4 or newer • Python 2.6 or 2.7 • GNU Make 3.81 or newer
  34. 67.
  35. 70.
  36. 74.

    Quicker Install / Upgrade • Quicker upgrading embedded node.js applications

    / plugins • Quicker upgrading embedded node.js applications / plugins • E.g. fengdie inside the Tea IDE
  37. 75.

    Enabling Node.js Developers • Build softwares instead of modules •

    Distribute to non-technical users • Merchandise by building personal / enterprise softwares
  38. 76.

    Code Protection • Enable code signing for the entire application;

    guarantee not being altered or corrupted • Prevent hacking by users modifying exposed Javascript source code • Applicable to NW.js applications (DingTalk) and Electron applications (Tea)
  39. 77.
  40. 79.

    Use CentOS release 5.8
 with gcc and g++ 4.8
 (possibly

    from devtoolset-2 of slc5-devtoolset)