lucpotage/vue-katex

Uncaught ReferenceError: require is not defined

Opened this issue · 3 comments

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'

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

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

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.