Home

Awesome

viteup npm

Disclaimer

This software is experimental.

Description

A better (opinionated) way to bundle your TypeScript libraries, powered by Vite + SWC.

Installation

npm i --save-dev viteup

Note: if you plan on using a different compiler than SWC, you can avoid installing the vite-plugin-swc-transform dependency:

npm i --save-dev --no-optional viteup

Example Usage

{
  "name": "my-library",
  "type": "module",
  "exports": "./dist/index.js",
  "scripts": {
    "build": "viteup"
  }
}

Build.

npm run build

Advanced Usage

Examples of package.json setup for ESM or CommonJS, or both

CommonJS output only for maximum compatibility

{
  "name": "my-library",
  ["type": "commonjs",]
  "main": "./dist/index.js",
  "scripts": {
    "build": "viteup"
  }
}

CommonJS output only for "modern module resolution"-capable consumers

{
  "name": "my-library",
  ["type": "commonjs",]
  "exports": "./dist/index.js",
  "scripts": {
    "build": "viteup"
  }
}

ESM output only for broad compatibility

{
  "name": "my-library",
  "module": "./dist/index.mjs",
  "scripts": {
    "build": "viteup"
  }
}

ESM output only for "modern module resolution"-capable consumers

{
  "name": "my-library",
  "type": "module",
  "exports": "./dist/index.js",
  "scripts": {
    "build": "viteup"
  }
}

Dual emit CommonJS + ESM output for "modern module resolution"-capable consumers

{
  "name": "my-library",
  "type": "module",
  "exports": {
    "require": "./dist/index.cjs",
    "default": "./dist/index.js"
  },
  "scripts": {
    "build": "viteup"
  }
}

Dual emit CommonJS + ESM output for maximum compatibility

{
  "name": "my-library",
  ["type": "commonjs",]
  "main": "./dist/index.js",
  "module": "./dist/index.mjs",
  "exports": {
    "require": "./dist/index.js",
    "default": "./dist/index.mjs"
  },
  "scripts": {
    "build": "viteup"
  }
}

Extending or overriding Vite configuration

JavaScript API

Integration with Vitest

Support

Package.json output fields support

Package.json export conditions support