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

tiss

v1.0.2

Published

A bare-bones static site generator

Downloads

126

Readme

tiss

A bare-bones static site generator

tiss will crawl through an input folder and copy files to a destination folder. If it finds any .js, .ts, .jsx, or .tsx files, it will run them and copy that output to the destination.

Get started

  1. Install tiss

    $ npm i -D tiss       # if you use npm
    $ yarn add --dev tiss # if you use yarn
  2. Create a config file if you want

  3. Copy your static files

    src
    ├── robots.txt
    └── index.html
  4. Create your dynamic handlers, they will run at build time and create a regular file in their place

    // src/latest-version.json.ts
    import { defineHandler } from "tiss";
    import pkg from "my-library/package.json" with { type: "json" };
    
    export default defineHandler(async () => ({
      LIBRARY_VERSION: pkg.version,
      NODE_VERSION: process.versions.node,
    }));
  5. Add to your scripts

    // package.json
    "scripts": {
    +  "archive": "tiss archive",
    +  "build": "tiss build",
    +  "dev": "tiss dev"
    }
  6. Run your build!

    $ npm run build  # if you use npm
    $ yarn run build # if you use yarn

Dynamic handlers

A handler is a file with a .js, .ts, .jsx, or .tsx extension (you can change this), with a default export.

The default export can be any of

  • a string
  • a Buffer, ArrayBuffer, Uint8Array, or any other typed array
  • a Node.js Readable stream
  • a JSON.stringify-able value
  • a Promise that resolves to any of the above
  • a function or an async function that returns any of the above

It will be called at build time and create a file with its result, removing the last extension (e.g. a foo/bar.txt.ts handler will create a foo/bar.txt file).

Static files

Everything else that is in the build folder and is not a dynamic handler, will be copied to the output unchanged.

CLI

$ tiss build   # builds the source and outputs to the destination folder
$ tiss dev     # runs a server with your site (not for production!)
$ tiss archive # builds the site into an zip file

Config

Everything is optional (even the config file itself), values shown are default values:

// app.config.ts
import { defineConfig } from "tiss";

// All paths are relative to the folder where the config file is

export default defineConfig({
  base: "./src", // Where the site root is

  input: {
    // All of these options accept either a glob string, an array of glob strings, a regular expression, or a (string) => boolean function.

    include: ["./**/*"], // Which files to include in the output
    exclude: [], // Which files to exclude in the output
    isDynamic: ["**/*.ts", "**/*.js", "**/*.tsx", "**/*.jsx"], // Which files to consider dynamic
  },

  dynamic: {
    transformName: internal_removeExtension, // By default, if a dynamic file is e.g. `hello.txt.ts`, it's transformed to `hello.txt`
    importer: jiti.import, // How to call the dynamic files, should return a promise of a no-arguments function. By default, we use `jiti` to be able to run TypeScript files on-the-fly.
    concurrency: 4, // How many files to be running at once
  },

  build: {
    outDir: "./public", // Where to output the built site
    clean: false, // Whether to empty the output dir before running the build
  },

  archive: {
    format: "zip", // Which archive format to use, right now only `zip` is supported
    outFile: "./archive.zip", // Where to write the archive
  },

  dev: {
    port: 2387, // The port for the server
    hostname: "localhost", // The host for the server
    indexFiles: ["index.html", "index.htm"], // Which files to use as index files for when a folder is requested (after the dynamic code is run)
  },
});