Unplugin TypeSugar Bundler Integrations

0.1.1 · active · verified Tue Apr 21

unplugin-typesugar provides essential bundler integrations for `typesugar`, a TypeScript macro expansion library. It enables compile-time macro processing across various build tools, including Vite, Webpack, esbuild, and Rollup. Leveraging the `unplugin` ecosystem, it ensures broad compatibility and simplifies integration into existing JavaScript and TypeScript projects. The current stable version is 0.1.1, marked as an initial release candidate and first stable patch, indicating active, early-stage development with frequent updates addressing stability and feature enhancements. A key differentiator is its ability to expand TypeScript macros before the code enters the bundler's optimization pipeline, ensuring that macro-transformed code is fully optimized. It requires TypeScript 5.0 or newer as a peer dependency, aligning with modern TypeScript tooling practices.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to integrate unplugin-typesugar into a Vite project with common configuration options, including verbose logging, file pattern matching, disk caching, and strict type-checking of expanded output.

import typesugar from "unplugin-typesugar/vite";
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    typesugar({
      verbose: true,
      include: /src\/.*\.tsx?$/,
      exclude: /\.test\.ts$/,
      diskCache: true, // Enable disk cache for faster rebuilds
      strict: true // Typecheck expanded output at build end
    }),
  ],
});

view raw JSON →