You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ git clone git@github.com:cevio/antd5-esm-cjs.git
$ cd antd5-esm-cjs
$ npm i --registry=https://registry.npmmirror.com/
$ node index.mjs
What is expected?
no errors.
What is actually happening?
import { Button } from 'antd';
^^^^^^
SyntaxError: Named export 'Button' not found. The requested module 'antd' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'antd';
const { Button } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Environment
Info
antd
5.0.0
React
18.0.0
System
mac os
Browser
chrome
mjs file module is not supported
sometimes, ssr bootstrap by .mjs, which like vite build --ssr command.
默认情况下,Vite 生成的 SSR 打包产物是 ESM 格式。实验性地支持配置 ssr.format ,但不推荐这样做。未来围绕 SSR 的开发工作将基于 ESM 格式,并且为了向下兼容,commonjs 仍然可用。如果你的 SSR 项目不能使用 ESM,你可以通过 Vite v2 外部启发式方法 设置 legacy.buildSsrCjsExternalHeuristics: true 生成 CJS 格式的产物。
Reproduction link
https://github.com/cevio/antd5-esm-cjs
Steps to reproduce
$ git clone git@github.com:cevio/antd5-esm-cjs.git $ cd antd5-esm-cjs $ npm i --registry=https://registry.npmmirror.com/ $ node index.mjs
What is expected?
no errors.
What is actually happening?
mjs
file module is not supportedsometimes, ssr bootstrap by
.mjs
, which likevite build --ssr
command.https://cn.vitejs.dev/guide/ssr.html#ssr-format
using antd@4.x
no errors.
So this is a bug in antd@5.x
The text was updated successfully, but these errors were encountered: