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

v4升级至v5中,获得less变量时异常 #38755

Closed
qiqizjl opened this issue Nov 20, 2022 · 8 comments
Closed

v4升级至v5中,获得less变量时异常 #38755

qiqizjl opened this issue Nov 20, 2022 · 8 comments

Comments

@qiqizjl
Copy link

qiqizjl commented Nov 20, 2022

Reproduction link

https://github.com/qiqizjl/antd-v4-to-v5

Steps to reproduce

  1. 使用pro 工具创建一个基于umijs4的ant-design-pro
  2. 将antd升级至5并引入@ant-design/compatible
  3. 按照教程在config/config.ts中增加对less变量的处理
  4. 重新启动服务

What is expected?

服务正常启用。less中的变量被正确编译

What is actually happening?

启用报错,提示无法解析config/config.ts

  [cause]: /Users/sean/Documents/node-work/antd-v4-to-v5/node_modules/.pnpm/antd@5.0.0_sfoxds7t5ydpegc3knd667wn6m/node_modules/antd/es/style/index.js:1
  import _extends from "@babel/runtime/helpers/esm/extends";
  ^^^^^^
  
  SyntaxError: Cannot use import statement outside a module
      at Object.compileFunction (node:vm:360:18)
      at wrapSafe (node:internal/modules/cjs/loader:1088:15)
      at Module._compile (node:internal/modules/cjs/loader:1123:27)
      at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
      at Object.newLoader [as .js] (/Users/sean/Documents/node-work/antd-v4-to-v5/node_modules/.pnpm/@umijs utils@4.0.32/node_modules/@umijs/utils/compiled/pirates/index.js:1:1684)
      at Module.load (node:internal/modules/cjs/loader:1037:32)
      at Module._load (node:internal/modules/cjs/loader:878:12)
      at Module.require (node:internal/modules/cjs/loader:1061:19)
      at require (node:internal/modules/cjs/helpers:103:18)
      at Object.<anonymous> (/Users/sean/Documents/node-work/antd-v4-to-v5/node_modules/.pnpm/@ant-design compatible@5.0.0_gi6qubjwjy77tewbbegvn2c62i/node_modules/@ant-design/compatible/lib/comment/style/index.js:16:14)

image

Environment Info
antd undefined
React 17.0.2
System macOS 13.1
Browser Edge 109.0.1505.0 Canary
@zombieJ
Copy link
Member

zombieJ commented Nov 20, 2022

@MadCcc 配置项这块看起来也需要 lib,否则得绕一圈。

@WalterZou
Copy link

升级过程中遇到类似的问题
image

@chunsch
Copy link
Contributor

chunsch commented Nov 21, 2022

@zombieJ 和之前的 locale 类似,node 环境引用 esm(@ant-design/compatible 引用 antd/es 目录的文件)。目前想到是 antd export 相关方法(已提 PR ⬆️),compatible 直接从 antd 引用。不知道有没更好的方式 : D

@zombieJ
Copy link
Member

zombieJ commented Nov 21, 2022

@zombieJ 和之前的 locale 类似,node 环境引用 esm(@ant-design/compatible 引用 antd/es 目录的文件)。目前想到是 antd export 相关方法(已提 PR ⬆️),compatible 直接从 antd 引用。不知道有没更好的方式 : D

我比较担心这样最后 export 一堆东西出来,这样的话还不如恢复 lib。

@chunsch
Copy link
Contributor

chunsch commented Nov 21, 2022

@zombieJ 嗯嗯,目前来看,把 lib 加回来,确实更具备兼容性。

@little-time
Copy link

little-time commented Nov 21, 2022

@zombieJ @chunsch 我也遇到了这个问题,请问怎么解决呢

@zombieJ
Copy link
Member

zombieJ commented Nov 21, 2022

@zombieJ @chunsch 我也遇到了这个问题,请问怎么解决呢

加一下 lib

@MadCcc
Copy link
Member

MadCcc commented Nov 23, 2022

Fixed in ant-design/compatible#151

@MadCcc MadCcc closed this as completed Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants