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

bunbun

v3.0.3

Published

Node.JS based simple, lightweight task bunner... I mean runner\*

Downloads

4

Readme

bunbun

Node.JS based simple, lightweight task bunner... I mean runner

Why?

Lightweight and very fast - very simple in design, without any library compilers that you will never use, just plain task runner

📐 Ready to use - just add to your project, create file and prepare your first task

🔌 Extendable - "extends-by-code" philosophy - you are owner of your build flow, without any magic and invisible parts/configurations etc., neither no compilers included

Universal - this library contains only language/tool/framework agnostic tools, all compilations/copying things are in your hands

🎈 Without magic - all of your tasks are just JS code, without any configs, 3rd-party plugins etc. just plain source code, therefore the learning curve is very low

🐞 Debuggable - debugging is very simple because none of all tasks are done invisibly underhood, it's easy to find erroring part if you see all steps of build process, also you can enable debugging mode in Bunbun to log all things

🧰 Safe versioning - version of Bunbun will never break any of building processes because Bunbun don't conains any API for them, updating Bunbun will need from you only update your building script - it's all, you will never have to wait for a some plugin to be updated

Requirements

  • Node.JS >= 7.6v
    • ...because of default support of async/await syntax
  • or Node.JS >= 10v
    • ...for execution and handling processes
  • NPM

How to install?

Simplest way is just using npm:

npm install --save-exact --save-dev bunbun

Real example

Example code:

const { build } = require('esbuild');
const nodeSass = require('node-sass');
const Bunbun = require('./../dist/main.js');

const sass = args => new Promise((res, rej) => {
    nodeSass.render(args, (err, data) => {
        err ? rej(err) : res(data);
    });
});

const hash = async file => {
    const res = await $.fs.hash(file, 'md5', 'base64');
    return res.replace(/[^a-z0-9]/gi, '');
};

const SOURCE_EXTS = '(scss|ts|tsx|js|jsx|html)';

const $ = new Bunbun;

$.task('build:typescript', async () => {
    await $.until('hash');
    await build({
        sourcemap: true,
        format: 'iife',
        minify: true,
        bundle: true,
        outfile: './build/index.js',
        entryPoints: ['./src/index.tsx'],
        platform: 'browser',
        tsconfig: './tsconfig.json',
        define: {
            'process.env.NODE_ENV': '"develop"',
        },
    });
    $.run('hash');
});

$.task('build:scss', async () => {
    await $.until('hash');
    const result = await sass({
        file: './src/index.scss',
        sourceMap: './index.css.map',
        outFile: './index.css',
        outputStyle: 'compressed',
        sourceMapContents: true,
    });
    await $.fs.write('./build/index.css', result.css || '');
    await $.fs.write('./build/index.css.map', result.map || '');
    $.run('hash');
});

$.task('hash', async () => {
    await $.fs.edit('./src/index.html', async html => {
        const jsHash = await hash('./build/index.js');
        const cssHash = await hash('./build/index.css');
        return html
            .replace('__JS_HASH__', jsHash)
            .replace('__CSS_HASH__', cssHash);
    });
});

$.alias('build', ['build:typescript', 'build:scss']);

$.task('assets', async () => {
    let list = await $.fs.list(['./src/**/*.*', `!**/*.${SOURCE_EXTS}`]);
    for (const x of list) {
        await $.fs.copy(x, x.replace(/^\.\/src/, './build'));
    }
});

$.task('watch', async () => {
    const server = $.serve('./build', 8080);

    $.fs.watch(`./src/**/*.${SOURCE_EXTS}`, async () => {
        await $.run('build');
        server.reload();
    });

    $.fs.watch(`./src/**/*.!${SOURCE_EXTS}`, async () => {
        await $.run('assets');
        server.reload();
    });
});

$.start('build');

Table of Contents