ant-design / pro-chat

🤖 Components Library for Quickly Building LLM Chat Interfaces.
https://pro-chat.antdigital.dev
MIT License
684 stars 88 forks source link

🐛[BUG] 依赖构建报错 "rewrite" is not exported #320

Open wztlink1013 opened 1 week ago

wztlink1013 commented 1 week ago

🐛 bug 描述

打包报错

去掉 "@ant-design/pro-chat": "^1.15.2", 打包构建正常

image image

📷 复现步骤

如上截图

🏞 期望结果

正常构建

💻 复现代码

可复现 demo

© 版本信息

均是antd相关最新依赖

🚑 其他信息

hakanemrebasol commented 1 week ago

I encountered an issue with oniguruma-to-js when using it alongside ProChat. The issue seems related to the recent update of pro-editor, which ProChat uses as a dependency. Specifically, the update to pro-editor 15 days ago is likely causing this error when installing ProChat again. The package version is as follows: "@ant-design/pro-editor": "latest"

Temporary Fix While I do not recommend this as a long-term solution, I was able to temporarily resolve the issue by disabling regex within the oniguruma-to-js package. I am unsure of the potential side effects, so proceed with caution.

Here are the steps I followed:

  1. Navigate to the oniguruma-to-js directory in your project. /node_modules/oniguruma-to-js/dist/shared/oniguruma-to-js.2969e22d.mjs

  2. Disable regex imports by modifying the file:

    // import { rewrite } from 'regex';
    .
    .
    .
    // if (useRegex) {
    //   output = rewrite(
    //     output,
    //     {
    //       flags: flagStr,
    //       unicodeSetsPlugin: null,
    //       disable: {
    //         n: true,
    //         v: true,
    //         x: true
    //       }
    //     }
    //   ).expression;
    // }

Applying the Patch After modifying the file, create a patch to persist these changes: npx patch-package oniguruma-to-js

Also update your scripts in your package.json

  "scripts": {
    "postinstall": "patch-package"
  },

Note This is not a recommended approach for production environments, as it might have unintended side effects. However, this temporary fix has resolved the issue in my case.