Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wztlink1013 opened this issue Sep 23, 2024 · 1 comment
Open

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

wztlink1013 opened this issue Sep 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@wztlink1013
Copy link

🐛 bug 描述

打包报错

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

image
image

📷 复现步骤

如上截图

🏞 期望结果

正常构建

💻 复现代码

可复现 demo

© 版本信息

均是antd相关最新依赖

  • @ant-design/pro-chat 版本: [e.g. 1.0.0]
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

@hakanemrebasol
Copy link

hakanemrebasol commented Sep 24, 2024

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.

@ONLY-yours ONLY-yours self-assigned this Oct 15, 2024
@ONLY-yours ONLY-yours added the bug Something isn't working label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants