Skip to content

Commit 26a7ca0

Browse files
migrate to tsup instead of bun builder
1 parent f74f658 commit 26a7ca0

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

bun.lockb

51.6 KB
Binary file not shown.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@curiousleaf/utils",
33
"description": "A lightweight set of utilities",
4-
"version": "1.0.34",
4+
"version": "1.0.35",
55
"license": "MIT",
66
"author": {
77
"name": "Piotr Kulpinski",
@@ -10,11 +10,11 @@
1010
},
1111
"repository": "curious-leaf/utils",
1212
"main": "./dist/index.js",
13+
"module": "./dist/index.mjs",
1314
"types": "./dist/index.d.ts",
14-
"files": ["./dist/*.js", "./dist/*.d.ts"],
15+
"files": ["dist"],
1516
"scripts": {
16-
"build": "bun build ./src/index.ts --outdir ./dist && bun run build:declaration",
17-
"build:declaration": "tsc --emitDeclarationOnly",
17+
"build": "tsup",
1818
"lint": "bun biome lint --apply .",
1919
"format": "bun biome format --write ."
2020
},
@@ -28,6 +28,7 @@
2828
"@biomejs/biome": "^1.7.1",
2929
"@types/bun": "^1.1.2",
3030
"prettier": "^3.1.1",
31+
"tsup": "^8.3.0",
3132
"typescript": "^5.3.3"
3233
},
3334
"peerDependencies": {

tsconfig.json

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

1313
/* Language and Environment */
14-
"target": "esnext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
14+
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
1515
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16-
// "jsx": "react-jsx", /* Specify what JSX code is generated. */
16+
// "jsx": "preserve", /* Specify what JSX code is generated. */
1717
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
1818
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
1919
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
@@ -25,9 +25,9 @@
2525
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
2626

2727
/* Modules */
28-
"module": "ESNext" /* Specify what module code is generated. */,
29-
"rootDir": "src" /* Specify the root folder within your source files. */,
30-
"moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */,
28+
"module": "commonjs" /* Specify what module code is generated. */,
29+
// "rootDir": "./", /* Specify the root folder within your source files. */
30+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
3131
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
3232
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
3333
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
@@ -44,18 +44,18 @@
4444
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
4545

4646
/* JavaScript Support */
47-
"allowJs": false /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
47+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
4848
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
49-
"maxNodeModuleJsDepth": 1 /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */,
49+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
5050

5151
/* Emit */
5252
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
5353
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
54-
"emitDeclarationOnly": true /* Only output d.ts files and not JavaScript files. */,
55-
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
54+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5656
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57-
"outFile": "dist/index.d.ts" /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */,
58-
"outDir": "dist" /* Specify an output folder for all emitted files. */,
57+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
5959
// "removeComments": true, /* Disable emitting comments. */
6060
// "noEmit": true, /* Disable emitting files from a compilation. */
6161
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
@@ -70,13 +70,13 @@
7070
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
7171
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
7272
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
73-
// "declarationDir": "dist", /* Specify the output directory for generated declaration files. */
73+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
7474
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
7575

7676
/* Interop Constraints */
7777
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
7878
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
79-
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
79+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
8080
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
8181
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
8282
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
@@ -91,22 +91,19 @@
9191
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
9292
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
9393
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
94-
"noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
95-
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
94+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
95+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
9696
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
97-
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
98-
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
99-
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
97+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
98+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
99+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
100100
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
101101
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
102102
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
103-
"allowUnreachableCode": true /* Disable error reporting for unreachable code. */,
103+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
104104

105105
/* Completeness */
106-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
107106
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108-
},
109-
110-
"include": ["src"],
111-
"exclude": ["node_modules"]
107+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
108+
}
112109
}

tsup.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from "tsup"
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
format: ["cjs", "esm"], // Build for commonJS and ESmodules
6+
dts: true, // Generate declaration file (.d.ts)
7+
splitting: false,
8+
sourcemap: true,
9+
clean: true,
10+
})

0 commit comments

Comments
 (0)