c-w / mathquill4quill

Power-up Quill's formula editing via the MathQuill editor
https://justamouse.com/mathquill4quill
Apache License 2.0
139 stars 33 forks source link

Build Failure. #103

Closed jbuyu closed 8 months ago

jbuyu commented 8 months ago

Hi, I've used this in a nextjs 13 app. everything works fine on dev, but when building for prod, I get a document is not defined.

Collecting page data .ReferenceError: document is not defined at Object.<anonymous> (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:7661:12) at __webpack_require__ (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:36:30) at Object.<anonymous> (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:1030:1) at __webpack_require__ (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:36:30) at Object.<anonymous> (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:5655:14) at __webpack_require__ (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:36:30) at Object.<anonymous> (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:10045:13) at __webpack_require__ (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:36:30) at Object.<anonymous> (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:11557:18) at __webpack_require__ (/Users/jbuyu/Desktop/projects/cider/Angaza/admin-dash/node_modules/quill/dist/quill.js:36:30)

Is there a way around this? I've tried to dynamically import the import ReactQuill, { Quill } from "react-quill"; library but that seems not to work.

c-w commented 8 months ago

Did you take a look at the NextJS setup example?

jbuyu commented 8 months ago

Yes I did. followed that example to a tee. Everything works well on dev. What I suspect is causing this is the nature of how I'm importing the Quill editor library. What's baffling is that it runs well on dev. It breaks when building though because the quill library is trying to run on the server rather than client for the build files. I'm using next 13.5.6 I've also tried to ensure the component that react-quill is imported on is a client component. Here's a screenshot of the files and the error I'm getting while building.

Screenshot 2024-02-14 at 15 31 07
c-w commented 8 months ago

How exactly are you building this? When I run npm run build in the nextjs subfolder of this repository (which calls through to next export), it completes without crash.

jbuyu commented 8 months ago

Hi, It could have been how I'm using the modules. I've decided to build this in react either way. Thanks @c-w .

c-w commented 8 months ago

Ok, resolving this as it's tied to your specific setup. Feel free to open other issues if you face problems specific to the library.