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

@strapi/pack-up

v5.0.2

Published

Simple tools for creating interoperable CJS & ESM packages.

Downloads

400,430

Readme

pack-up is a set of simple tools for creating interoperable CJS & ESM packages.

Setting up a new interoperable project is as easy as doing:

npx @strapi/pack-up@latest init my-package

cd my-package

npm run build

Just a small bit about us:

  • Vite: We support vite as a JS bundler, no need to install it though as it's preprepared with helpful defaults ready to tackle all projects.
  • Concise: It's all based off your package.json so you know the interoperable aspect is correctly set up and there's no requirement for another config!
  • Flexible: Need more customisation or to bundle a package not declared in your exports? Use the config file to dictate separate bundles & options.

Getting Started

If you're setting up a brand new package we recommend you use the init command to get started:

npx @strapi/pack-up@latest init my-package

But if you're adding this to an existing project then just install like every other dependency:

npm install @strapi/pack-up@latest --save-dev

And to help you ensure your package is set up correctly run the check command:

npm run pack-up check

Run pack-up -h for more information on CLI usage.

Commands

init [path]

Creates a new package at the given path, by default uses the inbuilt template sensible options for your package to choose from.

  • --template [path] – path to a custom template of type TemplateOrTemplateResolver.

build

Builds your current package based on the configuration in your package.json and packup.config.ts (if applicable).

  • --minify – minifies the output (default false).
  • --sourcemap – generates sourcemaps for the output (default true).

check

Checks your current package to ensure it's interoperable in the real world. In short, validates the files in your dist have been produced as we expect & then esbuild can actually build, using your exported code.

watch

Watches your current package for changes and rebuilds when necessary.

Configuration

@strapi/pack-up by default reads its configuration from your package.json. But sometimes you need more flexibility, to do this you can create a packup.config.ts file in the root of your package.

// packup.config.ts
import { defineConfig } from '@strapi/pack-up';

export default defineConfig({
  minify: true,
  sourcemap: false,
  externals: ['path', 'fs'],
});

Options

bundles

  • Type: ConfigBundle[]

An array of entry points to bundle. This is useful if you want to bundle something that should not be exported by the package, e.g. CLI scripts or Node.js workers.

dist

  • Type: string

The path to the directory to which the bundled files should be written.

exports

  • Type: Record<string, Export>

Overwrite or amend the parsed exports from your package.json.

externals

  • Type: string[]

An array of modules that should not be bundled but instead be resolved at runtime, this is by default the dependencies listed in your package.json (excluding devDeps).

minify

  • Type: boolean

Whether to minify the output or not.

plugins

  • Type: PluginOption[] | (({ runtime }: { runtime: Runtime }) => PluginOption[]);

An array of Vite plugins to use when bundling, or optionally a function that returns an array of plugins based on the runtime.

preserveModules

  • Type: boolean

Instead of creating as few chunks as possible, this mode will create separate chunks for all modules using the original module names as file names.

sourcemap

  • Type: boolean

Whether to generate sourcemaps for the output or not.

runtime

  • Type: Runtime

The transpilation target of the bundle. This is useful if you're bundling many different CLIs or Node.js workers and you want them to be transpiled for the node environment.

tsconfig

  • Type: string

Path to the tsconfig file to use for the bundle, defaults to tsconfig.build.json.