Theorem Bundler Plugins

0.3.2 · active · verified Tue Apr 21

The `theoremts-plugins` package provides essential build-time integration for projects utilizing the Theorem TypeScript contract system. Currently at version 0.3.2, this package offers plugins for popular bundlers like Vite, esbuild, and tsup, enabling the stripping of Theorem contracts during the build process. This crucial functionality ensures zero runtime overhead for contracts in production environments, making it a key differentiator for performance-sensitive applications using Theorem. As a pre-1.0 release, its development cadence is likely tied to the Theorem project itself, implying potential for breaking changes in minor versions without strict semver adherence. Its primary purpose is to optimize the deployment of Theorem-powered applications by removing development-time contract checks, offering a lean production bundle.

Common errors

Warnings

Install

Imports

Quickstart

Illustrates how to integrate the `theoremVite` plugin into a Vite configuration file to strip Theorem contracts at build time.

import { defineConfig } from 'vite';
import { theoremVite } from 'theoremts-plugins/vite';

// This configuration demonstrates how to integrate the theoremVite plugin
// into a standard Vite project. The plugin will automatically detect
// and strip Theorem contracts from your code during the build process,
// ensuring that they do not incur any runtime overhead in production.
export default defineConfig({
  plugins: [
    // Initialize the theoremVite plugin. It's typically added early
    // in the plugin array to ensure contracts are stripped before other
    // transformations that might interfere.
    theoremVite(),
    // ... other Vite plugins can go here
  ],
  // You might also have other Vite configurations here,
  // such as build options, server settings, etc.
  build: {
    sourcemap: true, // Example build option: useful for debugging production issues
    minify: 'esbuild' // Example: using esbuild for minification
  },
});

view raw JSON →