Skip to content

Commit

Permalink
add cjs support
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Oct 8, 2024
1 parent 2f79c0c commit 13aef39
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
8 changes: 0 additions & 8 deletions build.mjs

This file was deleted.

22 changes: 22 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -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",
})
])
Binary file modified bun.lockb
Binary file not shown.
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -23,8 +30,7 @@
"bugs": "https://github.com/wobsoriano/pkg-name/issues",
"author": "Robert Soriano <sorianorobertc@gmail.com>",
"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"
}
}

0 comments on commit 13aef39

Please sign in to comment.