esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Failed to import antd

Open gxy01 opened this issue 7 months ago • 5 comments

Failing module

  • GitHub: https://github.com/ant-design/ant-design
  • npm: https://www.npmjs.com/package/antd
import { Button } from "https://esm.sh/antd"

Error message

Uncaught SyntaxError: The requested module '/@ant-design/colors@^7.0.0?target=es2022&dev' does not provide an export named 'blue' (at AntdIcon.js:10:10)


The error was caused by https://www.npmjs.com/package/@ant-design/colors

The bundle output was wrong. Maybe was caused by last export * from "./types"; , I guess.

Image

gxy01 avatar Apr 24 '25 09:04 gxy01

I get this issue too

mnm1001 avatar May 03 '25 07:05 mnm1001

esbuild ignores named exports defined by export * expr, i added a workaround for single export *, multiple export * currently cannot work

see https://github.com/evanw/esbuild/issues/1737

ije avatar May 03 '25 08:05 ije

esbuild ignores named exports defined by export * expr, i added a workaround for single export *, multiple export * currently cannot work

see evanw/esbuild#1737

I submitted a PR to @ant-design/colors, and it has been merged. Right now there's only one export * statement left in the module, but it's still throwing an error.

import { blue } from 'https://esm.sh/@ant-design/colors' still does't work.

But

import colors from 'https://esm.sh/@ant-design/colors';
const blue=colors.blue;

worked

gxy01 avatar May 21 '25 05:05 gxy01

Same error here. It seems that many libraries might be affected by this issue. While I can work around it by destructuring from default in my own usage, it's hard to avoid problems when it's used this way by intermediary libraries. I’d greatly appreciate any insights or potential solutions.

init-center avatar Jun 15 '25 05:06 init-center

esbuild ignores named exports defined by export * expr, i added a workaround for single export *, multiple export * currently cannot work

see evanw/esbuild#1737

I noticed that @ant-design/colors does not have a default export, but the version processed by esm.sh bundles all named exports into the default, while the named exports themselves are missing. I'm not very familiar with esm.sh’s bundling process.

@gxy01 mentioned that he submitted a PR to @ant-design/colors, but the issue still hasn't been resolved.

I’d really appreciate any help or suggestions you can provide. Thank you for taking the time to look into this!

init-center avatar Jun 15 '25 12:06 init-center