Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@sinclair/hammer
Advanced tools
$ npm install @sinclair/hammer -g
Create an index.html
file
<!DOCTYPE html>
<html>
<head>
<link href="index.css" rel="stylesheet" />
<script src="index.tsx"></script>
</head>
<body>
<img src="banner.png" />
</body>
</html>
Run Hammer
$ hammer build index.html
Done
Hammer 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.
Hammer 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.
License MIT
Use the serve
command to start a development server that reloads pages on save.
<!DOCTYPE html>
<html>
<head>
<script type="module" src="index.tsx"></script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
$ hammer serve index.html
Use the run
command to start a node process that restarts on save.
$ hammer run index.ts
$ hammer run "index.ts arg1 arg2" # use quotes to pass arguments
Use the watch
command to start a compiler watch process only.
$ hammer watch worker.ts
Use the monitor
command to execute shell commands on file change.
$ hammer monitor index.ts "deno run --allow-all index.ts"
Hammer 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.
//
// file: hammer.mjs
//
export async function start() {
await Promise.all([
shell(`hammer serve apps/website/index.html --dist dist/website`),
shell(`hammer run apps/server/index.ts --dist dist/server`)
])
}
$ hammer task start
In mono repository projects, you can import shared libraries by using TypeScript tsconfig.json
path aliasing.
/apps
/server
index.ts ───────────┐
/website │
index.html │
index.ts ───────────┤ depends on
/libs │
/shared │
index.ts <──────────┘
tsconfig.json
To enable website
and server
to import the shared
library. Configure tsconfig.json
in the project root as follows.
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@libs/shared": ["libs/shared/index.ts"],
}
}
}
Once configured the server
and website
applications can import with the following.
import { Foo } from '@libs/shared'
Hammer provides the following command line interface.
Commands:
$ hammer run <entry script> <...options>
$ hammer build <file or folder> <...options>
$ hammer watch <file or folder> <...options>
$ hammer serve <file or folder> <...options>
$ hammer monitor <file or folder> <shell command>
$ hammer task <task> <...arguments>
$ hammer version
$ hammer help
Options:
--target targets The es build targets.
--platform platform The target platform.
--dist directory The target directory.
--port port The port to listen on.
--external Omits external packages.
--esm Use esm module target.
--minify Minifies the output.
--sourcemap Generate sourcemaps.
FAQs
Build Tool for Browser and Node Applications
The npm package @sinclair/hammer receives a total of 175 weekly downloads. As such, @sinclair/hammer popularity was classified as not popular.
We found that @sinclair/hammer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.