Skip to content

๐Ÿ›[BUG] ESM ๆž„ๅปบๅœจ Rspack/Vite ็ญ‰ไธฅๆ ผ ESM ็Žฏๅขƒไธ‹ๅคฑ่ดฅ๏ผš/es/index.js ไธญ็ผบๅฐ‘ๆ–‡ไปถๆ‰ฉๅฑ•ๅย #9434

@weihongyu12

Description

@weihongyu12

ๆ้—ฎๅ‰ๅ…ˆ็œ‹็œ‹๏ผš

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

๐Ÿ› bug ๆ่ฟฐ

ๅœจไฝฟ็”จ Rspack๏ผˆๆˆ– Viteใ€Webpack 5 + "type": "module"๏ผ‰็ญ‰ไธฅๆ ผ ESM ๅ…ผๅฎน็š„ๆž„ๅปบๅทฅๅ…ทๆ—ถ๏ผŒ้กน็›ฎๆž„ๅปบๅคฑ่ดฅใ€‚

@ant-design/pro-components/es/index.js ไธญ็š„ๅฏผๅ‡บ่ฏญๅฅๆœชๅŒ…ๅซ .js ๆ‰ฉๅฑ•ๅ๏ผŒไฝ†ๅœจ็Žฐไปฃ ESM ่ง„่Œƒไธ‹๏ผˆๅฐคๅ…ถๆ˜ฏๅฝ“ package.json ๅซ "type": "module" ๆˆ–ไฝฟ็”จ .mjs ๆ—ถ๏ผ‰๏ผŒๆ‰€ๆœ‰ๅฏผๅ…ฅ่ทฏๅพ„ๅฟ…้กปๆ˜ฏ ๅฎŒๆ•ดๆŒ‡ๅฎš๏ผˆfully specified๏ผ‰ ็š„๏ผŒๅณๅบ”ๅ†™ไธบ๏ผš

export * from "./card/index.js";
export * from "./layout/index.js";

๐Ÿ“ท ๅค็Žฐๆญฅ้ชค

ๅ‡็บงๅˆฐ 3.0.1-0 https://www.npmjs.com/package/@ant-design/pro-components/v/3.0.1-0 ๅŠไปฅไธŠ็‰ˆๆœฌๅฟ…ๅฎš้‡็Žฐ

๐Ÿž ๆœŸๆœ›็ป“ๆžœ

@ant-design/pro-components ็š„ ESM ่พ“ๅ‡บๅบ”ๅ…ผๅฎนๆ ‡ๅ‡† ESM ็Žฏๅขƒ๏ผŒๆ”ฏๆŒๅœจ Rspackใ€Vite ็ญ‰ๅทฅๅ…ทไธญๅผ€็ฎฑๅณ็”จใ€‚

๐Ÿ’ป ๅค็Žฐไปฃ็ 

ยฉ ็‰ˆๆœฌไฟกๆฏ

  • ProComponents ็‰ˆๆœฌ: [e.g. 3.1.3-1]
  • umi ็‰ˆๆœฌ: [ไธไฝฟ็”จumi]
  • ๆต่งˆๅ™จ็Žฏๅขƒ: [ๆ‰€ๆœ‰็Žฏๅขƒ]
  • ๅผ€ๅ‘็Žฏๅขƒ [e.g. Win 11 + Node.js 24 LTS + pnpm + RSPack 1.7.4]

๐Ÿš‘ ๅ…ถไป–ไฟกๆฏ

ๆŽงๅˆถๅฐ่พ“ๅ‡บ

WARNING in ./src/layouts/Default/index.tsx 33:14-24
  โš  ESModulesLinkingWarning: export 'getMenuData' (imported as 'getMenuData') was not found in '@ant-design/pro-components' (module has no exports)
    โ•ญโ”€[33:13]
 31 โ”‚     let t0;
 32 โ”‚     if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
 33 โ”‚         t0 = getMenuData(menu, {
    ยท              โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 34 โ”‚             locale: false
 35 โ”‚         });
    โ•ฐโ”€โ”€โ”€โ”€


WARNING in ./src/layouts/Default/index.tsx 138:36-44
  โš  ESModulesLinkingWarning: export 'ProLayout' (imported as 'ProLayout') was not found in '@ant-design/pro-components' (module has no exports)
     โ•ญโ”€[138:35]
 136 โ”‚     let t8;
 137 โ”‚     if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
 138 โ”‚         t8 = /*#__PURE__*/ _jsxDEV(ProLayout, {
     ยท                                    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 139 โ”‚             title: "Ant Design Pro",
 140 โ”‚             logo: "https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg",
     โ•ฐโ”€โ”€โ”€โ”€


WARNING in ./src/pages/Welcome/index.tsx 97:36-48
  โš  ESModulesLinkingWarning: export 'PageContainer' (imported as 'PageContainer') was not found in '@ant-design/pro-components' (module has no exports)
    โ•ญโ”€[97:35]
 95 โ”‚     let t2;
 96 โ”‚     if ($[5] !== styles.welcomeDiv || $[6] !== t0 || $[7] !== t1) {
 97 โ”‚         t2 = /*#__PURE__*/ _jsxDEV(PageContainer, {
    ยท                                    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 98 โ”‚             children: /*#__PURE__*/ _jsxDEV(ProCard, {
 99 โ”‚                 children: /*#__PURE__*/ _jsxDEV("div", {
    โ•ฐโ”€โ”€โ”€โ”€


WARNING in ./src/pages/Welcome/index.tsx 98:45-51
  โš  ESModulesLinkingWarning: export 'ProCard' (imported as 'ProCard') was not found in '@ant-design/pro-components' (module has no exports)
     โ•ญโ”€[98:44]
  96 โ”‚     if ($[5] !== styles.welcomeDiv || $[6] !== t0 || $[7] !== t1) {
  97 โ”‚         t2 = /*#__PURE__*/ _jsxDEV(PageContainer, {
  98 โ”‚             children: /*#__PURE__*/ _jsxDEV(ProCard, {
     ยท                                             โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  99 โ”‚                 children: /*#__PURE__*/ _jsxDEV("div", {
 100 โ”‚                     className: styles.welcomeDiv,
     โ•ฐโ”€โ”€โ”€โ”€


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 1:1-23
  ร— Module not found: Can't resolve './card' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[1:0]
 1 โ”‚ export * from "./card";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 2 โ”‚ export * from "./descriptions";
 3 โ”‚ export * from "./field";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './card\index.js'?
        
        The request './card' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 2:1-31
  ร— Module not found: Can't resolve './descriptions' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[2:0]
 1 โ”‚ export * from "./card";
 2 โ”‚ export * from "./descriptions";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 3 โ”‚ export * from "./field";
 4 โ”‚ export * from "./form";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './descriptions\index.js'?
        
        The request './descriptions' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 3:1-24
  ร— Module not found: Can't resolve './field' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[3:0]
 1 โ”‚ export * from "./card";
 2 โ”‚ export * from "./descriptions";
 3 โ”‚ export * from "./field";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 4 โ”‚ export * from "./form";
 5 โ”‚ export * from "./layout";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './field\index.js'?
        
        The request './field' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 4:1-23
  ร— Module not found: Can't resolve './form' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[4:0]
 2 โ”‚ export * from "./descriptions";
 3 โ”‚ export * from "./field";
 4 โ”‚ export * from "./form";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 5 โ”‚ export * from "./layout";
 6 โ”‚ export * from "./list";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './form\index.js'?
        
        The request './form' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 5:1-25
  ร— Module not found: Can't resolve './layout' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[5:0]
 3 โ”‚ export * from "./field";
 4 โ”‚ export * from "./form";
 5 โ”‚ export * from "./layout";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 6 โ”‚ export * from "./list";
 7 โ”‚ export * from "./provider";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './layout\index.js'?
        
        The request './layout' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 6:1-23
  ร— Module not found: Can't resolve './list' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[6:0]
 4 โ”‚ export * from "./form";
 5 โ”‚ export * from "./layout";
 6 โ”‚ export * from "./list";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 7 โ”‚ export * from "./provider";
 8 โ”‚ export * from "./skeleton";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './list\index.js'?
        
        The request './list' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 7:1-27
  ร— Module not found: Can't resolve './provider' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
   โ•ญโ”€[7:0]
 5 โ”‚ export * from "./layout";
 6 โ”‚ export * from "./list";
 7 โ”‚ export * from "./provider";
   ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 8 โ”‚ export * from "./skeleton";
 9 โ”‚ export * from "./table";
   โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './provider\index.js'?
        
        The request './provider' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 8:1-27
  ร— Module not found: Can't resolve './skeleton' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
    โ•ญโ”€[8:0]
  6 โ”‚ export * from "./list";
  7 โ”‚ export * from "./provider";
  8 โ”‚ export * from "./skeleton";
    ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  9 โ”‚ export * from "./table";
 10 โ”‚ export * from "./utils";
    โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './skeleton\index.js'?
        
        The request './skeleton' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 9:1-24
  ร— Module not found: Can't resolve './table' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
    โ•ญโ”€[9:0]
  7 โ”‚ export * from "./provider";
  8 โ”‚ export * from "./skeleton";
  9 โ”‚ export * from "./table";
    ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 10 โ”‚ export * from "./utils";
 11 โ”‚ export { version } from "./version";
    โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './table\index.js'?
        
        The request './table' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


ERROR in ./node_modules/.pnpm/@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd/node_modules/@ant-design/pro-components/es/index.js 10:1-24
  ร— Module not found: Can't resolve './utils' in 'D:\project\antd-pro\node_modules\.pnpm\@ant-design+pro-components@_2b666173c5245209f9b5260b18c8dccd\node_modules\@ant-design\pro-components\es'
    โ•ญโ”€[10:0]
  8 โ”‚ export * from "./skeleton";
  9 โ”‚ export * from "./table";
 10 โ”‚ export * from "./utils";
    ยท โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 11 โ”‚ export { version } from "./version";
    โ•ฐโ”€โ”€โ”€โ”€
  help: Did you mean './utils\index.js'?
        
        The request './utils' failed to resolve only because it was resolved as fully specified,
        probably because the origin is strict EcmaScript Module,
        e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'.
        
        The extension in the request is mandatory for it to be fully specified.
        Add the extension to the request.


Rspack compiled with 10 errors and 4 warnings in 3.18 s

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions