vite-plugin-pakk
v0.14.1
Published
Automatically fills out your package.json for both local and published version
Maintainers
Readme
vite-plugin-pakk
A vite plugin to fill out your package.json files for its local and published
variants.
Usage
Add it to the plugins array in your vite.config.ts file!
It is also wrapping vite-plugin-dts!
import { defineConfig } from 'vite';
import { pakk } from 'vite-plugin-pakk';
export default defineConfig({
plugins: [pakk()],
});Features
- Sets up exports automatically from the top level files in your library.
index.tswill be treated as the default export, and any additional files will be treated as other entry points. This means you have to put every other internal file in a directory!- Sets up exports for both ES Modules and CommonJS!
- It fills your local
package.jsonfile too! Fortypesit will point to your internal typescript file (./src/index.ts) but for the actual code, it will point to youroutDir(./dist/index.js). This ensures that you build and test with the actual build artifact, but let's you see changes immediately! (It assumes your build and test tools build dependencies before building or testing any package!) - It adjusts the distributed
package.jsonfile so it points to the correct paths for both types (./index.d.ts) and ESM/CJS files (./index.js,./index.cjs)
- Files in a folder called
binwill be treated as bins for the package. Shims and bin entries will automatically be created to allow them to be used locally too, not to disturb package managers likepnpmwhen they create symlinks. - You can set up a
staticfolder next tosrctoo to export non-js files like the docs or images. - Opinionated, but highly configurable! It works out-of-the box using these conventional locations, but almost every aspect of it is configurable. Directories can be adjusted, file globs can be added
- This plugin does not generate type definition files! It assumes you have a
dtsgenerator plugin present!
