marp-team / marp-core

The core of Marp converter
MIT License
750 stars 127 forks source link

TypeError: u2 is not a function #361

Closed moguixiaolin closed 8 months ago

moguixiaolin commented 9 months ago

image image

yhatt commented 9 months ago

Need more informations to resolve the issue, such as the version of Marp Core, the runtime operating environment, and whether or not a JavaScript bundler is used. Would you share the minimum reproducible if possible?

moguixiaolin commented 8 months ago

📝 This comment has been translated to English by the Marp team. For the community's discoverability and workability, we would appreciate your help in writing the description in English.

Original 操作如下: `import Marp from '@marp-team/marp-core'` `const marp = new Marp()` 版本: ![image](https://github.com/marp-team/marp-core/assets/95116912/3edabeac-2878-427a-a219-9e72e4948d97) 页面直接报错如下: ![image](https://github.com/marp-team/marp-core/assets/95116912/a1691e7b-27c7-440f-8744-cb0a9272ff4f) 注意:只进行new 操作,无其他任何操作

The operation is as follows: import Marp from '@marp-team/marp-core' const marp = new Marp()

Releases: image

The page directly reports the following error: image

Note: Only the new operation is performed, nothing else.

yhatt commented 8 months ago

Are you trying to use Marp Core on the Web page? Marp Core library is compatible with JavaScript server environment such as Node.js.

So for getting to work Marp Core on the web, you need to set up the JavaScript bundler properly. e.g. Native module polyfills for the browser environment. (If you were using Webpack, the setting for web extension of Marp for VS Code might help you)

For example, both of Marpit and Marp Core depend on PostCSS. https://github.com/postcss/postcss/issues/830 has mentioned that you need to pack JS with using proper browser polyfills to make PostCSS run in the browser.

moguixiaolin commented 8 months ago

📝 This comment has been translated to English by the Marp team. For the community's discoverability and workability, we would appreciate your help in writing the description in English.

Original @yhatt vite 4.x 版本打包通过fallback设置也无法消除 bug 产生。

@yhatt The vite 4.x version of the package does not eliminate the bug with the fallback setting.

moguixiaolin commented 8 months ago

📝 This comment has been translated to English by the Marp team. For the community's discoverability and workability, we would appreciate your help in writing the description in English.

Original 我的框架: vue + vite +ts 在浏览器运行中出现以上TS的typeerror问题

My framework: vue + vite +ts The above typeerror issue with TS occurs in the browser runtime

yhatt commented 8 months ago

If you're using Vite, you can inject Node.js polyfills through vite-plugin-node-polyfills.

moguixiaolin commented 8 months ago

📝 This comment has been translated to English by the Marp team. For the community's discoverability and workability, we would appreciate your help in writing the description in English.

Original ok,注入后,暂时没有看到其他错误,十分感谢解决方案 @yhatt

ok, after injection, no other errors seen for now, thanks a lot for the solution @yhatt