From 13aef39efb2377de5141b1ded1a7b0fc79abc88d Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 8 Oct 2024 10:50:47 -0700 Subject: [PATCH] add cjs support --- build.mjs | 8 -------- build.ts | 22 ++++++++++++++++++++++ bun.lockb | Bin 9106 -> 10178 bytes package.json | 18 ++++++++++++------ 4 files changed, 34 insertions(+), 14 deletions(-) delete mode 100644 build.mjs create mode 100644 build.ts diff --git a/build.mjs b/build.mjs deleted file mode 100644 index dd6ef5f..0000000 --- a/build.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import dts from 'bun-plugin-dts' - -await Bun.build({ - entrypoints: ['./src/index.ts'], - outdir: './dist', - minify: true, - plugins: [dts()] -}) diff --git a/build.ts b/build.ts new file mode 100644 index 0000000..395c65a --- /dev/null +++ b/build.ts @@ -0,0 +1,22 @@ +import type { BuildConfig } from 'bun' +import dts from 'bun-plugin-dts' + +const defaultBuildConfig: BuildConfig = { + entrypoints: ['./src/index.ts'], + outdir: './dist', + minify: true +} + +await Promise.all([ + Bun.build({ + ...defaultBuildConfig, + plugins: [dts()], + format: 'esm', + naming: "[dir]/[name].js", + }), + Bun.build({ + ...defaultBuildConfig, + format: 'cjs', + naming: "[dir]/[name].cjs", + }) +]) diff --git a/bun.lockb b/bun.lockb index 7b8645eedc19e20b45ca276ade0b90afb07d8b86..9cc21bd272003d5ab6e448e1b1ef072821eea237 100755 GIT binary patch delta 3019 zcmb_e3s6&68ou`?0TZ4Hk0c}^kcqD#2?>#RNT6)HsTQGYeJxT^0;V7j10qx&Dz0d4 z5l+`ZYq3(b?J8R>Y9EL#SglZSeXVY5aTix@eeQI2)wL_Q|9{~!VPZe;;`!h89FZH6k>aIUbPR~_lT}nt2pC5RVZaKf3-{WhVO0iAR zG+$k7P>fC}s-z%4vM6VTLj()H6jfIO=nZ%b&>t`hFc7dZXJx(%#`ow^zS0<11XF5g zY`&ABD9}-NZ45U6N?~3F=mmHd_K5+z0sRVK;BYO=Da^@rEGu-DJ3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dh|s#@DU+~xWi=d%41uIbg&Xa}ZkX%a{ujx`>DT}O diff --git a/package.json b/package.json index 055aea8..f374fcc 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,18 @@ { "name": "pkg-name", + "type": "module", "version": "0.0.0", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "description": "", + "exports": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, "scripts": { - "build": "bun run build.mjs", + "build": "bun run build.ts", "prepublishOnly": "bun run build" }, "files": [ @@ -23,8 +30,7 @@ "bugs": "https://github.com/wobsoriano/pkg-name/issues", "author": "Robert Soriano ", "devDependencies": { - "bun-plugin-dts": "^0.2.1", - "@types/bun": "^1.0.0", - "typescript": "^5.2.2" + "bun-plugin-dts": "^0.2.3", + "@types/bun": "^1.1.10" } }