@culur/config-tsdown 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # @culur/config-tsdown
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 🎉 Add `@culur/config-tsdown` package as a replacement for `@culur/config-tsup` ([`c828933`](https://github.com/culur/culur/commit/c828933f1c39505be8b2b1c5cbca6f0549bfa02d)) ([@phamhongphuc](https://github.com/phamhongphuc)).
8
+
9
+ This new package provides a standardized configuration for `tsdown`, supporting ESM and CJS formats with built-in TypeScript definitions and source mapping.
10
+
11
+ - ⚙️ Migrate build system from `tsup` to `tsdown` across all packages ([`83b3791`](https://github.com/culur/culur/commit/83b379149b9e9536f4cd161976762afb35b6b61a)) ([@phamhongphuc](https://github.com/phamhongphuc)).
12
+
13
+ ### Patch Changes
14
+
15
+ - ⚙️ Added `tsdown` to `devDependencies` for development and testing ([`1521d34`](https://github.com/culur/culur/commit/1521d34b3a6ac832a6f85d7ae8d3cc41f8622109)) ([@phamhongphuc](https://github.com/phamhongphuc)).
16
+
17
+ - 🔨 Update internal references and configurations to align with the renaming of `defineObject` to `defineObjectFactory` ([`93080d5`](https://github.com/culur/culur/commit/93080d5424969774178f2035a3fc623b199ca64d)) ([@phamhongphuc](https://github.com/phamhongphuc)).
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # `@culur/config-tsdown`
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@culur/config-tsdown?logo=npm)](https://www.npmjs.com/package/@culur/config-tsdown)
4
+ [![NPM Download](https://img.shields.io/npm/dm/@culur/config-tsdown?logo=npm)](https://www.npmjs.com/package/@culur/config-tsdown)
5
+ [![NPM License](https://img.shields.io/npm/l/@culur/config-tsdown)](../../LICENSE)
6
+
7
+ [![CodeFactor](https://www.codefactor.io/repository/github/culur/culur/badge)](https://www.codefactor.io/repository/github/culur/culur)
8
+ [![Codecov](https://img.shields.io/codecov/c/github/culur/culur)](https://app.codecov.io/gh/culur/culur)
9
+ [![Build and release](https://github.com/culur/culur/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/culur/culur/actions/workflows/build-and-release.yml)
10
+
11
+ > Sharing [tsdown](https://tsdown.dev/) configurations.
12
+
13
+ ## ✨ Features
14
+
15
+ The library includes several tsdown configurations for reuse.
16
+
17
+ ### 1. Shared configuration
18
+
19
+ ```js
20
+ const sharedConfig = {
21
+ sourcemap: true,
22
+ clean: true,
23
+ dts: true,
24
+ entry: [
25
+ 'src/**/*.ts', //
26
+ '!src/**/*.test.ts',
27
+ '!src/**/*.spec.ts',
28
+ ],
29
+ treeshake: true,
30
+ };
31
+ ```
32
+
33
+ ### 2. There are 3 complete configurations
34
+
35
+ | Name | Format |
36
+ | --------- | ------------ |
37
+ | `esm` | `esm` |
38
+ | `cjs` | `cjs` |
39
+ | `esm_cjs` | `esm`, `cjs` |
40
+
41
+ ## 💿 Installation
42
+
43
+ Add `@culur/config-tsdown` dependency to your project.
44
+
45
+ ```bash
46
+ # Using npm
47
+ npm install @culur/config-tsdown --save-dev
48
+
49
+ # Using pnpm
50
+ pnpm install @culur/config-tsdown --dev
51
+
52
+ # Using yarn
53
+ yarn add @culur/config-tsdown --dev
54
+ ```
55
+
56
+ Other packages:
57
+
58
+ - You also need to install `tsdown` and `typescript` packages in `devDependencies`.
59
+
60
+ ## 📖 Usage
61
+
62
+ ### 1. Use the config directly
63
+
64
+ In `tsdown.config.ts`, use:
65
+
66
+ ```ts
67
+ import { cjs, esm, esm_cjs } from '@culur/config-tsdown';
68
+
69
+ // format 'esm'
70
+ export default esm;
71
+
72
+ // format 'cjs'
73
+ export default cjs;
74
+
75
+ // format 'esm_cjs'
76
+ export default esm_cjs;
77
+ ```
78
+
79
+ ### 2. Overwrite some properties from the shared configuration
80
+
81
+ In `tsdown.config.ts`, use `defineConfig`:
82
+
83
+ ```ts
84
+ import { defineConfig, esm } from '@culur/config-tsdown';
85
+
86
+ export default defineConfig({
87
+ ...esm,
88
+ //...
89
+ });
90
+ ```
91
+
92
+ ## 🔄 Migrate from tsup
93
+
94
+ If you are migrating from `@culur/config-tsup`, you can follow these steps:
95
+
96
+ 1. Replace `@culur/config-tsup` with `@culur/config-tsdown`.
97
+ 2. Update your `tsup.config.ts` to `tsdown.config.ts`.
98
+ 3. Change imports from `@culur/config-tsup` to `@culur/config-tsdown`.
99
+
100
+ For more details on migrating from tsup to tsdown, please refer to the official [tsdown migration guide](https://tsdown.dev/guide/migrate-from-tsup).
101
+
102
+ ## 📜 Scripts
103
+
104
+ Some commonly used scripts in `package.json`.
105
+
106
+ ```json
107
+ {
108
+ "exports": {
109
+ ".": {
110
+ "import": {
111
+ "types": "./dist/index.d.mts",
112
+ "default": "./dist/index.cjs"
113
+ },
114
+ "require": {
115
+ "types": "./dist/index.d.cts",
116
+ "default": "./dist/index.cjs"
117
+ }
118
+ }
119
+ },
120
+ "files": ["CHANGELOG.md", "LICENSE", "README.md", "dist", "src"],
121
+ "scripts": {
122
+ "build": "tsdown"
123
+ }
124
+ }
125
+ ```
126
+
127
+ ## 🗃️ Changelog
128
+
129
+ See [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
130
+
131
+ ## 🔒 License
132
+
133
+ See [LICENSE](../../LICENSE) for license rights and limitations (MIT).
package/dist/index.cjs ADDED
@@ -0,0 +1,33 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_types = require("./types-BrvIhA3f.cjs");
3
+ //#region src/index.ts
4
+ const sharedConfig = require_types.defineConfigPure({
5
+ sourcemap: true,
6
+ clean: true,
7
+ dts: true,
8
+ entry: [
9
+ "src/**/*.ts",
10
+ "!src/**/*.test.ts",
11
+ "!src/**/*.spec.ts"
12
+ ],
13
+ treeshake: true
14
+ });
15
+ const esm = require_types.defineConfigPure({
16
+ ...sharedConfig,
17
+ format: "esm"
18
+ });
19
+ const cjs = require_types.defineConfigPure({
20
+ ...sharedConfig,
21
+ format: "cjs"
22
+ });
23
+ const esm_cjs = require_types.defineConfigPure({
24
+ ...sharedConfig,
25
+ format: ["esm", "cjs"]
26
+ });
27
+ //#endregion
28
+ exports.cjs = cjs;
29
+ exports.defineConfig = require_types.defineConfig;
30
+ exports.esm = esm;
31
+ exports.esm_cjs = esm_cjs;
32
+
33
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["defineConfigPure"],"sources":["../src/index.ts"],"sourcesContent":["import { defineConfigPure } from './types';\n\nexport { defineConfig } from './types';\n\nconst sharedConfig = defineConfigPure({\n sourcemap: true,\n clean: true,\n dts: true,\n entry: [\n 'src/**/*.ts', //\n '!src/**/*.test.ts',\n '!src/**/*.spec.ts',\n ] as const,\n treeshake: true,\n});\n\nexport const esm = defineConfigPure({\n ...sharedConfig,\n format: 'esm',\n});\n\nexport const cjs = defineConfigPure({\n ...sharedConfig,\n format: 'cjs',\n});\n\nexport const esm_cjs = defineConfigPure({\n ...sharedConfig,\n format: ['esm', 'cjs'] as const,\n});\n"],"mappings":";;;AAIA,MAAM,eAAeA,cAAAA,iBAAiB;CACpC,WAAW;CACX,OAAO;CACP,KAAK;CACL,OAAO;EACL;EACA;EACA;EACD;CACD,WAAW;CACZ,CAAC;AAEF,MAAa,MAAMA,cAAAA,iBAAiB;CAClC,GAAG;CACH,QAAQ;CACT,CAAC;AAEF,MAAa,MAAMA,cAAAA,iBAAiB;CAClC,GAAG;CACH,QAAQ;CACT,CAAC;AAEF,MAAa,UAAUA,cAAAA,iBAAiB;CACtC,GAAG;CACH,QAAQ,CAAC,OAAO,MAAM;CACvB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { defineConfig } from "./types/index.cjs";
2
+
3
+ //#region src/index.d.ts
4
+ declare const esm: {
5
+ format: "esm";
6
+ sourcemap: true;
7
+ clean: true;
8
+ dts: true;
9
+ entry: ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.spec.ts"];
10
+ treeshake: true;
11
+ };
12
+ declare const cjs: {
13
+ format: "cjs";
14
+ sourcemap: true;
15
+ clean: true;
16
+ dts: true;
17
+ entry: ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.spec.ts"];
18
+ treeshake: true;
19
+ };
20
+ declare const esm_cjs: {
21
+ format: ["esm", "cjs"];
22
+ sourcemap: true;
23
+ clean: true;
24
+ dts: true;
25
+ entry: ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.spec.ts"];
26
+ treeshake: true;
27
+ };
28
+ //#endregion
29
+ export { cjs, defineConfig, esm, esm_cjs };
30
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,30 @@
1
+ import { defineConfig } from "./types/index.mjs";
2
+
3
+ //#region src/index.d.ts
4
+ declare const esm: {
5
+ format: "esm";
6
+ sourcemap: true;
7
+ clean: true;
8
+ dts: true;
9
+ entry: ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.spec.ts"];
10
+ treeshake: true;
11
+ };
12
+ declare const cjs: {
13
+ format: "cjs";
14
+ sourcemap: true;
15
+ clean: true;
16
+ dts: true;
17
+ entry: ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.spec.ts"];
18
+ treeshake: true;
19
+ };
20
+ declare const esm_cjs: {
21
+ format: ["esm", "cjs"];
22
+ sourcemap: true;
23
+ clean: true;
24
+ dts: true;
25
+ entry: ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.spec.ts"];
26
+ treeshake: true;
27
+ };
28
+ //#endregion
29
+ export { cjs, defineConfig, esm, esm_cjs };
30
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,29 @@
1
+ import { n as defineConfigPure, t as defineConfig } from "./types-78D1wC2M.mjs";
2
+ //#region src/index.ts
3
+ const sharedConfig = defineConfigPure({
4
+ sourcemap: true,
5
+ clean: true,
6
+ dts: true,
7
+ entry: [
8
+ "src/**/*.ts",
9
+ "!src/**/*.test.ts",
10
+ "!src/**/*.spec.ts"
11
+ ],
12
+ treeshake: true
13
+ });
14
+ const esm = defineConfigPure({
15
+ ...sharedConfig,
16
+ format: "esm"
17
+ });
18
+ const cjs = defineConfigPure({
19
+ ...sharedConfig,
20
+ format: "cjs"
21
+ });
22
+ const esm_cjs = defineConfigPure({
23
+ ...sharedConfig,
24
+ format: ["esm", "cjs"]
25
+ });
26
+ //#endregion
27
+ export { cjs, defineConfig, esm, esm_cjs };
28
+
29
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { defineConfigPure } from './types';\n\nexport { defineConfig } from './types';\n\nconst sharedConfig = defineConfigPure({\n sourcemap: true,\n clean: true,\n dts: true,\n entry: [\n 'src/**/*.ts', //\n '!src/**/*.test.ts',\n '!src/**/*.spec.ts',\n ] as const,\n treeshake: true,\n});\n\nexport const esm = defineConfigPure({\n ...sharedConfig,\n format: 'esm',\n});\n\nexport const cjs = defineConfigPure({\n ...sharedConfig,\n format: 'cjs',\n});\n\nexport const esm_cjs = defineConfigPure({\n ...sharedConfig,\n format: ['esm', 'cjs'] as const,\n});\n"],"mappings":";;AAIA,MAAM,eAAe,iBAAiB;CACpC,WAAW;CACX,OAAO;CACP,KAAK;CACL,OAAO;EACL;EACA;EACA;EACD;CACD,WAAW;CACZ,CAAC;AAEF,MAAa,MAAM,iBAAiB;CAClC,GAAG;CACH,QAAQ;CACT,CAAC;AAEF,MAAa,MAAM,iBAAiB;CAClC,GAAG;CACH,QAAQ;CACT,CAAC;AAEF,MAAa,UAAU,iBAAiB;CACtC,GAAG;CACH,QAAQ,CAAC,OAAO,MAAM;CACvB,CAAC"}
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_types = require("../types-BrvIhA3f.cjs");
3
+ exports.defineConfig = require_types.defineConfig;
4
+ exports.defineConfigPure = require_types.defineConfigPure;
@@ -0,0 +1,8 @@
1
+ import { UserConfig } from "tsdown";
2
+
3
+ //#region src/types/index.d.ts
4
+ declare const defineConfigPure: <TActualObject extends UserConfig>(object: TActualObject) => TActualObject;
5
+ declare const defineConfig: <TActualObject extends UserConfig>(object: UserConfig | TActualObject) => UserConfig | TActualObject;
6
+ //#endregion
7
+ export { defineConfig, defineConfigPure };
8
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,8 @@
1
+ import { UserConfig } from "tsdown";
2
+
3
+ //#region src/types/index.d.ts
4
+ declare const defineConfigPure: <TActualObject extends UserConfig>(object: TActualObject) => TActualObject;
5
+ declare const defineConfig: <TActualObject extends UserConfig>(object: UserConfig | TActualObject) => UserConfig | TActualObject;
6
+ //#endregion
7
+ export { defineConfig, defineConfigPure };
8
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { n as defineConfigPure, t as defineConfig } from "../types-78D1wC2M.mjs";
2
+ export { defineConfig, defineConfigPure };
@@ -0,0 +1,10 @@
1
+ //#region ../types/src/define-object-factory.ts
2
+ const defineObjectFactory = () => (object) => object;
3
+ //#endregion
4
+ //#region src/types/index.ts
5
+ const defineConfigPure = defineObjectFactory();
6
+ const defineConfig = defineObjectFactory();
7
+ //#endregion
8
+ export { defineConfigPure as n, defineConfig as t };
9
+
10
+ //# sourceMappingURL=types-78D1wC2M.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-78D1wC2M.mjs","names":[],"sources":["../../types/src/define-object-factory.ts","../src/types/index.ts"],"sourcesContent":["export const defineObjectFactory =\n <TBaseObject, TAutoComplete extends boolean = false>() =>\n <TActualObject extends TBaseObject>(\n object: TAutoComplete extends true\n ? TActualObject | TBaseObject\n : TActualObject,\n ) =>\n object;\n","import type { UserConfig } from 'tsdown';\nimport { defineObjectFactory } from '../../../types/src/define-object-factory'; // external import\n\nexport const defineConfigPure = defineObjectFactory<UserConfig>();\n\nexport const defineConfig = defineObjectFactory<UserConfig, true>();\n"],"mappings":";AAAA,MAAa,6BAGT,WAIA;;;ACJJ,MAAa,mBAAmB,qBAAiC;AAEjE,MAAa,eAAe,qBAAuC"}
@@ -0,0 +1,21 @@
1
+ //#region ../types/src/define-object-factory.ts
2
+ const defineObjectFactory = () => (object) => object;
3
+ //#endregion
4
+ //#region src/types/index.ts
5
+ const defineConfigPure = defineObjectFactory();
6
+ const defineConfig = defineObjectFactory();
7
+ //#endregion
8
+ Object.defineProperty(exports, "defineConfig", {
9
+ enumerable: true,
10
+ get: function() {
11
+ return defineConfig;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "defineConfigPure", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return defineConfigPure;
18
+ }
19
+ });
20
+
21
+ //# sourceMappingURL=types-BrvIhA3f.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BrvIhA3f.cjs","names":[],"sources":["../../types/src/define-object-factory.ts","../src/types/index.ts"],"sourcesContent":["export const defineObjectFactory =\n <TBaseObject, TAutoComplete extends boolean = false>() =>\n <TActualObject extends TBaseObject>(\n object: TAutoComplete extends true\n ? TActualObject | TBaseObject\n : TActualObject,\n ) =>\n object;\n","import type { UserConfig } from 'tsdown';\nimport { defineObjectFactory } from '../../../types/src/define-object-factory'; // external import\n\nexport const defineConfigPure = defineObjectFactory<UserConfig>();\n\nexport const defineConfig = defineObjectFactory<UserConfig, true>();\n"],"mappings":";AAAA,MAAa,6BAGT,WAIA;;;ACJJ,MAAa,mBAAmB,qBAAiC;AAEjE,MAAa,eAAe,qBAAuC"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@culur/config-tsdown",
3
+ "version": "1.1.0",
4
+ "description": "Culur's tsdown configuration",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/culur/culur.git",
11
+ "directory": "packages/config-tsdown"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/culur/culur/issues"
15
+ },
16
+ "homepage": "https://github.com/culur/culur/tree/main/packages/config-tsdown#readme",
17
+ "author": "culur <culur.net@gmail.com>",
18
+ "license": "MIT",
19
+ "keywords": [
20
+ "culur",
21
+ "config",
22
+ "typescript",
23
+ "tsdown"
24
+ ],
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "import": {
29
+ "types": "./dist/index.d.mts",
30
+ "default": "./dist/index.mjs"
31
+ },
32
+ "require": {
33
+ "types": "./dist/index.d.cts",
34
+ "default": "./dist/index.cjs"
35
+ }
36
+ }
37
+ },
38
+ "files": [
39
+ "!**/*.test.*",
40
+ "CHANGELOG.md",
41
+ "LICENSE",
42
+ "README.md",
43
+ "dist",
44
+ "src"
45
+ ],
46
+ "scripts": {
47
+ "clean": "rimraf dist coverage",
48
+ "build": "tsdown --config-loader unrun",
49
+ "test": "tsc --noEmit && vitest run"
50
+ },
51
+ "volta": {
52
+ "extends": "../../package.json"
53
+ },
54
+ "engines": {
55
+ "node": ">=20"
56
+ },
57
+ "devDependencies": {
58
+ "@culur/config-typescript": "workspace:*",
59
+ "tsdown": "^0.21.6"
60
+ },
61
+ "peerDependencies": {
62
+ "tsdown": "^0.21.6"
63
+ }
64
+ }
@@ -0,0 +1,9 @@
1
+ import type { UserConfig } from 'tsdown';
2
+ import { expectTypeOf, it } from 'vitest';
3
+ import { cjs, esm, esm_cjs } from '.';
4
+
5
+ it('config esm', () => {
6
+ expectTypeOf(esm).toExtend<UserConfig>();
7
+ expectTypeOf(cjs).toExtend<UserConfig>();
8
+ expectTypeOf(esm_cjs).toExtend<UserConfig>();
9
+ });
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { defineConfigPure } from './types';
2
+
3
+ export { defineConfig } from './types';
4
+
5
+ const sharedConfig = defineConfigPure({
6
+ sourcemap: true,
7
+ clean: true,
8
+ dts: true,
9
+ entry: [
10
+ 'src/**/*.ts', //
11
+ '!src/**/*.test.ts',
12
+ '!src/**/*.spec.ts',
13
+ ] as const,
14
+ treeshake: true,
15
+ });
16
+
17
+ export const esm = defineConfigPure({
18
+ ...sharedConfig,
19
+ format: 'esm',
20
+ });
21
+
22
+ export const cjs = defineConfigPure({
23
+ ...sharedConfig,
24
+ format: 'cjs',
25
+ });
26
+
27
+ export const esm_cjs = defineConfigPure({
28
+ ...sharedConfig,
29
+ format: ['esm', 'cjs'] as const,
30
+ });
@@ -0,0 +1,6 @@
1
+ import type { UserConfig } from 'tsdown';
2
+ import { defineObjectFactory } from '../../../types/src/define-object-factory'; // external import
3
+
4
+ export const defineConfigPure = defineObjectFactory<UserConfig>();
5
+
6
+ export const defineConfig = defineObjectFactory<UserConfig, true>();