|
5 | 5 | [](https://www.codacy.com/gh/AlexAegis/js-tooling/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AlexAegis/js-tooling&utm_campaign=Badge_Grade) |
6 | 6 | [](https://codecov.io/github/AlexAegis/js-tooling) |
7 | 7 |
|
8 | | -A vite plugin to fill out your `package.json` files for library development. |
| 8 | +A vite plugin to fill out your `package.json` files for its local and published |
| 9 | +variants. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +Add it to the `plugins` array in your `vite.config.ts` file! |
| 14 | + |
| 15 | +> It is also wrapping |
| 16 | +> [vite-plugin-dts](https://github.com/qmhc/vite-plugin-dts)! |
| 17 | +
|
| 18 | +```ts |
| 19 | +import { defineConfig } from 'vite'; |
| 20 | +import { pakk } from 'vite-plugin-pakk'; |
| 21 | + |
| 22 | +export default defineConfig({ |
| 23 | + plugins: [pakk()], |
| 24 | +}); |
| 25 | +``` |
| 26 | + |
| 27 | +## Features |
| 28 | + |
| 29 | +- Sets up exports automatically from the top level files in your library. |
| 30 | + `index.ts` will be treated as the default export, and any additional files |
| 31 | + will be treated as other entry points. This means you have to put every other |
| 32 | + internal file in a directory! |
| 33 | + - Sets up exports for both ES Modules and CommonJS! |
| 34 | + - It fills your local `package.json` file too! For `types` it will point to |
| 35 | + your internal typescript file (`./src/index.ts`) but for the actual code, it |
| 36 | + will point to your `outDir` (`./dist/index.js`). This ensures that you build |
| 37 | + and test with the actual build artifact, but let's you see changes |
| 38 | + immediately! (It assumes your build and test tools build dependencies before |
| 39 | + building or testing any package!) |
| 40 | + - It adjusts the distributed `package.json` file so it points to the correct |
| 41 | + paths for both types (`./index.d.ts`) and ESM/CJS files (`./index.js`, |
| 42 | + `./index.cjs`) |
| 43 | +- Files in a folder called `bin` will be treated as bins for the package. Shims |
| 44 | + and bin entries will automatically be created to allow them to be used locally |
| 45 | + too, not to disturb package managers like `pnpm` when they create symlinks. |
| 46 | +- You can set up a `static` folder next to `src` too to export non-js files like |
| 47 | + the docs or images. |
| 48 | +- Opinionated, but highly configurable! It works out-of-the box using these |
| 49 | + conventional locations, but almost every aspect of it is configurable. |
| 50 | + Directories can be adjusted, file globs can be added |
| 51 | +- This plugin **does not generate type definition files!** It assumes you have a |
| 52 | + `dts` generator plugin present! |
0 commit comments