{"id":13672842,"url":"https://github.com/sinclairzx81/hammer","last_synced_at":"2025-04-05T07:08:19.739Z","repository":{"id":40378859,"uuid":"359069231","full_name":"sinclairzx81/hammer","owner":"sinclairzx81","description":"Build Tool for Browser and Node Applications","archived":false,"fork":false,"pushed_at":"2023-10-05T05:55:30.000Z","size":5727,"stargazers_count":237,"open_issues_count":2,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-19T11:12:19.804Z","etag":null,"topics":["bundle","esbuild","html","node","tasks","watch","workflow"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/sinclairzx81.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}},"created_at":"2021-04-18T07:00:15.000Z","updated_at":"2024-10-03T04:29:58.000Z","dependencies_parsed_at":"2024-01-17T04:18:43.324Z","dependency_job_id":null,"html_url":"https://github.com/sinclairzx81/hammer","commit_stats":{"total_commits":166,"total_committers":2,"mean_commits":83.0,"dds":"0.0060240963855421326","last_synced_commit":"a371adc8a1058dc01d7ed15b3763fe6978b93e8b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fhammer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fhammer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fhammer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fhammer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/hammer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299833,"owners_count":20916190,"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":["bundle","esbuild","html","node","tasks","watch","workflow"],"created_at":"2024-08-02T09:01:51.267Z","updated_at":"2025-04-05T07:08:19.696Z","avatar_url":"https://github.com/sinclairzx81.png","language":"TypeScript","readme":"\u003cdiv align='center'\u003e\n\n\u003ch1\u003eHammer\u003c/h1\u003e\n\n\u003cp\u003eBuild Tool for Browser and Node Applications\u003c/p\u003e\n\n[![npm version](https://badge.fury.io/js/%40sinclair%2Fhammer.svg)](https://badge.fury.io/js/%40sinclair%2Fhammer)\n\n\u003cimg src=\"doc/hammer.png\" /\u003e\n\n\u003c/div\u003e\n\n## Install\n\n```shell\n$ npm install @sinclair/hammer -g\n```\n\n## Usage\n\nCreate an `index.html` file\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003clink href=\"index.css\" rel=\"stylesheet\" /\u003e\n    \u003cscript src=\"index.tsx\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cimg src=\"banner.png\" /\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\nRun Hammer\n```shell\n$ hammer build index.html\n```\nDone\n\n## Overview\n\nHammer is a command line tool for browser and node application development. It provides a command line interface to trivially run both browser and node applications and offers appropriate `watch` and `reload` workflows for each environment. It is designed with rapid application development in mind and requires little to no configuration to use.\n\nHammer was written to consolidate several disparate tools related to monitoring node processes (nodemon), building from HTML (parcel), mono repository support (lerna, nx) and project automation (gulp, grunt). It takes `esbuild` as its only dependency and is as much concerned with build performance as it is with dramatically reducing the number of development dependencies required for modern web application development.\n\nLicense MIT\n\n## Serve\n\nUse the `serve` command to start a development server that reloads pages on save.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript type=\"module\" src=\"index.tsx\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eHello World\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n```bash\n$ hammer serve index.html\n```\n\n## Run\n\nUse the `run` command to start a node process that restarts on save.\n\n```bash\n$ hammer run index.ts\n\n$ hammer run \"index.ts arg1 arg2\" # use quotes to pass arguments\n\n$ hammer run index.mts            # node esm modules supported via .mts\n```\n\n## Watch\n\nUse the `watch` command to start a compiler watch process only.\n\n```bash\n$ hammer watch worker.ts\n```\n\n## Monitor\n\nUse the `monitor` command to execute shell commands on file change.\n\n```bash\n$ hammer monitor index.ts \"deno run --allow-all index.ts\"\n```\n\n## Tasks\n\nHammer provides a built-in task runner for automating various workflow at the command line. Tasks are created with JavaScript functions specified in a file named `hammer.mjs`. Hammer will search for the `hammer.mjs` file in the current working directory and setup a callable command line interface to each exported function. Hammer provides a global `shell(...)` function that can be used to start command line processes within each task. Additional functionality can be imported via ESM `import`. The following shows running a Hammer website and server watch process in parallel.\n\n```typescript\n//\n// file: hammer.mjs\n//\nexport async function start() {\n    await Promise.all([\n        shell(`hammer serve apps/website/index.html --dist dist/website`),\n        shell(`hammer run apps/server/index.ts --dist dist/server`)\n    ])\n}\n```\n```bash\n$ hammer task start\n```\n\n## Libs\n\nIn mono repository projects, you can import shared libraries by using TypeScript `tsconfig.json` path aliasing.\n\n```shell\n/apps\n  /server\n    index.ts    ───────────┐\n  /website                 │\n    index.html             │\n    index.ts    ───────────┤ depends on\n/libs                      │\n  /shared                  │\n    index.ts    \u003c──────────┘\ntsconfig.json\n```\nTo enable `website` and `server` to import the `shared` library. Configure `tsconfig.json` in the project root as follows.\n\n```javascript\n{\n    \"compilerOptions\": {\n        \"baseUrl\": \".\",\n        \"paths\": {\n            \"@libs/shared\": [\"libs/shared/index.ts\"],\n        }\n    }\n}\n```\n\nOnce configured the `server` and `website` applications can import with the following.\n\n```typescript\nimport { Foo } from '@libs/shared'\n```\n\n## Cli\n\nHammer provides the following command line interface.\n\n```\nCommands:\n\n   $ hammer run     \u003cscript path\u003e     \u003c...options\u003e\n   $ hammer build   \u003cfile or folder\u003e  \u003c...options\u003e\n   $ hammer watch   \u003cfile or folder\u003e  \u003c...options\u003e\n   $ hammer serve   \u003cfile or folder\u003e  \u003c...options\u003e\n   $ hammer monitor \u003cfile or folder\u003e  \u003cshell command\u003e\n   $ hammer task    \u003cname\u003e            \u003c...arguments\u003e\n   $ hammer version\n   $ hammer help\n\nOptions:\n\n   --target      targets     The es build targets.\n   --platform    platform    The target platform.\n   --dist        directory   The target directory.\n   --port        port        The port to listen on.\n   --external    packages    Omits external packages.\n   --esm                     Use esm module target.\n   --minify                  Minifies the output.\n   --sourcemap               Generate sourcemaps.\n   --sabs                    (serve) Enable shared array buffer.\n   --cors                    (serve) Enable cors.\n```\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fhammer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Fhammer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fhammer/lists"}