vite-plugin-antdv-fix

raw JSON →
1.0.3 verified Mon Apr 27 auth: no javascript maintenance

Vite plugin that patches ant-design-vue@1.7.8 (unmaintained) for Vue 2 + Vite projects. Fixes two critical runtime errors: 'require is not defined' in production builds (due to CJS/ESM incompatibility) and 'moment.isMoment is not exported by default' (missing named export). No active development; last updated February 2022. Alternative: upgrade to ant-design-vue v3+ (Vue 3) or use @ant-design-vue/p shortly for v1 fixes.

error ReferenceError: require is not defined
cause ant-design-vue@1.7.8 uses CommonJS require() which is not available in the browser when bundled by Vite.
fix
Install and apply vite-plugin-antdv-fix: npm i -D vite-plugin-antdv-fix then add antdvFix() to plugins.
error Uncaught TypeError: moment.isMoment is not a function
cause Moment.js version mismatch; ant-design-vue expects moment.isMoment but it's not exported as default.
fix
Use vite-plugin-antdv-fix which patches the default export to include isMoment.
breaking Plugin only fixes ant-design-vue@1.7.8. Higher or lower versions may break differently.
fix Use antdvFix() with ant-design-vue exactly 1.7.8.
deprecated Package not updated since 2022; no issue tracker activity.
fix Consider forking or migrating to Vue 3 + ant-design-vue v3+.
gotcha Plugin may conflict with other Vite plugins that transform CJS dependencies.
fix Test thoroughly in production build; adjust plugin order if needed.
npm install vite-plugin-antdv-fix
yarn add vite-plugin-antdv-fix
pnpm add vite-plugin-antdv-fix

Configure Vite plugin to fix ant-design-vue@1.7.8 runtime errors in production builds.

// vite.config.ts
import { defineConfig } from 'vite'
import antdvFix from 'vite-plugin-antdv-fix'

export default defineConfig({
  plugins: [
    antdvFix()
  ],
  // Ensure Vite processes ant-design-vue as a dependency (optional)
  optimizeDeps: {
    include: ['ant-design-vue']
  }
})