build: Add build for browsers

This commit is contained in:
Sojin Park 2024-07-20 11:18:01 +09:00
parent 3f7136734b
commit 701e82300b
4 changed files with 28 additions and 7 deletions

1
.gitignore vendored
View File

@ -19,3 +19,4 @@ dist
out
*.d.ts
*.tgz
umd

View File

@ -35,6 +35,7 @@
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"browser": "./umd/browser.global.js",
"exports": {
".": {
"import": {

8
src/browser.ts Normal file
View File

@ -0,0 +1,8 @@
import * as toolkit from './index';
interface Window {
_: typeof toolkit;
}
declare var window: Window;
window._ = toolkit;

View File

@ -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,
}),
];