Registry / devops / vite-plugin-lwc

vite-plugin-lwc

JSON →
library4.1.0jsnpmunverified

Vite plugin for Lightning Web Components (LWC) providing instant preview for Salesforce component development. Current stable version is 4.1.0, released with support for Vite 6+ and @lwc/rollup-plugin 8+. This plugin handles LWC module resolution, template compilation, and HMR. Unlike @lwc/vite-plugin (experimental), this is a community-maintained production-ready alternative with full ESM support and TypeScript definitions. Release cadence follows Vite major versions.

npm install vite-plugin-lwc
INSTALL
IMPORT
SIG · VITE-PLUGIN-LWC
V
vite-plugin-lwc
devopsjavascriptv4.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import lwc from 'vite-plugin-lwc'
const lwc = require('vite-plugin-lwc')
ESM-only plugin. CJS require() will fail because the package only exports a default ESM function.
lwc type
import type { LwcPluginOptions } from 'vite-plugin-lwc'
import { LwcPluginOptions } from 'vite-plugin-lwc'
Options type is only available as a type import to avoid runtime inclusion. Not exported as value.
Plugin registration
lwc()
new lwc()
The plugin is a factory function, not a class. Do not use 'new'.

Minimal Vite configuration to enable LWC plugin. Place this in vite.config.js at project root.

// vite.config.js import { defineConfig } from 'vite'; import lwc from 'vite-plugin-lwc'; export default defineConfig({ plugins: [lwc()], });
Debug
Known issues
breakingVersion 4.0.0 drops support for Vite 5 and @lwc/rollup-plugin 7. Update your peer dependencies to Vite >=6 and @lwc/rollup-plugin >=8.
fix
Upgrade vite to ^6 and @lwc/rollup-plugin to ^8.
affects: <4.0.0
gotchaThe plugin expects LWC modules to be under 'src/modules' by default. If your project uses a different directory, you must configure it via options.
fix
Use lwc({ modules: [{ dir: 'path/to/modules' }] }) in plugin options.
affects: >=1.0.0
deprecatedThe 'mode' option was removed in v3. Use 'ssr' and 'client' options instead.
fix
Remove 'mode' from config and use the new boolean flags if needed.
affects: >=3.0.0
gotchaHMR requires the LWC compiler to output compatible code. Some older LWC components may not support HMR and require a full reload.
fix
Ensure LWC modules are compiled with @lwc/compiler >=2.0.0.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-lwc'
Package not installed or missing from package.json dependencies.
fix
Run 'npm install vite-plugin-lwc' and ensure it's in your dependencies.
TypeError: lwc is not a function
Using default import incorrectly or CJS require() in an ESM-only package.
fix
Use ESM syntax: import lwc from 'vite-plugin-lwc'.
[vite] Internal server error: Unknown plugin option 'mode'
Using deprecated 'mode' option that was removed in v3.
fix
Remove the 'mode' option from the plugin config.
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
@lwc/rollup-pluginrequiredCore LWC compilation logic delegation
viterequiredPeer dependency for Vite plugin ecosystem
Agent activity
2 hits · last 30 days
node
2
Resources
vite-plugin-lwc — npm install vite-plugin-lwc · libregistry