oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.86k stars 2.56k forks source link

Why can't import some packages from npm? #9504

Open 826327700 opened 3 months ago

826327700 commented 3 months ago

What version of Bun is running?

1.0.33

What platform is your computer?

Windows 11

What steps can reproduce the bug?

import PSD from "psd";
var psd = PSD.fromFile("a.psd");
psd.parse();
console.log(psd.tree().export());

What is the expected behavior?

I hope it work

What do you see instead?

TypeError: undefined is not a function (near '...PSD.fromFile...')

Additional information

No response

Electroid commented 3 months ago

Looks like for some reason, Bun is resolving the lib/psd.coffee instead of index.js in the psd package.

❯ bun psd.ts
Module {
  __esModule: true,
  default: "/Users/ashcon/Desktop/code/sandbox/node_modules/psd/lib/psd.coffee",
}
1 | import PSD from "psd";
2 | console.log(PSD);
3 | var psd = PSD.fromFile("a.psd");
              ^
TypeError: PSD.fromFile is not a function. (In 'PSD.fromFile("a.psd")', 'PSD.fromFile' is undefined)
      at /Users/ashcon/Desktop/code/sandbox/psd.ts:3:11