unjs / giget

✨ Download templates and git repositories with pleasure!
MIT License
425 stars 37 forks source link

[bun] No matching export in "node_modules/node-fetch-native/dist/proxy.cjs" #145

Closed pi0 closed 5 months ago

pi0 commented 6 months ago

Bun: 1.0.25

Git repo: https://github.com/tkjaergaard/giget-bun-reproduction

Steps to reproduce

  1. Clone repository
  2. Install Bun version 1.0.25 (https://bun.sh)
  3. Run bun install to install dependencies
  4. Run build command
    $ bun build index.ts --outdir=dist --target=node

Error

11 | import { fetch } from 'node-fetch-native/proxy';
              ^
error: No matching export in "node_modules/node-fetch-native/dist/proxy.cjs" for import "fetch"
    at /Users/thomaskjaergaard/projects/internal/giget-bun-reproduction/node_modules/giget/dist/index.mjs:11:10

Originally posted by @tkjaergaard in https://github.com/unjs/giget/issues/140#issuecomment-1910092203

tkjaergaard commented 6 months ago

If i set the build target to browser it works. But if i set it to bun or node i get the error.

When running the script using bun index.ts, i don't see the error either 🤔

Also if i use import { fetch } from 'node-fetch-native/proxy' installed as a dependency i see the error.

Seems to more of an error with node-fetch-native/proxy than giget?

I've added an example of using node-fetch-native directly in the reproduction repo: fetch-native-proxy.ts

tkjaergaard commented 5 months ago

@pi0 any progress on this? 😊

pi0 commented 5 months ago

Hi. It is definitely on my track. only 24h per day is not enough (notes) 😅

tkjaergaard commented 5 months ago

@pi0 All good, just interested in where this was stranded 💪

tkjaergaard commented 5 months ago

@pi0 I've identified the issue. It's related to unjs/node-fetch-native.

I've re-created the issue here: https://github.com/unjs/node-fetch-native/issues/114.

tkjaergaard commented 5 months ago

@pi0 Think this should be closed since we fixed it in https://github.com/unjs/node-fetch-native/issues/114 😊✌️