fix: module exports not working

Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
This commit is contained in:
Florian Bouillon 2023-07-18 12:46:39 +02:00
parent c392b27cac
commit 98c80fcd20
2 changed files with 9 additions and 11 deletions

View File

@ -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"

View File

@ -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