GithubHelp home page GithubHelp logo

hhy5277 / enclose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from igorklopov/enclose

0.0 1.0 0.0 539 KB

Compile your Node.js project into an executable

Home Page: http://enclosejs.com

License: Other

JavaScript 100.00%

enclose's Introduction

This project is deprecated

Dear users of EncloseJS. I highly encourage you to switch to https://github.com/zeit/pkg.

This a rewritten successor of EncloseJS. It is open source, and all improvements will go there.


EncloseJS

Compile your Node.js project into an executable

Gitter

Hello, world!

Use cases

  • Make a commercial version of your application without sources
  • Make a demo/evaluation/trial version of your app without sources
  • Make some kind of self-extracting archive or installer
  • Make a closed source GUI application using node-thrust
  • No need to install Node.js and npm to deploy the compiled application
  • No need to download hundreds of files via npm install to deploy your application. Deploy it as a single independent file
  • Put your assets inside the executable to make it even more portable
  • Test your app against new Node.js version without installing it

Install

npm install -g enclose

Usage

Run enclose without arguments to see help.

In short, as input you specify the entry file of your project /path/app.js. As output you get a standalone executable /path/app. When it is run, it does the same as node /path/app.js

Command line of the executable

Command line call ./app a b is equivalent to node ./app.js a b

Dependencies

The compiler parses your sources, detects calls to require, traverses the dependencies of your project and includes them into the executable. You don't need to list them manually.

Assets

If your project has assets (HTML templates, CSS, etc), for example to serve via HTTP, you can bundle them into the executable. Just list them as a glob in the configuration file.

Compilation? Srsly?

Both Yes and No.

Yes. Because JavaScript code is transformed into native code at compile-time using V8 internal compiler. Hence, your sources are not required to execute the binary, and they are not packaged.

No. Optimized native code can be generated only at run-time, using information collected at run-time. Without that information EncloseJS can generate only "unoptimized" code. It runs about 2x slower, than optimized one.

Also, Node.js code is put inside the executable (along with your code) to support Node.js API for your application at run-time. This increases output file size.

So, this is not that static compilation we used to know. But nevertheless you get fully functional binary without sources. Also, performance and file size overhead are vectors of future work.

Code protection?

The code protection is as strong as possible when the sources are compiled to native code. Hackers will deal with that push-mov stuff. No need to obfuscate, no need to encrypt, no "hidden" decryption keys. Also

myfunc.toString()
function myfunc() { [native code] }

Versions of Node.js

You can choose what runtime version to wrap your project in - 0.12.x, 4.x or 6.x.

Vanilla Node.js

EncloseJS project does not aim to add new features to Node.js - to avoid undesirable issues, to have predictable stability and to make Node.js native modules compatible with enclosed executables.

Fast

It takes seconds to make an executable. You don't need to build Node.js from sources in order to make the binary. EncloseJS is shipped with precompiled parts, ready for bundling.

Compatibility with non-enclosed run

Projects like npm, browserify, eslint can be compiled using EncloseJS (see examples directory). Probably, your existing project can be compiled too, with minimal adjustments. The adjustments preserve the ability to run you project via node ./app.js

Platforms

EncloseJS can build executables for Linux, Windows and Mac OS X. Cross compilation is not currently supported, but will be supported in future.

Native modules

Native modules (.node files) are supported for all platforms (more info, serialport example, oracle example).

  • EncloseJS cannot package a native module inside the executable.
  • You have to deploy your native modules along with your final executable.
  • On Windows, native modules (built with node-gyp) require executable name to be 'node.exe'. In order to make a module compatible with your 'myserver.exe' EncloseJS makes a copy of the module, patches IAT of the copy (binds it to 'myserver.exe'), and then calls dlopen against the copy. This workaround will be deprecated soon.

License

Proprietary.

enclose's People

Contributors

igorklopov avatar root-core avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.