Big news!Introducing Socket AI - ChatGPT-Powered Threat Analysis. Learn more
Socket
Log inDemoInstall

loadr

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Issues
File Explorer

Advanced tools

loadr

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

    0.1.1latest
    GitHub

Version published
Maintainers
1
Weekly downloads
754
decreased by-24.52%

Weekly downloads

Readme

Source
loadr
version downloads install size
Quickly attach multiple ESM Loaders and/or Require Hooks together
but without the repetitive `--experimental-loader` and/or `--require` Node flags

Features

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

Keywords

FAQs

Last updated on 28 Aug 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc