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

@aspiesoft/miniforge-js

v1.2.2

Published

Minify and Forge your node.js files for production.

Downloads

30

Readme

MiniforgeJS

npm Libraries.io dependency status for latest release GitHub top language NPM

npm npm

paypal

Minify and Forge your node.js files for production.

  • Tracks down local required files, and adds them to the parent file as a self running function.

  • Minifies each file individually, and then as a whole.

  • Allows your file to run standalone, and not depend on miniforge-js to run.

Optional:

  • Compresses the file, and decompress it at runtime
  • Encrypts the file, and decrypts it at runtime

This module Never uses eval. Instead, the file is pushed into the nodejs module object, as a way to run the file as a string after decompression. This is generating a virtual file, so no file writes are needed at runtime.

This module runs a minified version of itself, minified using miniforge-js. (self minified)

What's New

  • Added zlib compression
  • Top level comments now stay with compressed file
  • Added option to avoid dependencies on file compression

Installation

npm install @aspiesoft/miniforge-js

# or install as a dev dependency
npm install @aspiesoft/miniforge-js -D

# or install global for cli
npm install @aspiesoft/miniforge-js -g

Setup

const miniforge = require('@aspiesoft/miniforge-js');

// optional
miniforge.rootDir(__dirname);

Usage

miniforge.build('./app.js', {/* options */});
// output creates file: app.build.js

miniforge.build('./app.js', {encrypt: true});
// output will also create key file: app.build.keys

// running files
const app = require('./app.build.js');

// in some cases (depending on options), you may have to require the file with this module
const app = miniforge('./app.build.js', true||false/*optional (default: false) (if true, will avoid throwing errors on fail*/);

// you could also change the var name if you want
const requireMini = require('miniforge-js');

const app = requireMini('./app.build.js');

This module uses the terser module for magnifying

This module sets some of its own defaults for terser, but you can change its options if you want. You can find terser options here

miniforge.build('./app.js', {minify: {/* terser minify options */}});

Options

// with defaults (the first string ('./app.js') has no default and is required)
miniforge.build('./app.js', {
    encrypt: false, /* encrypt the files code */
    compress: true, /* true for default (currently zlib) || 'lzutf8' for old lzutf8 method || false to disable */
    standAlone: true, /* allow the file to run without miniforge-js as a dependency */
    avoidDependencies: true, /* avoid requiring external dependencies for compressed files */
    minify: {}, /* set minify options for the terser module */
    outputNameMin: false, /* will write output to "filename.min.js" instead of "filename.build.js" (will also use min.keys instead of build.keys) */
    output: undefined, /* (type: string) optional path to an output file to use instead of the default path */
    root: undefined, /* (type: string) set the root dir for build (can replace miniforge.rootDir(__dirname); for build, but its still required for miniforge('./app.js'); function to run) */
});

CLI

You can use cli scripts as shown

# for a list of commands
miniforge-js -h

Note: if encrypt or compress are used, and standAlone is false, you will need to use miniforge('./app.js'); method to require the file.

If standAlone, the file (when ran/imported) will warn the user what modules (if not installed) are needed to run it.