🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

lazy-cache-cli

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-cache-cli

Super basic CLI for adding a `utils.js` file for adding lazy-cache to a project.

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

lazy-cache-cli NPM version

Super basic CLI for adding a utils.js file for adding lazy-cache to a project.

Install

Install globally with npm

$ npm i -g lazy-cache-cli

CLI

$ lazy

Running the lazy command will do two things:

  • Add utils.js with var utils = require('lazy-cache')(require); and a list of dependencies from package.json
  • Add the utils.js filepath to the files property in package.json

Options

  • -f | --file: Optionally specify a filename to use for the created file. The default is utils.js
$ lazy -f foo.js

About

For those who can't sleep and/or would rather read this than do virtually anything else that would be fun and not this.

What's lazy-caching?

lazy-caching offers the huge advantage of only loading modules that are actually called at some point in the lifecycle of the application.

Why does this project exist?

I made this for two reasons:

  • I keep forgetting to add utils.js to package.json, so this is my crutch.
  • I myself am lazy. This lets me do less work.

What is this project?

This is a CLI for adding lazy-cache to your project. You don't need a CLI for that really, since you can just require it in and start using it. But I like to add lazily-required module dependencies to utils.js file.

Why do you add lazy-cached deps to utils.js?

The short version: I view this tiny bit of ugliness as a tradeoff.

You're saying that you'll make my application faster whilst also allowing browserify and webpack to find dependencies, and all I need to do is add utils.js with some ugly code and temporary re-assignment of require? Sold. Where do I sign?

TLDR: I like to use temporary re-assignment of the require function to trick browserfy and webpack into finding lazily-required module dependencies that - despite being needed by the project - might never actually be called (depending on how the application is used or the options passed by the user, etc). Thus, browserify would not otherwise discover these lazy dependencies while instrumenting the code.

Similar projects or projects you might find interesting based on this one.

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on October 20, 2015.

Keywords

cache

FAQs

Package last updated on 20 Oct 2015

Did you know?

Socket

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.

Install

Related posts