Tree-Shaking
date-wiz is fully tree-shakable. Every module is an independent ES Module with no side effects, so any modern bundler (Vite, webpack 5, Rollup, esbuild, Parcel) will eliminate unused code automatically.
Sub-path imports (recommended)
Section titled “Sub-path imports (recommended)”Import directly from a sub-path to give your bundler the clearest possible signal:
import { format } from 'date-wiz/format'; // ~1.2 KB gzippedimport { getRelativeTime } from 'date-wiz/relative'; // ~1.4 KB gzippedimport { smartFormat } from 'date-wiz/smart'; // ~0.8 KB gzippedimport { parse } from 'date-wiz/parse'; // ~1.5 KB gzippedimport { addBusinessDays } from 'date-wiz/business'; // ~1.2 KB gzippedRoot import (also tree-shakable)
Section titled “Root import (also tree-shakable)”Importing from the root is equally tree-shakable when your bundler supports "exports" maps (Vite, Rollup, webpack 5+):
// Only format() and getRelativeTime() end up in your bundleimport { format, getRelativeTime } from 'date-wiz';Module sizes (gzipped)
Section titled “Module sizes (gzipped)”| Module | Sub-path | Gzipped |
|---|---|---|
format | date-wiz/format | ~1.2 KB |
relative | date-wiz/relative | ~1.4 KB |
smart | date-wiz/smart | ~0.8 KB |
parse | date-wiz/parse | ~1.5 KB |
business | date-wiz/business | ~1.2 KB |
| Everything | date-wiz | ~6.9 KB |
Checking your bundle
Section titled “Checking your bundle”Use Bundlephobia to estimate your impact, or inspect your Vite/Rollup bundle with:
# Vitenpx vite build --mode analyze
# Rollupnpx rollup-plugin-visualizer"sideEffects": false
Section titled “"sideEffects": false”date-wiz sets "sideEffects": false in package.json, which tells bundlers it’s safe to discard any module that isn’t imported. This enables aggressive dead-code elimination even in non-ESM contexts.
{ "name": "date-wiz", "sideEffects": false}