Registry / devops / vite-plugin-sdk

vite-plugin-sdk

JSON →
library0.1.5jsnpmunverified

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-sdk
INSTALL
IMPORT
SIG · VITE-PLUGIN-SDK
V
vite-plugin-sdk
devopsjavascriptv0.1.5
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sdk
✓ import sdk from 'vite-plugin-sdk'
✗ const sdk = require('vite-plugin-sdk')
ESM-only package; default export is the plugin function
default
✓ import sdk from 'vite-plugin-sdk'
✗ import { sdk } from 'vite-plugin-sdk'
Package only exports a default function; named imports will fail
PluginOptions
✓ import type { PluginOptions } from 'vite-plugin-sdk'
✗ import { PluginOptions } from 'vite-plugin-sdk'
Type-only export; use import type to avoid runtime import warning

Minimal Vite config using vite-plugin-sdk to bundle an SDK with type declarations.

// vite.config.ts import { defineConfig } from 'vite'; import sdk from 'vite-plugin-sdk'; export default defineConfig({ plugins: [ sdk({ dts: true, internalDependencies: [], srcDir: 'src', }), ], });
Debug
Known issues
gotchaPackage is ESM-only. Use `import` syntax; `require()` will throw.
fix
Use `import sdk from 'vite-plugin-sdk'` in your Vite config. Ensure `"type": "module"` in package.json or use .mjs extension.
affects: >=0.0.1
breakingPeer dependency Vite supports major versions 4, 5, 6, and 7. Using older Vite versions may break.
fix
Update Vite to ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0.
affects: >=0.1.0
deprecatedOption `packageJSON` path resolution may be deprecated in favor of explicit path in future versions.
fix
Always provide an explicit `packageJSON` option to avoid relying on CWD-based discovery.
affects: unknown
gotchaIf `dts: true`, TypeScript must be installed (peer dependency). Build will fail otherwise.
fix
Install typescript >=5 as a devDependency.
affects: >=0.0.1
gotchaPlugin automatically externalizes all dependencies listed in `dependencies` and `peerDependencies` of package.json. To bundle them, add to `internalDependencies`.
fix
Use the `internalDependencies` array to explicitly include packages that should be bundled.
affects: >=0.0.1
gotchaSource directory defaults to `src`. If your SDK code is elsewhere (e.g., `lib`), builds will produce empty output.
fix
Set `srcDir` to the correct source directory relative to project root.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Plugin vite-plugin-sdk: `dts` option requires `typescript` as a peer dependency.
TypeScript is not installed when `dts: true`.
fix
Run `npm install --save-dev typescript` or set `dts: false`.
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/vite-plugin-sdk not supported.
Using CommonJS `require()` to import an ESM-only package.
fix
Switch to `import sdk from 'vite-plugin-sdk'` in an ESM-configured project.
TypeError: Cannot read properties of undefined (reading 'dependencies')
`packageJSON` option not provided and plugin cannot find a package.json from CWD.
fix
Provide an explicit `packageJSON` option pointing to your package.json.
vite build output is empty (no files generated)
`srcDir` does not point to a valid directory containing source files.
fix
Set `srcDir` correctly, e.g., `srcDir: 'lib'` if your entry is in `lib/index.ts`.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies
viterequiredpeer dependency; required as plugin host
typescriptoptionalpeer dependency; used for type declaration generation
tsliboptionalpeer dependency; runtime helpers for TypeScript
Agent activity
8 hits · last 30 days
node
8
Resources
vite-plugin-sdk — npm install vite-plugin-sdk · libregistry