Vite plugin to bundle SDKs with support for ESM and CJS outputs. Current stable version: 0.1.5. Active development with frequent releases. Extensible via defu. Only works with Vite 4, 5, 6, or 7. Provides TypeScript type declarations. Key differentiator: focused solely on SDK bundling, with automatic externalization based on package.json dependencies, built-in DTS generation, and support for internal dependencies. Lightweight alternative to full Rollup setups for SDK authors.
npm install vite-plugin-sdkVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config using vite-plugin-sdk to bundle an SDK with type declarations.
Use `import sdk from 'vite-plugin-sdk'` in your Vite config. Ensure `"type": "module"` in package.json or use .mjs extension.
Update Vite to ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0.
Always provide an explicit `packageJSON` option to avoid relying on CWD-based discovery.
Install typescript >=5 as a devDependency.
Use the `internalDependencies` array to explicitly include packages that should be bundled.
Set `srcDir` to the correct source directory relative to project root.
Run `npm install --save-dev typescript` or set `dts: false`.
Switch to `import sdk from 'vite-plugin-sdk'` in an ESM-configured project.
Provide an explicit `packageJSON` option pointing to your package.json.
Set `srcDir` correctly, e.g., `srcDir: 'lib'` if your entry is in `lib/index.ts`.