npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

loadr

v0.1.1

Published

Quickly attach multiple ESM Loaders and/or --require hooks together

Downloads

2,074

Readme

Features

  • Extremely lightweight
  • Easily chain multiple ESM Loaders together
  • Interleave additional --require hooks at the same time
  • Command spawns as a ChildProcess, forwarding the current process.env context

The ESM Loader API is still experimental and will change in the future.

Install

$ npm install --save-dev loadr

Example

Before

$ node --require dotenv/config \
  --experimental-loader ts-node/esm \
  --experimental-loader ./tests/loader.mjs \
  server/index.mjs

After

$ loadr -- node server/index.mjs
// loadr.mjs
export const loaders = [
  'ts-node/esm',
  './tests/loader.mjs',
]
export const registers = [
  'dotenv/config',
]

Usage

# Run `npm test` using the `loadr.mjs` configuration file
$ loadr -- npm test

# Run `npm test` using custom `loadr.custom.js` file
$ loadr -c loadr.custom.js -- npm test

# Run `node server.mjs` w/o system bell
$ loadr -q -- node server.mjs

CLI

The loadr binary expects the following usage:

$ loadr [options] -- <command>

Important: The -- is required! It separates your command from your loadr arguments.

Please run loadr --help for additional information.

Configuration

Unless specified via the -c or --config CLI arguments, loadr looks for a loadr.mjs configuration file in the current working directory – aka process.cwd().

loaders

Type: string[]

A list of files and/or modules to be added as an --experimental-loader hook.

Important: Any relative file paths will be resolved from the current working directory.

// loadr.mjs
export const loaders = [
  "ts-node/esm", // third-party module
  "./tests/loader.mjs", // local file
];

requires

Type: string[]

A list of files and/or modules to be added as a --require hook. Please note that ESM files cannot be loaded via a require() statement.

Important: Any relative file paths will be resolved from the current working directory.

// loadr.mjs
export const requires = [
  "esm", // third-party module
  "dotenv/register", // third-party module
  "./tests/setup.js", // local file
];

quiet

Type: Boolean Default: false

By default, loadr invokes the system bell when your command process terminates with a non-zero exit code.

Note: If defined, the -q or --quiet CLI argument takes precedence over the configuation file.

// loader.mjs
export const quiet = true;

License

MIT © Luke Edwards