monosize-bundler-vite
raw JSON → 0.3.0 verified Sat May 09 auth: no javascript
A Vite bundler adapter for monosize that enables building size measurement fixtures using Vite instead of esbuild. Version 0.3.0 supports customizing Vite's InlineConfig via a callback, allowing resolution aliases and other Vite-specific configuration. Unlike the default esbuild bundler, Vite provides broader compatibility with modern web tooling (e.g., Vue, Svelte plugins). This package is in early development (pre-1.0) and currently has a notable limitation: Vite cannot emit multiple self-contained IIFE bundles in a single build, so fixtures are built sequentially regardless of build mode. Ships TypeScript types.
Common errors
error Cannot find module 'monosize-bundler-vite' or its corresponding type declarations. ↓
cause Missing dependency or type package not installed; TypeScript may not resolve types.
fix
Run 'npm install monosize-bundler-vite' and ensure node_modules is present.
error viteBundler is not a function ↓
cause Using named import instead of default import in CJS context without .default.
fix
Use 'import viteBundler from ...' (ESM) or 'const viteBundler = require('...').default' (CJS).
Warnings
gotcha Sequential builds regardless of --build-mode: Vite cannot emit multiple standalone IIFE bundles in one build; fixtures are built one by one. ↓
fix Ensure your build time accounts for sequential processing; currently unavoidable.
gotcha Peer dependency on 'vite' required and must be installed separately. ↓
fix Run 'npm install vite --save-dev' or equivalent; version compatibility should be checked.
breaking The package exports a default export only, not a named export. Prior to v0.2.0, named export might have existed? ↓
fix Use default import: import viteBundler from 'monosize-bundler-vite';
deprecated No deprecated APIs known at this version. ↓
fix N/A
Install
npm install monosize-bundler-vite yarn add monosize-bundler-vite pnpm add monosize-bundler-vite Imports
- default (viteBundler) wrong
import { viteBundler } from 'monosize-bundler-vite';correctimport viteBundler from 'monosize-bundler-vite'; - viteBundler (type)
import type { Bundler } from 'monosize-bundler-vite'; - viteBundler (CommonJS) wrong
const viteBundler = require('monosize-bundler-vite');correctconst viteBundler = require('monosize-bundler-vite').default;
Quickstart
// monosize.config.mjs
import viteBundler from 'monosize-bundler-vite';
export default {
repository: 'https://github.com/example/example.git',
root: '.',
output: './monosize-output.json',
bundler: viteBundler(config => {
config.resolve ??= {};
config.resolve.alias = {
...config.resolve.alias,
'react': 'react/dist/react.esm.js',
};
return config;
}),
};