Skip to content

Commit

Permalink
Fix browser entry
Browse files Browse the repository at this point in the history
  • Loading branch information
omrilotan committed Apr 29, 2024
1 parent b9973b6 commit 4c5f803
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isbot",
"version": "5.1.5",
"version": "5.1.6-rc.1",
"description": "🤖/👨‍🦰 Recognise bots/crawlers/spiders using the user agent string.",
"keywords": [
"bot",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/procedure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ esbuild src/index.ts --outfile=index.mjs --bundle --platform=neutral --format=es
failures=$((failures + $?))

echo "→ Build browser file (iife)"
esbuild src/browser.ts --outfile=index.iife.js --bundle --platform=neutral --format=iife --global-name=isbot --log-level=warning --target=es2016
esbuild src/browser.ts --outfile=index.iife.js --bundle --platform=neutral --format=iife --log-level=warning --target=es2016
failures=$((failures + $?))

echo "→ Build TypeScript declaration file"
Expand Down
18 changes: 17 additions & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import { isbot } from ".";

export default isbot;
(function () {
if (typeof globalThis === "object") {
globalThis.isbot = isbot;
return;
}
if (typeof window === "object") {
window.isbot = isbot;
return;
}
if (typeof global === "object") {
global.isbot = isbot;
return;
}
if (typeof self === "object") {
self.isbot = isbot;
}
})();

0 comments on commit 4c5f803

Please sign in to comment.