diff --git a/package.json b/package.json index 01e9ec0..9ab7068 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "main": "./dist/tcgdex.node.js", "module": "./dist/tcgdex.node.mjs", "types": "./dist/tcgdex.node.d.ts", + "browser": "./dist/tcgdex.browser.global.js", "exports": { ".": { "require": { @@ -11,8 +12,8 @@ "default": "./dist/tcgdex.node.js" }, "import": { - "default": "./dist/tcgdex.node.mjs", - "types": "./dist/tcgdex.node.d.mts" + "types": "./dist/tcgdex.node.d.mts", + "default": "./dist/tcgdex.node.mjs" } } }, @@ -30,7 +31,9 @@ "api", "typescript", "javascript", - "typing" + "typing", + "browser", + "node" ], "license": "MIT", "devDependencies": { @@ -55,7 +58,7 @@ }, "scripts": { "prebuild": "node scripts/export-version-number.js", - "build": "tsup ./src/tcgdex.node.ts --format cjs,esm --dts --clean && tsup ./src/tcgdex.browser.ts --format iife --minify --sourcemap", + "build": "tsup ./src/tcgdex.node.ts --format cjs,esm --dts --clean && tsup ./src/tcgdex.browser.ts --format iife --global-name TCGdex --sourcemap", "prepublishOnly": "npm run build", "lint": "eslint", "test": "jest --coverage" diff --git a/src/tcgdex.browser.ts b/src/tcgdex.browser.ts index 352e68f..ffd4a6c 100644 --- a/src/tcgdex.browser.ts +++ b/src/tcgdex.browser.ts @@ -1,11 +1,6 @@ -import TCGdex from './tcgdex' import unfetch from 'unfetch' +import TCGdex from './tcgdex' TCGdex.fetch = window.fetch ?? unfetch as any -if (typeof global !== 'undefined') { - global.TCGdex = TCGdex -} -if (typeof window !== 'undefined') { - (window as any).TCGdex = TCGdex -} +export default TCGdex