lucpotage / vue-katex

Vue plugin for KaTeX
MIT License
128 stars 22 forks source link

Uncaught ReferenceError: require is not defined #59

Open raygence13 opened 2 years ago

raygence13 commented 2 years ago

when building a vite app that uses vue-katex, the build breaks due to const merge = require('deepmerge') i've been able to fix this manually by copying the katex-directive.js code in my plugin.js file, and changing the line above to import merge from 'deepmerge'

hsorby commented 2 years ago

Did you do this with Vite + Vue 2? or Vite + Vue 3? Just wondering if this could have worked with Vite + Vue 3.

hsorby commented 2 years ago

Nevermind, I'm guessing it was Vite + Vue 2.

hhaensel commented 1 year ago

Alternatively, you can use the existing vue-katex.umd.js and change the line

// var o=require("deepmerge"),r=require("deepmerge");
var o = deepmerge, r = deepmerge;

and add deepmerge.umd.js to your dependencies if you don't have a vue installation on your computer to rebuild the files.