omrilotan / isbot

🤖/👨‍🦰 Detect bots/crawlers/spiders using the user agent string
https://isbot.js.org/
The Unlicense
876 stars 72 forks source link

Import "default" will always be undefined because there is no matching export in ".../isbot/index.mjs" #246

Closed moltar closed 4 months ago

moltar commented 4 months ago

Steps to reproduce

When bundling a Remix app with Vite, which uses isbot under the hood, the following warning is produced, which comes from esbuild:

▲ [WARNING] Import "default" will always be undefined because there is no matching export in "node_modules/.pnpm/isbot@5.1.1/node_modules/isbot/index.mjs" [import-is-undefined]

    apps/foo/lib/server/index.js:28:53:
      28 │   if ("default" in isbotModule && typeof isbotModule.default === "function") {

Expected behaviour

No warning.

Actual behaviour

Yes warning.

Additional details

Can make an isolated repro, with isbot and esbuild alone, if the problem isn't clear.

moltar commented 4 months ago

Sorry, lack of coffee, this issue is certainly not the isbot issue, but the way Remix uses this internally. Sorry. Closing.

omrilotan commented 4 months ago

No worries. I know there was a Remix release that addressed the nature they import "isbot". In short, when using version 4 and above, use named import instead of default import

- import isbot from "isbot"
+ import { isbot } from "isbot"