Registry / devops / esbuild-plugin-vite-element-ui

esbuild-plugin-vite-element-ui

JSON →
library1.0.2jsnpmunverified

An esbuild plugin that resolves the common issue where Element UI components cannot be used properly in Vite projects due to the `$isServer` property being undefined. Current stable version is 1.0.2, with infrequent releases. It addresses a specific compatibility problem between Element UI and Vite's dependency optimization by patching the Element UI module during esbuild bundling. This plugin is a targeted solution for developers who use Element UI with Vite and encounter runtime errors related to `$isServer`.

npm install esbuild-plugin-vite-element-ui
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-VIT
E
esbuild-plugin-vite-element-ui
devopsjavascriptv1.0.2
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 esbuildPlugin from 'esbuild-plugin-vite-element-ui'
const esbuildPlugin = require('esbuild-plugin-vite-element-ui')
ESM-only package; CommonJS require will fail.

Shows how to configure the esbuild plugin in vite.config.js to fix Element UI '$isServer' error.

// vite.config.js import { defineConfig } from 'vite'; import esbuildPlugin from 'esbuild-plugin-vite-element-ui'; export default defineConfig({ optimizeDeps: { esbuildOptions: { plugins: [ esbuildPlugin() ] } } }); // Ensure Element UI is installed: npm install element-ui // Then import Element UI normally in your main.js import Vue from 'vue'; import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; Vue.use(ElementUI);
Debug
Known issues
gotchaThe plugin must be used only in the esbuild optimization step, not as a general Vite plugin.
fix
Place the plugin inside optimizeDeps.esbuildOptions.plugins, as shown in the quickstart.
affects: >=1.0.0
gotchaThe plugin may not work with custom Element UI builds or tree-shaken imports.
fix
Ensure you import Element UI normally (not individual components) for the plugin to patch correctly.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot read property '$isServer' of undefined
Element UI expects a CommonJS environment but Vite's esbuild tree-shaking removes the global Vue reference.
fix
Install and configure esbuild-plugin-vite-element-ui as shown in the quickstart.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-vite-element-ui — npm install esbuild-plugin-vite-element-ui · libregistry