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

quickbundle

v2.6.0

Published

The zero-configuration transpiler and bundler for the web

Downloads

915

Readme

✨ Features

Quickbundle allows you to bundle a library in a quick, fast and easy way:

  • Fast build and watch mode powered by Rollup[^1] and SWC[^2].
  • Zero configuration: define the build artifacts in your package.json, and you're all set!
  • Support of cjs & esm module formats output.
  • Support of several loaders including JavaScript, TypeScript, JSX, JSON, and Images.
  • TypeScript's declaration file (.d.ts) bundling.
  • Automatic dependency inclusion (peerDependencies and dependencies are not bundled in the final output, devDependencies are unless they're not imported).

[^1]: A module bundler optimized for better tree-shaking processing and seamless interoperability of CommonJS and ESM formats with minimal code footprint.

[^2]: A TypeScript / JavaScript transpiler for quicker code processing including TypeScript transpilation, JavaScript transformation, and, minification.

🚀 Quick Start

1️⃣ Install by running:

# Npm
npm install quickbundle
# Pnpm
pnpm add quickbundle
# Yarn
yarn add quickbundle

2️⃣ Set up your package configuration (package.json):

  • When exporting exclusively ESM format:
{
	"name": "lib", // Package name
	"type": "module", // Optional if you want Node-like runtime to process by default `.js` file as ESM modules.
	"sideEffects": false, // Mark the package as a side-effect-free one to support the consumer dead-code elimination (tree-shaking) process. If your library contains global side effects (ideally, it should be avoided), configure the field to list the files that do have side effects.
	"exports": {
		".": {
			"source": "src/index.ts(x)?", // Source code entry point.
			"types": "./dist/index.d.ts", // Typing output file (if defined, can increase build time). This condition should always come first after the custom `source` field definition.
			"default": "./dist/index.mjs", // By default, Quickbundle will always output ESM format for the `default` field (this condition should always come last since it always matches as a generic fallback). However, take care: if both `import` and `default` fields are defined, provide the same file path, as the `import` field export instruction will be the only one considered to define the output file path.
		},
		"./otherModulePath": {
			// ...
		}
	}
	"scripts": {
		"build": "quickbundle build", // Production mode (optimizes bundle)
		"watch": "quickbundle watch", // Development mode (watches each file change)
	},
	// ...
}
{
	"name": "lib", // Package name
	"type": "module", // Optional if you want Node-like runtime to process by default `.js` file as ESM modules.
	"sideEffects": false, // Mark the package as a side-effect-free one to support the consumer dead-code elimination (tree-shaking) process. If your library contains global side effects (ideally, it should be avoided), configure the field to list the files that do have side effects.
	"exports": {
		".": {
			"source": "src/index.ts(x)?", // Source code entry point.
			"types": "./dist/index.d.ts", // // Typing output file (if defined, can increase build time). This condition should always come first after the custom `source` field definition.
			"require": "./dist/index.cjs", // CommonJS output file (matches when the module is loaded via require() consumer side).
			"import": "./dist/index.mjs", // ESM output file (matches when the package is loaded via import or import() consumer side).
			"default": "./dist/index.mjs", // By default, Quickbundle will always output ESM format for the `default` field (this condition should always come last since it always matches as a generic fallback). However, take care: if both `import` and `default` fields are defined, provide the same file path, as the `import` field export instruction will be the only one considered to define the output file path.
		},
		"./otherModulePath": {
			// ...
		}
	}
	"scripts": {
		"build": "quickbundle build", // Production mode (optimizes bundle)
		"watch": "quickbundle watch", // Development mode (watches each file change)
	},
	// ...
}

3️⃣ Try it by running:

# Npm
npm run build
# Pnpm
pnpm build
# Yarn
yarn build

👨‍🍳 Patterns

Optimize the build output

By default, Quickbundle does the following built-in optimizations during the bundling process:

  • Include, in the build output, only the code that is effectively imported and used in the source code. Setting the sideEffects package.json field to false marks the package as a side-effect-free one and helps Quickbundle to safely prune unused exports.
  • Identify and annotate side-effect-free code (functions, ...) to enable a fine-grained dead-code elimination process later consumer side. For example, if a consumer uses only one library API, build output annotations added by Quickbundle allow the consumer's bundler remove all other unused APIs.

However, Quickbundle doesn't minify the build output. Indeed, in general, if the build targets a library (the most Quickbundle use case), minification is not necessary since enabling it can introduce some challenges:

  • Reduce the build output discoverability inside the node_modules folder (minified code is an obfuscated code that can be hard to read for code audit/debugging purposes).
  • Generate suboptimal source maps for the bundled library, as the consumer bundler will generate source maps based on the already minified library build (transformed code, mangled variable names, etc.).
  • Risk of side effects with double optimizations (producer side and then consumer side).

Popular open source libraries (Vue, SolidJS, Material UI, ...) do not provide minified builds as the build optimization is sensitive to the consumer context (e.g. environment targets (browser support), ...) and needs to be fully owned upstream (i.e. consumer/application-side).

However, for non-library targets or if you would like to minify the build output on your side anyway, Quickbundle still provides the ability to enable the minification via:

quickbundle build --minification
quickbundle watch --minification

Enable source maps generation

By default, source maps are not enabled but Quickbundle still provides the ability to enable it via:

quickbundle build --source-maps
quickbundle watch --source-maps

Enabling source map generation is needed only if a build is obfuscated (minified) for debugging-easing purposes. It generally pairs with the minification flag.

🤩 Used by

  • @adbayb/stack My opinionated toolbox for JavaScript/TypeScript projects.

✍️ Contribution

We're open to new contributions, you can find more details here.

💙 Acknowledgements

  • The backend is powered by Rollup and its plugin ecosystem (including SWC) to make blazing-fast builds. A special shoutout to all contributors involved.
  • The zero-configuration approach was inspired by microbundle. A special shoutout to its author Jason Miller and all contributors.

📖 License

MIT.