@kcconfigs/tsdown 0.0.1 → 0.1.0-beta.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,30 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-beta.0 (2025-12-26)
4
+
5
+
6
+ ### Features
7
+
8
+ * **core:** move all packages into packages/* directory ([58230cd](https://github.com/kc-workspace/kcws/commit/58230cd286d0dea953d232806c91508ebfc57701))
9
+ * **kcconfigs/tsdown:** add source and typedoc conditions in exports ([6911d45](https://github.com/kc-workspace/kcws/commit/6911d4557f67362d78e959b88af8f110a78ee3a0))
10
+
11
+
12
+ ### Performance Improvements
13
+
14
+ * **kcconfigs/tsdown:** add [@generated](https://github.com/generated) to generated file ([f3efbca](https://github.com/kc-workspace/kcws/commit/f3efbca38e221ad9445e09fd4b772d3cc07c3027))
15
+ * **kcconfigs/tsdown:** enabled publint, unused, and arethetypewrong validators by default ([fd8a89e](https://github.com/kc-workspace/kcws/commit/fd8a89edfa6385c1211f5077499c56adf18f4b2c))
16
+
17
+
18
+ ### Bugfixes
19
+
20
+ * homepage contains invalid url ([0ee37d6](https://github.com/kc-workspace/kcws/commit/0ee37d641fe5b04fb019099915c8aa3ddfed3be7))
21
+ * **kcconfigs/tsdown:** attw should be error or no one will care and disable older node <16 ([7735770](https://github.com/kc-workspace/kcws/commit/77357707a071f358657b27e8eafeff626924442e))
22
+ * trigger re-release please ([65447a7](https://github.com/kc-workspace/kcws/commit/65447a776ed2f8638f6f35a4d00277d407143114))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * devDependencies
29
+ * @kcconfigs/biome bumped to 0.1.0
30
+ * @kcconfigs/tsconfig bumped to 0.1.0-beta.0
package/dist/index.cjs ADDED
@@ -0,0 +1,81 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ let tsdown = require("tsdown");
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * @public Defines the configuration for tsdown.
7
+ * @param configs UserConfig for tsdown
8
+ * @returns The merged UserConfig
9
+ */
10
+ const defineConfig = (config, ...configs) => {
11
+ const { format, dts, ...rest } = config ?? {};
12
+ let _dts = dts;
13
+ if (_dts === void 0 || _dts === null) _dts = {
14
+ sourcemap: true,
15
+ resolve: false
16
+ };
17
+ else if (typeof _dts === "object") {
18
+ var _dts2;
19
+ (_dts2 = _dts).sourcemap ?? (_dts2.sourcemap = true);
20
+ _dts.resolve = false;
21
+ }
22
+ const banner = "// @generated by tsdown, DO NOT edit it manually";
23
+ const footer = "// Generated by @kcconfigs/tsdown";
24
+ let _format = format;
25
+ if (_format === void 0 || _format === null) _format = {
26
+ esm: {
27
+ sourcemap: true,
28
+ banner,
29
+ footer
30
+ },
31
+ cjs: {
32
+ sourcemap: true,
33
+ banner,
34
+ footer
35
+ }
36
+ };
37
+ else if (Array.isArray(_format)) _format = _format.reduce((obj, fmt) => {
38
+ obj[fmt] = {
39
+ sourcemap: true,
40
+ banner,
41
+ footer
42
+ };
43
+ return obj;
44
+ }, {});
45
+ else if (typeof _format === "object") _format = Object.fromEntries(Object.entries(_format).map(([key, value]) => {
46
+ return [key, {
47
+ sourcemap: true,
48
+ footer,
49
+ ...value
50
+ }];
51
+ }));
52
+ return (0, tsdown.defineConfig)([{
53
+ entry: ["./src/index.ts"],
54
+ platform: "neutral",
55
+ fixedExtension: false,
56
+ outDir: "dist",
57
+ clean: true,
58
+ publint: {
59
+ enabled: true,
60
+ level: "warning"
61
+ },
62
+ unused: {
63
+ enabled: true,
64
+ level: "warning",
65
+ depKinds: ["dependencies", "peerDependencies"]
66
+ },
67
+ attw: {
68
+ enabled: true,
69
+ level: "error",
70
+ profile: "node16"
71
+ },
72
+ format: _format,
73
+ dts: _dts,
74
+ ...rest
75
+ }].concat(...configs));
76
+ };
77
+
78
+ //#endregion
79
+ exports.defineConfig = defineConfig;
80
+ // Generated by @kcconfigs/tsdown
81
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n\tdefineConfig as _defineConfig,\n\ttype UserConfig as _UserConfig,\n} from \"tsdown\";\n\n/**\n * @public Custom User Config exported from defineConfig function\n */\nexport type UserConfig = _UserConfig[];\n\n/**\n * @public Defines the configuration for tsdown.\n * @param configs UserConfig for tsdown\n * @returns The merged UserConfig\n */\nexport const defineConfig = (\n\tconfig?: _UserConfig,\n\t...configs: UserConfig\n): UserConfig => {\n\tconst { format, dts, ...rest } = config ?? ({} as _UserConfig);\n\n\tlet _dts = dts;\n\tif (_dts === undefined || _dts === null) {\n\t\t_dts = {\n\t\t\tsourcemap: true,\n\t\t\tresolve: false,\n\t\t};\n\t} else if (typeof _dts === \"object\") {\n\t\t_dts.sourcemap ??= true;\n\t\t_dts.resolve = false;\n\t}\n\n\tconst banner = \"// @generated by tsdown, DO NOT edit it manually\";\n\tconst footer = \"// Generated by @kcconfigs/tsdown\";\n\tlet _format = format;\n\tif (_format === undefined || _format === null) {\n\t\t_format = {\n\t\t\tesm: {\n\t\t\t\tsourcemap: true,\n\t\t\t\tbanner,\n\t\t\t\tfooter,\n\t\t\t},\n\t\t\tcjs: {\n\t\t\t\tsourcemap: true,\n\t\t\t\tbanner,\n\t\t\t\tfooter,\n\t\t\t},\n\t\t};\n\t} else if (Array.isArray(_format)) {\n\t\t_format = _format.reduce(\n\t\t\t(obj, fmt) => {\n\t\t\t\tobj[fmt] = {\n\t\t\t\t\tsourcemap: true,\n\t\t\t\t\tbanner,\n\t\t\t\t\tfooter,\n\t\t\t\t};\n\t\t\t\treturn obj;\n\t\t\t},\n\t\t\t{} as Exclude<_UserConfig[\"format\"], undefined | string | Array<unknown>>,\n\t\t);\n\t} else if (typeof _format === \"object\") {\n\t\t_format = Object.fromEntries(\n\t\t\tObject.entries(_format).map(([key, value]) => {\n\t\t\t\treturn [key, { sourcemap: true, footer, ...value }];\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst baseConfig: _UserConfig = {\n\t\tentry: [\"./src/index.ts\"],\n\t\tplatform: \"neutral\",\n\t\tfixedExtension: false,\n\t\toutDir: \"dist\",\n\t\tclean: true,\n\t\tpublint: {\n\t\t\tenabled: true,\n\t\t\tlevel: \"warning\",\n\t\t},\n\t\tunused: {\n\t\t\tenabled: true,\n\t\t\tlevel: \"warning\",\n\t\t\tdepKinds: [\"dependencies\", \"peerDependencies\"],\n\t\t},\n\t\tattw: {\n\t\t\tenabled: true,\n\t\t\tlevel: \"error\",\n\t\t\t// We don't build package for node older than 10\n\t\t\t// https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md#true-positive-node-10-doesnt-support-packagejson-exports\n\t\t\tprofile: \"node16\",\n\t\t},\n\t\tformat: _format,\n\t\tdts: _dts,\n\t\t...rest,\n\t};\n\n\treturn _defineConfig([baseConfig].concat(...configs));\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,gBACZ,QACA,GAAG,YACa;CAChB,MAAM,EAAE,QAAQ,KAAK,GAAG,SAAS,UAAW,EAAE;CAE9C,IAAI,OAAO;AACX,KAAI,SAAS,UAAa,SAAS,KAClC,QAAO;EACN,WAAW;EACX,SAAS;EACT;UACS,OAAO,SAAS,UAAU;;AACpC,iBAAK,gCAAc;AACnB,OAAK,UAAU;;CAGhB,MAAM,SAAS;CACf,MAAM,SAAS;CACf,IAAI,UAAU;AACd,KAAI,YAAY,UAAa,YAAY,KACxC,WAAU;EACT,KAAK;GACJ,WAAW;GACX;GACA;GACA;EACD,KAAK;GACJ,WAAW;GACX;GACA;GACA;EACD;UACS,MAAM,QAAQ,QAAQ,CAChC,WAAU,QAAQ,QAChB,KAAK,QAAQ;AACb,MAAI,OAAO;GACV,WAAW;GACX;GACA;GACA;AACD,SAAO;IAER,EAAE,CACF;UACS,OAAO,YAAY,SAC7B,WAAU,OAAO,YAChB,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,KAAK,WAAW;AAC7C,SAAO,CAAC,KAAK;GAAE,WAAW;GAAM;GAAQ,GAAG;GAAO,CAAC;GAClD,CACF;AA8BF,iCAAqB,CA3BW;EAC/B,OAAO,CAAC,iBAAiB;EACzB,UAAU;EACV,gBAAgB;EAChB,QAAQ;EACR,OAAO;EACP,SAAS;GACR,SAAS;GACT,OAAO;GACP;EACD,QAAQ;GACP,SAAS;GACT,OAAO;GACP,UAAU,CAAC,gBAAgB,mBAAmB;GAC9C;EACD,MAAM;GACL,SAAS;GACT,OAAO;GAGP,SAAS;GACT;EACD,QAAQ;EACR,KAAK;EACL,GAAG;EACH,CAEgC,CAAC,OAAO,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,19 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ import { UserConfig as UserConfig$1 } from "tsdown";
3
+
4
+ //#region src/index.d.ts
5
+
6
+ /**
7
+ * @public Custom User Config exported from defineConfig function
8
+ */
9
+ type UserConfig = UserConfig$1[];
10
+ /**
11
+ * @public Defines the configuration for tsdown.
12
+ * @param configs UserConfig for tsdown
13
+ * @returns The merged UserConfig
14
+ */
15
+ declare const defineConfig: (config?: UserConfig$1, ...configs: UserConfig) => UserConfig;
16
+ //#endregion
17
+ export { UserConfig, defineConfig };
18
+ // Generated by @kcconfigs/tsdown
19
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAOa,KAPD,UAAA,GAAa,YAUtB,EAAA;;;;;;cAHU,wBACH,0BACG,eACV"}
@@ -0,0 +1,19 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ import { UserConfig as UserConfig$1 } from "tsdown";
3
+
4
+ //#region src/index.d.ts
5
+
6
+ /**
7
+ * @public Custom User Config exported from defineConfig function
8
+ */
9
+ type UserConfig = UserConfig$1[];
10
+ /**
11
+ * @public Defines the configuration for tsdown.
12
+ * @param configs UserConfig for tsdown
13
+ * @returns The merged UserConfig
14
+ */
15
+ declare const defineConfig: (config?: UserConfig$1, ...configs: UserConfig) => UserConfig;
16
+ //#endregion
17
+ export { UserConfig, defineConfig };
18
+ // Generated by @kcconfigs/tsdown
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAOa,KAPD,UAAA,GAAa,YAUtB,EAAA;;;;;;cAHU,wBACH,0BACG,eACV"}
package/dist/index.js ADDED
@@ -0,0 +1,81 @@
1
+ // @generated by tsdown, DO NOT edit it manually
2
+ import { defineConfig as defineConfig$1 } from "tsdown";
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * @public Defines the configuration for tsdown.
7
+ * @param configs UserConfig for tsdown
8
+ * @returns The merged UserConfig
9
+ */
10
+ const defineConfig = (config, ...configs) => {
11
+ const { format, dts, ...rest } = config ?? {};
12
+ let _dts = dts;
13
+ if (_dts === void 0 || _dts === null) _dts = {
14
+ sourcemap: true,
15
+ resolve: false
16
+ };
17
+ else if (typeof _dts === "object") {
18
+ var _dts2;
19
+ (_dts2 = _dts).sourcemap ?? (_dts2.sourcemap = true);
20
+ _dts.resolve = false;
21
+ }
22
+ const banner = "// @generated by tsdown, DO NOT edit it manually";
23
+ const footer = "// Generated by @kcconfigs/tsdown";
24
+ let _format = format;
25
+ if (_format === void 0 || _format === null) _format = {
26
+ esm: {
27
+ sourcemap: true,
28
+ banner,
29
+ footer
30
+ },
31
+ cjs: {
32
+ sourcemap: true,
33
+ banner,
34
+ footer
35
+ }
36
+ };
37
+ else if (Array.isArray(_format)) _format = _format.reduce((obj, fmt) => {
38
+ obj[fmt] = {
39
+ sourcemap: true,
40
+ banner,
41
+ footer
42
+ };
43
+ return obj;
44
+ }, {});
45
+ else if (typeof _format === "object") _format = Object.fromEntries(Object.entries(_format).map(([key, value]) => {
46
+ return [key, {
47
+ sourcemap: true,
48
+ footer,
49
+ ...value
50
+ }];
51
+ }));
52
+ return defineConfig$1([{
53
+ entry: ["./src/index.ts"],
54
+ platform: "neutral",
55
+ fixedExtension: false,
56
+ outDir: "dist",
57
+ clean: true,
58
+ publint: {
59
+ enabled: true,
60
+ level: "warning"
61
+ },
62
+ unused: {
63
+ enabled: true,
64
+ level: "warning",
65
+ depKinds: ["dependencies", "peerDependencies"]
66
+ },
67
+ attw: {
68
+ enabled: true,
69
+ level: "error",
70
+ profile: "node16"
71
+ },
72
+ format: _format,
73
+ dts: _dts,
74
+ ...rest
75
+ }].concat(...configs));
76
+ };
77
+
78
+ //#endregion
79
+ export { defineConfig };
80
+ // Generated by @kcconfigs/tsdown
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_defineConfig"],"sources":["../src/index.ts"],"sourcesContent":["import {\n\tdefineConfig as _defineConfig,\n\ttype UserConfig as _UserConfig,\n} from \"tsdown\";\n\n/**\n * @public Custom User Config exported from defineConfig function\n */\nexport type UserConfig = _UserConfig[];\n\n/**\n * @public Defines the configuration for tsdown.\n * @param configs UserConfig for tsdown\n * @returns The merged UserConfig\n */\nexport const defineConfig = (\n\tconfig?: _UserConfig,\n\t...configs: UserConfig\n): UserConfig => {\n\tconst { format, dts, ...rest } = config ?? ({} as _UserConfig);\n\n\tlet _dts = dts;\n\tif (_dts === undefined || _dts === null) {\n\t\t_dts = {\n\t\t\tsourcemap: true,\n\t\t\tresolve: false,\n\t\t};\n\t} else if (typeof _dts === \"object\") {\n\t\t_dts.sourcemap ??= true;\n\t\t_dts.resolve = false;\n\t}\n\n\tconst banner = \"// @generated by tsdown, DO NOT edit it manually\";\n\tconst footer = \"// Generated by @kcconfigs/tsdown\";\n\tlet _format = format;\n\tif (_format === undefined || _format === null) {\n\t\t_format = {\n\t\t\tesm: {\n\t\t\t\tsourcemap: true,\n\t\t\t\tbanner,\n\t\t\t\tfooter,\n\t\t\t},\n\t\t\tcjs: {\n\t\t\t\tsourcemap: true,\n\t\t\t\tbanner,\n\t\t\t\tfooter,\n\t\t\t},\n\t\t};\n\t} else if (Array.isArray(_format)) {\n\t\t_format = _format.reduce(\n\t\t\t(obj, fmt) => {\n\t\t\t\tobj[fmt] = {\n\t\t\t\t\tsourcemap: true,\n\t\t\t\t\tbanner,\n\t\t\t\t\tfooter,\n\t\t\t\t};\n\t\t\t\treturn obj;\n\t\t\t},\n\t\t\t{} as Exclude<_UserConfig[\"format\"], undefined | string | Array<unknown>>,\n\t\t);\n\t} else if (typeof _format === \"object\") {\n\t\t_format = Object.fromEntries(\n\t\t\tObject.entries(_format).map(([key, value]) => {\n\t\t\t\treturn [key, { sourcemap: true, footer, ...value }];\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst baseConfig: _UserConfig = {\n\t\tentry: [\"./src/index.ts\"],\n\t\tplatform: \"neutral\",\n\t\tfixedExtension: false,\n\t\toutDir: \"dist\",\n\t\tclean: true,\n\t\tpublint: {\n\t\t\tenabled: true,\n\t\t\tlevel: \"warning\",\n\t\t},\n\t\tunused: {\n\t\t\tenabled: true,\n\t\t\tlevel: \"warning\",\n\t\t\tdepKinds: [\"dependencies\", \"peerDependencies\"],\n\t\t},\n\t\tattw: {\n\t\t\tenabled: true,\n\t\t\tlevel: \"error\",\n\t\t\t// We don't build package for node older than 10\n\t\t\t// https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md#true-positive-node-10-doesnt-support-packagejson-exports\n\t\t\tprofile: \"node16\",\n\t\t},\n\t\tformat: _format,\n\t\tdts: _dts,\n\t\t...rest,\n\t};\n\n\treturn _defineConfig([baseConfig].concat(...configs));\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,gBACZ,QACA,GAAG,YACa;CAChB,MAAM,EAAE,QAAQ,KAAK,GAAG,SAAS,UAAW,EAAE;CAE9C,IAAI,OAAO;AACX,KAAI,SAAS,UAAa,SAAS,KAClC,QAAO;EACN,WAAW;EACX,SAAS;EACT;UACS,OAAO,SAAS,UAAU;;AACpC,iBAAK,gCAAc;AACnB,OAAK,UAAU;;CAGhB,MAAM,SAAS;CACf,MAAM,SAAS;CACf,IAAI,UAAU;AACd,KAAI,YAAY,UAAa,YAAY,KACxC,WAAU;EACT,KAAK;GACJ,WAAW;GACX;GACA;GACA;EACD,KAAK;GACJ,WAAW;GACX;GACA;GACA;EACD;UACS,MAAM,QAAQ,QAAQ,CAChC,WAAU,QAAQ,QAChB,KAAK,QAAQ;AACb,MAAI,OAAO;GACV,WAAW;GACX;GACA;GACA;AACD,SAAO;IAER,EAAE,CACF;UACS,OAAO,YAAY,SAC7B,WAAU,OAAO,YAChB,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,KAAK,WAAW;AAC7C,SAAO,CAAC,KAAK;GAAE,WAAW;GAAM;GAAQ,GAAG;GAAO,CAAC;GAClD,CACF;AA8BF,QAAOA,eAAc,CA3BW;EAC/B,OAAO,CAAC,iBAAiB;EACzB,UAAU;EACV,gBAAgB;EAChB,QAAQ;EACR,OAAO;EACP,SAAS;GACR,SAAS;GACT,OAAO;GACP;EACD,QAAQ;GACP,SAAS;GACT,OAAO;GACP,UAAU,CAAC,gBAAgB,mBAAmB;GAC9C;EACD,MAAM;GACL,SAAS;GACT,OAAO;GAGP,SAAS;GACT;EACD,QAAQ;EACR,KAAK;EACL,GAAG;EACH,CAEgC,CAAC,OAAO,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@kcconfigs/tsdown",
3
- "version": "0.0.1",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "TSDown configuration",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "tsdown": "0.18.1",
8
+ "publint": "0.3.16",
9
+ "unplugin-unused": "0.5.6",
10
+ "@arethetypeswrong/core": "0.18.2"
11
+ },
12
+ "devDependencies": {
13
+ "@biomejs/biome": "2.3.8",
14
+ "@kcconfigs/biome": "0.1.0",
15
+ "@kcconfigs/tsconfig": "0.1.0-beta.0"
16
+ },
17
+ "peerDependencies": {
18
+ "tsdown": "^0.17.0",
19
+ "publint": "^0.3.0",
20
+ "unplugin-unused": "^0.5.0",
21
+ "@arethetypeswrong/core": "^0.18.0"
22
+ },
23
+ "peerDependenciesMeta": {
24
+ "publint": {
25
+ "optional": true
26
+ },
27
+ "unplugin-unused": {
28
+ "optional": true
29
+ },
30
+ "@arethetypeswrong/core": {
31
+ "optional": true
32
+ }
33
+ },
34
+ "main": "./dist/index.js",
35
+ "types": "./dist/index.d.cts",
36
+ "exports": {
37
+ ".": {
38
+ "source": "./src/index.ts",
39
+ "typedoc": "./src/index.ts",
40
+ "require": {
41
+ "types": "./dist/index.d.cts",
42
+ "default": "./dist/index.cjs"
43
+ },
44
+ "default": {
45
+ "types": "./dist/index.d.ts",
46
+ "default": "./dist/index.js"
47
+ }
48
+ }
49
+ },
4
50
  "license": "AGPL-3.0-only",
5
51
  "homepage": "https://github.com/kc-workspace/kcws/tree/main/packages/@kcconfigs/tsdown",
6
52
  "repository": {
@@ -13,10 +59,34 @@
13
59
  "email": "kcws@kc.in.th",
14
60
  "url": "https://github.com/kamontat"
15
61
  },
62
+ "keywords": [
63
+ "config",
64
+ "typescript",
65
+ "tsdown",
66
+ "library",
67
+ "compiler",
68
+ "bundler"
69
+ ],
70
+ "files": [
71
+ "CHANGELOG.json",
72
+ "CHANGELOG.md",
73
+ "dist",
74
+ "src"
75
+ ],
16
76
  "engines": {
17
77
  "node": ">=14"
18
78
  },
19
79
  "publishConfig": {
20
80
  "access": "public"
81
+ },
82
+ "scripts": {
83
+ "build": "tsdown --config-loader unrun",
84
+ "fix": "biome check --fix --unsafe",
85
+ "check": "pnpm run lint:check && pnpm run format:check && pnpm run type:check",
86
+ "format": "biome format --fix",
87
+ "format:check": "biome format",
88
+ "lint": "biome lint --fix --unsafe",
89
+ "lint:check": "biome lint",
90
+ "type:check": "tsc --build"
21
91
  }
22
92
  }
package/src/index.ts ADDED
@@ -0,0 +1,97 @@
1
+ import {
2
+ defineConfig as _defineConfig,
3
+ type UserConfig as _UserConfig,
4
+ } from "tsdown";
5
+
6
+ /**
7
+ * @public Custom User Config exported from defineConfig function
8
+ */
9
+ export type UserConfig = _UserConfig[];
10
+
11
+ /**
12
+ * @public Defines the configuration for tsdown.
13
+ * @param configs UserConfig for tsdown
14
+ * @returns The merged UserConfig
15
+ */
16
+ export const defineConfig = (
17
+ config?: _UserConfig,
18
+ ...configs: UserConfig
19
+ ): UserConfig => {
20
+ const { format, dts, ...rest } = config ?? ({} as _UserConfig);
21
+
22
+ let _dts = dts;
23
+ if (_dts === undefined || _dts === null) {
24
+ _dts = {
25
+ sourcemap: true,
26
+ resolve: false,
27
+ };
28
+ } else if (typeof _dts === "object") {
29
+ _dts.sourcemap ??= true;
30
+ _dts.resolve = false;
31
+ }
32
+
33
+ const banner = "// @generated by tsdown, DO NOT edit it manually";
34
+ const footer = "// Generated by @kcconfigs/tsdown";
35
+ let _format = format;
36
+ if (_format === undefined || _format === null) {
37
+ _format = {
38
+ esm: {
39
+ sourcemap: true,
40
+ banner,
41
+ footer,
42
+ },
43
+ cjs: {
44
+ sourcemap: true,
45
+ banner,
46
+ footer,
47
+ },
48
+ };
49
+ } else if (Array.isArray(_format)) {
50
+ _format = _format.reduce(
51
+ (obj, fmt) => {
52
+ obj[fmt] = {
53
+ sourcemap: true,
54
+ banner,
55
+ footer,
56
+ };
57
+ return obj;
58
+ },
59
+ {} as Exclude<_UserConfig["format"], undefined | string | Array<unknown>>,
60
+ );
61
+ } else if (typeof _format === "object") {
62
+ _format = Object.fromEntries(
63
+ Object.entries(_format).map(([key, value]) => {
64
+ return [key, { sourcemap: true, footer, ...value }];
65
+ }),
66
+ );
67
+ }
68
+
69
+ const baseConfig: _UserConfig = {
70
+ entry: ["./src/index.ts"],
71
+ platform: "neutral",
72
+ fixedExtension: false,
73
+ outDir: "dist",
74
+ clean: true,
75
+ publint: {
76
+ enabled: true,
77
+ level: "warning",
78
+ },
79
+ unused: {
80
+ enabled: true,
81
+ level: "warning",
82
+ depKinds: ["dependencies", "peerDependencies"],
83
+ },
84
+ attw: {
85
+ enabled: true,
86
+ level: "error",
87
+ // We don't build package for node older than 10
88
+ // https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md#true-positive-node-10-doesnt-support-packagejson-exports
89
+ profile: "node16",
90
+ },
91
+ format: _format,
92
+ dts: _dts,
93
+ ...rest,
94
+ };
95
+
96
+ return _defineConfig([baseConfig].concat(...configs));
97
+ };