Skip to content

Commit

Permalink
build: Add build for browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
raon0211 committed Jul 20, 2024
1 parent 3f71367 commit 701e823
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dist
out
*.d.ts
*.tgz
umd
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"browser": "./umd/browser.global.js",
"exports": {
".": {
"import": {
Expand Down
8 changes: 8 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as toolkit from './index';

interface Window {
_: typeof toolkit;
}

declare var window: Window;
window._ = toolkit;
25 changes: 18 additions & 7 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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,
}),
];

0 comments on commit 701e823

Please sign in to comment.