marktext / muya

📄 Future markdown editor for web browser applications development
MIT License
647 stars 57 forks source link

prismjs import error - require is not define #124

Open nepaul opened 1 year ago

nepaul commented 1 year ago

Describe the bug

When I integrated "muya" into my project, the following error occurred (I'm using the latest version of npm - "@marktext/muya": "^0.2.1",).

This seems to be a common error with Vite.

Unknown variable dynamic import: ../../../node_modules/prisms/components/prism-latex.js te: July at eval (webpack-internal:///../muya/dist/chunks/emptyStates. cbb949b2.js:2179:86)

Unknown variable dynamic import: ../../.. /node_modules /prismjs/components/prism-yaml.js

require is not defined
ReferenceError: require is not defined
at eval (webpack-internal:/// ../muva/dist/chunks/prism-keep-markup.6f6991cb.is:2:1)
at . . /mua/dist/chunks/prism-keep-markup.6f6991cb.js(http://localhost:3000/js/muya_dist_chunks_prism-keep-markup_6f6991cb_js.js:18:1)
at webpack_require.
(http://localhost:3000/js/app.is:737:33)
at Function. fn (http://localhost:3000/js/app.js: 1110:21)

To Reproduce Steps to reproduce the behavior:

import Muya from '@marktext/muya';
import {
  EmojiSelector,
  InlineFormatToolbar,
  ImageEditTool,
  ImageToolBar,
  ImageResizeBar,
  CodeBlockLanguageSelector,
  TableColumnToolbar,
  ParagraphQuickInsertMenu,
  TableDragBar,
  TableRowColumMenu,
  PreviewToolBar,
  ParagraphFrontButton,
  ParagraphFrontMenu,
} from '@marktext/muya/dist/ui/index';

Expected behavior A clear and concise description of what you expected to happen.

Actual behavior The actual result of this bug

Operation System and Browser version (please complete the following information):

Muya Version "^0.2.1"

Jocs commented 1 year ago

I can't reproduce this problem, upgrade node and vite to the latest version to try?