{"id":29482866,"url":"https://github.com/Ray-D-Song/lexe","last_synced_at":"2025-07-15T02:02:35.342Z","repository":{"id":287184242,"uuid":"963206676","full_name":"Ray-D-Song/lexe","owner":"Ray-D-Song","description":"Package your Node.js application into a single executable file, but only 10MB.🔥","archived":false,"fork":false,"pushed_at":"2025-04-16T06:34:43.000Z","size":5483,"stargazers_count":578,"open_issues_count":10,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-14T17:32:10.870Z","etag":null,"topics":["executable","javascript","nodejs","quickjs"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ray-D-Song.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-09T10:19:20.000Z","updated_at":"2025-07-11T18:42:39.000Z","dependencies_parsed_at":"2025-04-10T12:40:35.675Z","dependency_job_id":null,"html_url":"https://github.com/Ray-D-Song/lexe","commit_stats":null,"previous_names":["ray-d-song/lexe_core","ray-d-song/lexe"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ray-D-Song/lexe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ray-D-Song%2Flexe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ray-D-Song%2Flexe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ray-D-Song%2Flexe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ray-D-Song%2Flexe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ray-D-Song","download_url":"https://codeload.github.com/Ray-D-Song/lexe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ray-D-Song%2Flexe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265386079,"owners_count":23756747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["executable","javascript","nodejs","quickjs"],"created_at":"2025-07-15T02:01:59.005Z","updated_at":"2025-07-15T02:02:35.334Z","avatar_url":"https://github.com/Ray-D-Song.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Lexe\n[中文文档](README-zh.md)\n\nLexe is a fork of AWS's lightweight JavaScript runtime \"LLRT\".  \nYou can use it to package your Node.js applications into a single executable file, but the size is only 8~10MB.\n\n![Size comparison](./benchmarks/size.png)\n\n```bash\nnpx lexe build -i=index.js\n\nnpx lexe build -i=index.js -o=binary -d=dist -p=linux-x64,windows-x64\n```\n\nOptions:\n- `-i`: input file(required)\n- `-o`: output file(optional, default: `\u003cinput file name\u003e-\u003cplatform\u003e`)\n- `-d`: output directory(optional, default: `./dist`)\n- `-p`: target platform, use \",\" to separate multiple platforms\n  options: linux-x64,linux-arm64,darwin-x64,darwin-arm64,windows-x64\n  (optional, default: current platform)\n\n\u003e [!IMPORTANT]\n\u003e Lexe(or LLRT) currently does not support the complete http and https modules, but implements `fetch` for requests and `net` for low-level network services.  \n\u003e In the LLRT team's ROADMAP, http and https modules are a [2025 goal](https://github.com/awslabs/llrt/issues/635)  \n\u003e So I currently do not recommend using Lexe to build HTTP services, but to create CLI tools  \n\n\u003e [!WARNING]\n\u003e Lexe is not a drop-in replacement for Node.js. It only supports a subset of Node.js APIs.  \n\u003e You can read more about LLRT in [LLRT README](https://github.com/awslabs/llrt)  \n\u003e Since Lexe is a fork of LLRT, the following document is basically a copy of LLRT\n\n## Compatibility matrix\n\n| Modules        | Node.js | LLRT ⚠️ |\n| -------------- | ------- | ------- |\n| assert         | ✔︎     | ✔︎️    |\n| buffer         | ✔︎     | ✔︎️    |\n| child_process  | ✔︎     | ✔︎⏱   |\n| console        | ✔︎     | ✔︎     |\n| crypto         | ✔︎     | ✔︎     |\n| dns            | ✔︎     | ✔︎     |\n| events         | ✔︎     | ✔︎     |\n| fs/promises    | ✔︎     | ✔︎     |\n| fs             | ✔︎     | ✘⏱     |\n| http           | ✔︎     | ✘⏱\\*\\* |\n| https          | ✔︎     | ✘⏱\\*\\* |\n| net:sockets    | ✔︎     | ✔︎⏱   |\n| net:server     | ✔︎     | ✔︎     |\n| os             | ✔︎     | ✔︎     |\n| path           | ✔︎     | ✔︎     |\n| perf_hooks     | ✔︎     | ✔︎     |\n| process        | ✔︎     | ✔︎     |\n| streams        | ✔︎     | ✔︎\\*   |\n| string_decoder | ✔︎     | ✔︎     |\n| timers         | ✔︎     | ✔︎     |\n| tty            | ✔︎     | ✔︎     |\n| url            | ✔︎     | ✔︎     |\n| util           | ✔︎     | ✔︎     |\n| tls            | ✔︎     | ✘⏱     |\n| zlib           | ✔︎     | ✔︎     |\n| Other modules  | ✔︎     | ✘       |\n\n| Features    | Node.js | LLRT ⚠️ |\n| ----------- | ------- | ------- |\n| async/await | ✔︎     | ✔︎     |\n| encoding    | ✔︎     | ✔︎     |\n| fetch       | ✔︎     | ✔︎     |\n| ESM         | ✔︎     | ✔︎     |\n| CJS         | ✔︎     | ✔︎     |\n\n_⚠️ = partially supported in LLRT_\u003cbr /\u003e\n_⏱ = planned partial support_\u003cbr /\u003e\n_\\* = Not native_\u003cbr /\u003e\n_\\*\\* = Use fetch instead_\u003cbr /\u003e\n\n## Using node_modules (dependencies) with llrt\n\nSince llrt is meant for performance critical application it's not recommended to deploy `node_modules` without bundling, minification and tree-shaking.\n\nllrt can work with any bundler of your choice. Below are some configurations for popular bundlers:\n\n\u003e [!WARNING]\n\u003e LLRT implements native modules that are largely compatible with the following external packages.\n\u003e By implementing the following conversions in the bundler's alias function, your application may be faster, but we recommend that you test thoroughly as they are not fully compatible.\n\n| Node.js         | LLRT      |\n| --------------- | --------- |\n| fast-xml-parser | llrt:xml  |\n| uuid            | llrt:uuid |\n\n### ESBuild\n\n```shell\nesbuild index.js --platform=browser --target=es2023 --format=esm --bundle --minify --external:@aws-sdk --external:@smithy\n```\n\n### Rollup\n\n```javascript\nimport resolve from \"@rollup/plugin-node-resolve\";\nimport commonjs from \"@rollup/plugin-commonjs\";\nimport terser from \"@rollup/plugin-terser\";\n\nexport default {\n  input: \"index.js\",\n  output: {\n    file: \"dist/bundle.js\",\n    format: \"esm\",\n    sourcemap: true,\n    target: \"es2023\",\n  },\n  plugins: [resolve(), commonjs(), terser()],\n  external: [\"@aws-sdk\", \"@smithy\"],\n};\n```\n\n### Webpack\n\n```javascript\nimport TerserPlugin from \"terser-webpack-plugin\";\nimport nodeExternals from \"webpack-node-externals\";\n\nexport default {\n  entry: \"./index.js\",\n  output: {\n    path: \"dist\",\n    filename: \"bundle.js\",\n    libraryTarget: \"module\",\n  },\n  target: \"web\",\n  mode: \"production\",\n  resolve: {\n    extensions: [\".js\"],\n  },\n  externals: [nodeExternals(), \"@aws-sdk\", \"@smithy\"],\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new TerserPlugin({\n        terserOptions: {\n          ecma: 2023,\n        },\n      }),\n    ],\n  },\n};\n```\n## Running TypeScript with LLRT\n\nSame principle as dependencies applies when using TypeScript. TypeScript must be bundled and transpiled into ES2023 JavaScript.\n\n\u003e [!NOTE]\n\u003e LLRT will not support running TypeScript without transpilation. This is by design for performance reasons. Transpiling requires CPU and memory that adds latency and cost during execution. This can be avoided if done ahead of time during deployment.\n\n## Rationale\n\nWhat justifies the introduction of another JavaScript runtime in light of existing options such as [Node.js](https://nodejs.org/en), [Bun](https://bun.sh) \u0026 [Deno](https://deno.com/)?\n\nNode.js, Bun, and Deno represent highly proficient JavaScript runtimes. However, they are designed with general-purpose applications in mind. These runtimes were not specifically tailored for the demands of a Serverless environment, characterized by short-lived runtime instances. They each depend on a ([Just-In-Time compiler (JIT)](https://en.wikipedia.org/wiki/Just-in-time_compilation) for dynamic code compilation and optimization during execution. While JIT compilation offers substantial long-term performance advantages, it carries a computational and memory overhead.\n\nIn contrast, LLRT distinguishes itself by not incorporating a JIT compiler, a strategic decision that yields two significant advantages:\n\nA) JIT compilation is a notably sophisticated technological component, introducing increased system complexity and contributing substantially to the runtime's overall size.\n\nB) Without the JIT overhead, LLRT conserves both CPU and memory resources that can be more efficiently allocated to code execution tasks, thereby reducing application startup times.\n\n## Limitations\n\nThere are many cases where LLRT shows notable performance drawbacks compared with JIT-powered runtimes, such as large data processing, Monte Carlo simulations or performing tasks with hundreds of thousands or millions of iterations. LLRT is most effective when applied to smaller Serverless functions dedicated to tasks such as data transformation, real time processing, AWS service integrations, authorization, validation etc. It is designed to complement existing components rather than serve as a comprehensive replacement for everything. Notably, given its supported APIs are based on Node.js specification, transitioning back to alternative solutions requires minimal code adjustments.\n\n## Environment Variables\n\n### `LLRT_EXTRA_CA_CERTS=file`\n\nLoad extra certificate authorities from a PEM encoded file\n\n### `LLRT_GC_THRESHOLD_MB=value`\n\nSet a memory threshold in MB for garbage collection. Default threshold is 20MB\n\n### `LLRT_HTTP_VERSION=value`\n\nExtends the HTTP request version. By default, only HTTP/1.1 is enabled. Specifying '2' will enable HTTP/1.1 and HTTP/2.\n\n### `LLRT_LOG=[target][=][level][,...]`\n\nFilter the log output by target module, level, or both (using `=`). Log levels are case-insensitive and will also enable any higher priority logs.\n\nLog levels in descending priority order:\n\n- `Error`\n- `Warn | Warning`\n- `Info`\n- `Debug`\n- `Trace`\n\nExample filters:\n\n- `warn` will enable all warning and error logs\n- `llrt_core::vm=trace` will enable all logs in the `llrt_core::vm` module\n- `warn,llrt_core::vm=trace` will enable all logs in the `llrt_core::vm` module and all warning and error logs in other modules\n\n### `LLRT_NET_ALLOW=\"host[ ...]\"`\n\nSpace-delimited list of hosts or socket paths which should be allowed for network connections. Network connections will be denied for any host or socket path missing from this list. Set an empty list to deny all connections\n\n### `LLRT_NET_DENY=\"host[ ...]\"`\n\nSpace-delimited list of hosts or socket paths which should be denied for network connections\n\n### `LLRT_NET_POOL_IDLE_TIMEOUT=value`\n\nSet a timeout in seconds for idle sockets being kept-alive. Default timeout is 15 seconds\n\n### `LLRT_PLATFORM=value`\n\nUsed to explicitly specify a preferred platform for the Node.js package resolver. The default is `browser`. If `node` is specified, \"node\" takes precedence in the search path. If a value other than `browser` or `node` is specified, it will behave as if \"browser\" was specified.\n\n### `LLRT_TLS_VERSION=value`\n\nSet the TLS version to be used for network connections. By default only TLS 1.2 is enabled. TLS 1.3 can also be enabled by setting this variable to `1.3`\n\n## Benchmark Methodology\n\nAlthough Init Duration [reported by Lambda](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html) is commonly used to understand cold start impact on overall request latency, this metric does not include the time needed to copy code into the Lambda sandbox.\n\nThe technical definition of Init Duration ([source](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-logging.html#node-logging-output)):\n\n\u003e For the first request served, the amount of time it took the runtime to load the function and run code outside of the handler method.\n\nMeasuring round-trip request duration provides a more complete picture of user facing cold-start latency.\n\nLambda invocation results (λ-labeled row) report the sum total of Init Duration + Function Duration.\n\n## License\n\nThis library is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRay-D-Song%2Flexe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRay-D-Song%2Flexe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRay-D-Song%2Flexe/lists"}