{"id":14965921,"url":"https://github.com/elbywan/zap","last_synced_at":"2025-04-09T09:04:13.627Z","repository":{"id":108157522,"uuid":"562595348","full_name":"elbywan/zap","owner":"elbywan","description":"Another [insert blazing fast synonyms] JavaScript package manager ","archived":false,"fork":false,"pushed_at":"2025-02-10T08:21:14.000Z","size":16254,"stargazers_count":56,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T07:53:34.474Z","etag":null,"topics":["crystal","javascript","npm","package-manager","pnpm","yarn"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elbywan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-06T20:24:08.000Z","updated_at":"2025-03-16T21:07:57.000Z","dependencies_parsed_at":"2023-06-03T17:30:36.582Z","dependency_job_id":"82f0f5f5-fe38-4fde-93de-1e309bd5b97a","html_url":"https://github.com/elbywan/zap","commit_stats":{"total_commits":372,"total_committers":2,"mean_commits":186.0,"dds":0.005376344086021501,"last_synced_commit":"62050866f4e140fe97bd466cfbaf16cfc626c8fb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fzap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fzap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fzap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fzap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elbywan","download_url":"https://codeload.github.com/elbywan/zap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008628,"owners_count":21032556,"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":["crystal","javascript","npm","package-manager","pnpm","yarn"],"created_at":"2024-09-24T13:35:34.315Z","updated_at":"2025-04-09T09:04:13.608Z","avatar_url":"https://github.com/elbywan.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"assets/zap.png\" width=\"128\" height=\"128\" /\u003e\n  \u003ch6\u003e\u003ci\u003e\u003ca href=\"https://www.flaticon.com/free-icons/comic\" title=\"logo\"\u003eLogo created by Freepik - Flaticon\u003c/a\u003e\u003c/i\u003e\u003c/h6\u003e\n  \u003ch3\u003eAnother [insert blazing fast synonyms] JavaScript package manager\u003c/h3\u003e\n  \u003ca href=\"https://github.com/elbywan/zap/actions/workflows/build.yml?query=branch%3Amain+workflow%3ABuild\"\u003e\u003cimg alt=\"Build Status\" src=\"https://github.com/elbywan/zap/actions/workflows/build.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@zap.org/zap\"\u003e\u003cimg alt=\"GitHub tag (latest SemVer)\" src=\"https://img.shields.io/npm/v/@zap.org/zap\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/elbywan/zap/blob/main/LICENSE\"\u003e\u003cimg alt=\"GitHub\" src=\"https://img.shields.io/github/license/elbywan/zap\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n![demo](assets/demo.gif)\n\n**`Zap` is a JavaScript package manager _(think npm/pnpm/yarn)_ that aims to be quick, reliable, memory efficient and developer friendly.**\n\n\u003c/div\u003e\n\n---\n\n### Disclaimer\n\nZap is a **hobby** project that I am currently working on in my free time. Documentation is sparse, Windows support is partial at best and the code is not yet ready for production.\n\nI am not looking for contributors at the moment, but feel free to open an issue if you have any question or suggestion.\n\n\u003e [!WARNING]\n\u003e **Use it at your own risk.**\n\n## Installation\n\n```bash\nnpm i -g @zap.org/zap\nzap --help\n```\n\n## Commands\n\n| Command       | Aliases               | Description                                            | Status  |\n| ------------- | --------------------- | ------------------------------------------------------ | ------- |\n| `zap install` | `i` `add`             | Install dependencies                                   | ✅       |\n| `zap remove`  | `rm` `uninstall` `un` | Remove dependencies                                    | ✅       |\n| `zap init`    | `create`              | Create a new project or initialize a package.json file | ✅       |\n| `zap dlx`     | `x`                   | Execute a command in a temporary environment           | ✅       |\n| `zap store`   | `s`                   | Manage the store                                       | ✅       |\n| `zap run`     | `r`                   | Run a script defined in package.json                   | ✅       |\n| `zap rebuild` | `rb`                  | Rebuild installed native node addons                   | ✅       |\n| `zap exec`    | `e`                   | Execute a shell command in the scope of the project    | ✅       |\n| `zap update`  | `up` `upgrade`        | Update the lockfile with the newest package versions   | ⏳ _WIP_ |\n| `zap why`     | `y`                   | Show information about why a package is installed      | ✅       |\n\n#### Check the [project board](https://github.com/users/elbywan/projects/1/views/1) for the current status of the project.\n\n## Features\n\nHere is a non exhaustive list of features that are currently implemented:\n\n- **Classic (~npm), isolated (~pnpm) or plug'n'play (~yarn) install strategies**\n\n```bash\n# Classic install by default\nzap i # or zap i --classic\n# Isolated install\nzap i --isolated\n# Plug'n'play (experimental - no zero-installs yet)\nzap i --pnp\n```\n\n_or:_\n\n```json\n\"zap\": {\n  \"strategy\": \"isolated\",\n  \"hoist_patterns\": [\n    \"react*\"\n  ],\n  \"public_hoist_patterns\": [\n    \"*eslint*\", \"*prettier*\"\n  ]\n}\n// package.json\n```\n\n- **[Workspaces](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true#defining-workspaces)**\n\n```json\n\"workspaces\": [\n  \"core/*\",\n  \"packages/*\"\n]\n// package.json\n```\n\n_or to prevent hoisting:_\n\n```json\n\"workspaces\": {\n  \"packages\": [\n    \"packages/**\"\n  ],\n  \"nohoist\": [\n    \"react\",\n    \"react-dom\",\n    \"*babel*\"\n  ]\n}\n// package.json\n```\n\n```bash\n# Install all workspaces\nzap i\n# Using pnpm-flavored filters (see: https://pnpm.io/filtering)\nzap i -F \"./libs/**\" -F ...@my/package...[origin/develop]\nzap i -w add pkg\n\n## Scripts can be scoped too\n\n# Run a single script in the current workspace.\nzap run my-script\n# Run scripts in all workspaces in parallel.\n# Will use topological ordering by default - dependencies will run first…\nzap -r run test\n# …or omit the \"run\" argument.\nzap -r test\n# Scope to the dependencies of a specific workspace, and pack the output.\nzap -F \"my_app^...\" --deferred-output run build\n# Disregard the topological ordering and run the scripts in parallel.\nzap run --parallel -r build\n```\n\n- **[Private registries](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc#auth-related-configuration)**\n\n```ini\n; .npmrc file\n\n; default registry:\nregistry=https://registry.yarnpkg.com/\n; scoped registries:\n@myorg:registry=https://somewhere-else.com/myorg\n@another:registry=https://somewhere-else.com/another\n; scoped authentication: (supported fields -\u003e _auth, _authToken, certfile, keyfile)\n//registry.org/:_auth=BASICAUTHTOKEN\n//registry.npmjs.org/:_authToken=BEARERTOKEN\n; disable strict ssl peers checking: (default is true)\nstrict_ssl=false\n; use a custom certificate authority file:\ncafile=/certs/rootCA.crt\n```\n\n- **[Overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json?v=true#overrides) / [Package Extensions](https://pnpm.io/package_json#pnpmpackageextensions)**\n\n```json\n\"overrides\": {\n  \"foo\": {\n    \".\": \"1.0.0\",\n    \"bar\": \"1.0.0\"\n  }\n},\n\"zap\": {\n  \"package_extensions\": {\n    \"react-redux@1\": {\n      \"peerDependencies\": {\n        \"react-dom\": \"*\"\n      }\n    }\n  }\n}\n// package.json\n```\n\n- **[Aliases](https://github.com/npm/rfcs/blob/main/implemented/0001-package-aliases.md)**\n\n```bash\nzap i my-react@npm:react\nzap i jquery2@npm:jquery@2\nzap i jquery3@npm:jquery@3\n```\n\n# Benchmarks\n\n### a.k.a is it fast?\n\n## Methodology\n\nBenchmarks consist on installing a fresh [**create-react-app**](https://create-react-app.dev/) in various scenarii, with postinstall scripts disabled.\n\n**See:** [https://github.com/elbywan/zap/tree/main/bench](/bench)\n\nThey are performed on my own personal laptop (macbook pro 16\" 2019, 2,3 GHz Intel Core i9, 16 Go 2667 MHz DDR4) with 5G wifi and 1 Gb/s fiber.\n\nThe benchmarking tool is [**hyperfine**](https://github.com/sharkdp/hyperfine) and to make sure that the results are consistent I re-ran unfavorable results (high error delta).\n\nI am aware that this is not a very scientific approach, but it should give rough good idea about what zap is capable of.\n\n## Results\n\n![cold](bench/cold.png)\n![only-cache](bench/only-cache.png)\n![without-lockfile](bench/without-lockfile.png)\n![without-node-modules](bench/without-node-modules.png)\n\n## Why?\n\n**This is a legitimate question.** There are already a lot of package managers out there, and they all have their own pros and cons. So why another one?\n\nFirst, I thought that it would be a good and fun challenge to build a package manager from scratch. I also really like the [Crystal language](https://crystal-lang.org/) and I have been using it for a couple of years now. So it would be a good opportunity to put my knowledge to the test.\n\nI also experimented with a lot of package managers over the years, and I have a few praise and gripes with the existing ones:\n\n- [npm](https://www.npmjs.com/) is the de facto standard for JavaScript package management. It is reliable and has a huge community. But it is also super slow and lack features introduced by other package managers over time even though it is trying to catch up.\n\n- [yarn](https://yarnpkg.com/) is a great alternative to npm, it was a pioneer initially in terms of speed and it introduced many improvements and innovations along the years. Yarn is also impressively reliable which is paramount. I never used yarn berry in a significant project but the PnP approach is very interesting - unfortunately the downside is that does not seem to be compatible out of the box with a lot of packages from the ecosystem.\n\n- [pnpm](https://pnpm.io/) is an impressive package manager which introduced the concept of isolated installs. It handles workspaces very well with a lot of options to customize the behavior. Speed is mostly fine even with big monorepos. I experienced some reliability issues using it over the years though (peer dependencies handling, lockfile inconsistencies, very high memory consumption, need to manually delete the node modules folder…).\n\n- [bun](https://bun.sh/) was a great source of inspiration for this project, but it comes with tradeoffs. While tremendously fast, it did not support some critical features when I started working on zap (and it still is very feature-limited), cannot be considered reliable as of today and is not as flexible as I would like it to be.\n\n- newer contenders ([orogene](https://github.com/orogene/orogene), [cotton](https://github.com/danielhuang/cotton), [ultra](https://github.com/nachoaldamav/ultra)…) are kind of interesting but they are clearly lacking in terms of features and/or reliability and/or speed.\n\n#### So I decided to build a package manager that would be fast, flexible and easy to use. For my own personal use, but also for the community (in the long run).\n\n### How?\n\nZap is written in [Crystal](https://crystal-lang.org/) which is a compiled language, which means that it should be faster than JavaScript. It can easily tap into system calls and use the fastest ones depending on the platform (_for instance [clonefile](https://www.manpagez.com/man/2/clonefile/)_). It is also an excellent fit when dealing with concurrent tasks.\n\nCrystal also has _experimental_ support for parallelism and can dispatch fibers to a pool of worker threads, which means that zap can take advantage of multiple cores. This is especially useful when dealing with CPU-bound tasks.\n\nOn top of that, zap will also try to cache package manifests in order to avoid unnecessary network calls in a performant way using [messagepack](https://msgpack.org/).\n\n## Development\n\n### Prerequisites\n\n- [Install crystal](https://crystal-lang.org/install/)\n- _(optional)_ Install the [vscode extension](https://marketplace.visualstudio.com/items?itemName=crystal-lang-tools.crystal-lang) and [crystalline](https://github.com/elbywan/crystalline)\n\n### Setup\n\n```bash\ngit clone https://github.com/elbywan/zap\nshards install\n# Run the specs\ncrystal spec\n# Build locally (-Dpreview_mt might not work on some os/arch)\nshards build --progress -Dpreview_mt --release\n```\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/elbywan/zap/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Julien Elbaz](https://github.com/your-github-user) - creator and maintainer\n\n## Related\n\n- [pnpm](https://pnpm.io/)\n- [bun](https://bun.sh/)\n- [npm](https://www.npmjs.com/)\n- [yarn](https://yarnpkg.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbywan%2Fzap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felbywan%2Fzap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbywan%2Fzap/lists"}