Skip to content

πŸ›[BUG] @ant-design/pro-components@3.1.14-1: the CommonJS build (main, lib/) requires antd's ESM build (antd/es/locale/zh_CN), so the main entry cannot be loaded by NodeΒ #9661

Description

@yuki2006

πŸ› bug 描述 / Description

Follow-up to #9656: "type": "module" was removed in 3.1.13-0 (thanks!), but the package's main entry is still unusable under Node. lib/provider/index.js (CommonJS build) contains:

var _zh_CN = _interopRequireDefault(require("antd/es/locale/zh_CN"));

i.e. the CJS build reaches into antd's ESM build.

  • On Node < 22, requiring the ESM-syntax antd/es/locale/zh_CN.js as CommonJS fails with:

    SyntaxError: Cannot use import statement outside a module
        at .../antd/es/locale/zh_CN.js:1
        at Object.<anonymous> (.../@ant-design/pro-components/lib/provider/index.js:19:37)
    
  • On Node β‰₯ 22 (require(esm) support), the file is re-loaded as ESM instead, and its extension-less relative import (../calendar/locale/zh_CN) then fails with:

    Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../antd/es/calendar/locale/zh_CN'
    imported from .../antd/es/locale/zh_CN.js
    

Either way, require('@ant-design/pro-components') crashes immediately, which breaks any tool that resolves the package through main (Vitest externalizing node_modules, Jest, plain Node SSR, …).

lib/provider/index.js is the only file under lib/ that references antd/es/* β€” the CJS build should require antd/lib/locale/zh_CN (or the root antd/locale/zh_CN) instead.

πŸ“· 倍现ζ­₯ιͺ€ / Steps to reproduce

  1. npm install @ant-design/pro-components@3.1.14-1 antd@^6 react@^19 react-dom@^19
  2. node -e "require('@ant-design/pro-components')"

🏞 ζœŸζœ›η»“ζžœ / Expected

The main (CommonJS) entry can be loaded by Node; the CJS build only references other CJS builds.

πŸ’» 倍现代码 / Reproduction

Online (CodeSandbox Devbox β€” run npm install && npm test in the terminal; the devbox runs Node 20, so you get the SyntaxError variant):
https://codesandbox.io/p/devbox/92qjl3

πŸš‘ 兢他俑息 / Environment

  • @ant-design/pro-components: 3.1.14-1 / antd: 6.5.0 / react: 19.x
  • Node: reproduced on both v20.12.0 (SyntaxError) and v24 (ERR_MODULE_NOT_FOUND)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions