esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Error: No matching export in <file> for import <named import>.

Open nextgennexia opened this issue 9 months ago • 1 comments

Hello! I encountered a problem when one of the entry points contains an absolute path to the cdn.

Example:

// index.js
import { useState } from "./shared-react-package.js";
// shared-react-package.js
export * from "https://esm.sh/[email protected]/es2022/react.development.mjs";
export { default } from "https://esm.sh/[email protected]/es2022/react.development.mjs";

Run esbuild index.js shared-react.package.js --bundle --outdir=out --conditions=development --format=esm --splitting

My case:

  • project on vite
  • there is an alias on react: react@npm:shared-react
  • there is an package @react-hookz/web
  • run script "dev": "vite"

Vite starts the optimizer with deps:

  • node_modules/@react-hookz/web/dist/useAsync/index.js (contain named imports from react)
  • node_modules/react/react.development.js (react alias of npm. contain re-export esm.sh)

Can I hope that this will work in future versions?

node: 20.17.0 esbuild: 0.25.1 vite: 6.2.2

nextgennexia avatar Mar 25 '25 11:03 nextgennexia

Just want to add the playground link where rollup works fine.

hyrious avatar Mar 25 '25 12:03 hyrious