Skip to content

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.


Import directly from a sub-path to give your bundler the clearest possible signal:

import { format } from 'date-wiz/format'; // ~1.2 KB gzipped
import { getRelativeTime } from 'date-wiz/relative'; // ~1.4 KB gzipped
import { smartFormat } from 'date-wiz/smart'; // ~0.8 KB gzipped
import { parse } from 'date-wiz/parse'; // ~1.5 KB gzipped
import { addBusinessDays } from 'date-wiz/business'; // ~1.2 KB gzipped

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 bundle
import { format, getRelativeTime } from 'date-wiz';

ModuleSub-pathGzipped
formatdate-wiz/format~1.2 KB
relativedate-wiz/relative~1.4 KB
smartdate-wiz/smart~0.8 KB
parsedate-wiz/parse~1.5 KB
businessdate-wiz/business~1.2 KB
Everythingdate-wiz~6.9 KB

Use Bundlephobia to estimate your impact, or inspect your Vite/Rollup bundle with:

Terminal window
# Vite
npx vite build --mode analyze
# Rollup
npx rollup-plugin-visualizer

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
}