bundlejs
A quick and easy way to bundle, minify, and compress your ts, js, jsx and npm packages, while viewing the file size of the final bundle.
Quickly bundle js & view the file size.
Console
No logs...
Generate a dynamic badge
Share a badge with the computed size of the current query!
Badge type
Badge style
Image type
Analysis
Nothing to analyze...
đź“‘ Official Docs for
bundlejs
are now available.
✨ Update ✨ bundlejs.com is the new official domain for
bundlejs
.
Usage
When bundling packages that also export CSS and other external files, bundlejs now checks the gzip/brotli size of these external files, even though it won’t output any code. Keep this in mind this isn’t a bug, however, if it causes confusion I am willing to change this behaviour.
Treeshaking is available, but not all CDNs support access to each packages package.json so there might be slight package version conflicts. The only verified CDN with access to the package.json is unpkg.com.
Check the console for error messages and warnings.
You can use custom protocols to specify which CDN the module should come from.
- esm.run:react -> https://esm.run/react
- esm.sh:react -> https://esm.sh/react
- esm:react -> https://esm.sh/react
- jsr:@oxi/result -> https://esm.sh/jsr/@oxi/result
- skypack:react -> https://cdn.skypack.dev/react
- unpkg:react -> https://unpkg.com/react
- deno:preact -> https://deno.land/x/preact
- jsdelivr:react -> https://cdn.jsdelivr.net/npm/react
- jsdelivr.gh:…/react-dom/index.js -> https://cdn.jsdelivr.net/gh/.../react-dom/index.js
- github:…/react/index.js -> https://raw.githubusercontent.com/.../react/index.js
e.g.
import { toStr } from "skypack:@okikio/animate";
// or
export * from "esm:@okikio/animate";
// or
export { animate } from "https://cdn.skypack.dev/@okikio/animate";
* If an error occurs try using a different CDN, by default bundlejs uses unpkg.com but you can use the others.
* For some packages an error occurs where the default export is excluded from the treeshaken bundle, the solution for this is to manually include the default export like so,
export * from "solid-dismiss";
// and
export { default } from "solid-dismiss";
Externals
Externals allow you to mark certain modules as modules to exclude from resolving, loading, and bundling, you use it the way you’d use the esbuild externals config option, e.g.
{
"esbuild": {
"external": ["react", "react-dom"],
}
}
You can try it out below,
bundlejs.com/?config={"esbuild":{"external":["@okikio/animate"]}}
Check out a complex example of using the external config
bundlejs.com/?q=@babel/core&config={"esbuild":{"external":[...]}}
Aliases
Aliases act as a redirect for modules, they are for replacing packages with different ones, e.g. replace fs
with memfs
, so, it can work on the web, etc..
You use aliases like this:
{
"alias": {
"@okikio/animate": "react-dom"
}
}
You can try out an example of using aliases,
bundlejs.com/?config={"alias":{"@okikio/animate":"react-dom"}}
⚠️ Warning: aliases currently don’t care about the original packages version, e.g.
@okikio/animate@beta
will be redirected toreact-dom
regardless of the package version in use.
Badges
You can also add bundle badges, they look like this,
All you need to do is to add this to your README.md
# Light Mode Badge
[![Open Bundle](https://bundlejs.com/badge-light.svg)](https://bundlejs.com/)
# Dark Mode Badge
[![Open Bundle](https://bundlejs.com/badge-dark.svg)](https://bundlejs.com/)
You can use the Sharing section above, to create unique bundles, when users clicks on the badge.
Community
Tweet at me on @okikio_dev with what you love and what you think needs improvement in
bundlejs
to get added to the list users.
- @sheetjs
- @daniguardio_la
- And more, etc…
Note You can also use bundlesize.com to access
bundlejs
.
Special thanks to @sheetjs and @daniguardio_la for donating to
bundle
on OpenCollective.