diff --git a/.gitignore b/.gitignore index 046a8d305..6f91fbb65 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ dist out *.d.ts *.tgz +umd \ No newline at end of file diff --git a/package.json b/package.json index 5eda852a7..497b86711 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", + "browser": "./umd/browser.global.js", "exports": { ".": { "import": { diff --git a/src/browser.ts b/src/browser.ts new file mode 100644 index 000000000..6671ab0ba --- /dev/null +++ b/src/browser.ts @@ -0,0 +1,8 @@ +import * as toolkit from './index'; + +interface Window { + _: typeof toolkit; +} + +declare var window: Window; +window._ = toolkit; diff --git a/tsup.config.ts b/tsup.config.ts index b77c30cc4..68247437b 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,9 +1,20 @@ import { defineConfig } from 'tsup'; -export default defineConfig({ - format: ['cjs', 'esm'], - entry: ['src/*.ts', 'src/*/*.ts', '!**/*.{spec,test,test-d}.*'], - sourcemap: true, - dts: true, - clean: true, -}); +export default [ + defineConfig({ + format: ['cjs', 'esm'], + entry: ['src/*.ts', 'src/*/*.ts', '!**/*.{spec,test,test-d}.*'], + sourcemap: true, + dts: true, + clean: true, + }), + defineConfig({ + format: ['iife'], + outDir: 'umd', + entry: ['src/browser.ts'], + sourcemap: true, + dts: false, + clean: true, + minify: true, + }), +];