
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
vite-plugin-component-lib
Advanced tools
Framework-agnostic Vite plugin that emits an unbundled component library in both ESM and CJS formats by default, using a single `vite build` command. It wires up Vite’s `environments` + `builder` APIs so the same source can ship to multiple module targets
Framework-agnostic Vite plugin that emits an unbundled component library in both ESM and CJS formats by default, using a single vite build command. It wires up Vite’s environments + builder APIs so the same source can ship to multiple module targets without hand-rolled Rollup/Rolldown configs.
dist/esm or dist/cjs[!IMPORTANT] Requires Vite 6+ for the Environment API
npm add -D vite-plugin-component-lib
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { components } from "vite-plugin-component-lib";
export default defineConfig({
plugins: [react(), components()],
});
Run vite build. The plugin:
esm and cjs by default).dist/esm and dist/cjs with matching folder structures.dist.dist/
├─ esm/
│ ├─ index.js
│ └─ components/Button.js
└─ cjs/
├─ index.cjs
└─ components/Button.cjs
src by default (preserveModulesRoot).[name][ext]) so CSS, SVG, and other static files keep their filenames.package.json#types can target dist/index.d.ts.unplugin-dts..d.ts files into the base outDir (dist unless overridden).types entry file (dist/index.d.ts by default).unplugin-dts option (or disable emission entirely) with the dts option.package.json exports{
"name": "my-component-lib",
"type": "module",
"main": "./dist/cjs/index.cjs",
"module": "./dist/esm/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./dist/index.d.ts",
},
},
}
| Option | Type | Default | Description |
|---|---|---|---|
entry | string | string[] | Record<string,string> | "src/index.ts" | Library entry passed to build.lib.entry. |
outDir | string | "dist" | Base output directory. Format folders (esm, cjs) are nested inside. |
preserveModulesRoot | string | "src" | Root folder trimmed from emitted paths when preserveModules is on. |
fileSuffix | { esm?: string; cjs?: string } | {esm: ".js", cjs: ".cjs"} | Customize per-format filename suffixes. |
external | (RegExp | string)[] | bare imports | Extra ids to mark as external. |
internal | (RegExp | string)[] | [] | Allow-listed bare ids that should stay bundled. |
envNames | { esm?: string; cjs?: string } | {esm: "esm", cjs: "cjs"} | Rename the environments if you need non-default names. |
formats | ("esm" | "cjs")[] | ["esm", "cjs"] | Choose which formats to emit. Pass ["esm"] for ESM-only, etc. |
disableBuilder | boolean | false | Skip registering the builder hook. Useful for CI workflows that call environments individually. |
dts | boolean | PluginOptions | true | Configure the bundled unplugin-dts instance or disable it. |
PluginOptions is the option type exported by unplugin-dts.
MIT
FAQs
Framework-agnostic Vite plugin that emits an unbundled component library in both ESM and CJS formats by default, using a single `vite build` command. It wires up Vite’s `environments` + `builder` APIs so the same source can ship to multiple module targets
We found that vite-plugin-component-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.