tsdown-config-silverwind 4.1.1 → 4.1.3

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/README.md CHANGED
@@ -1,12 +1,21 @@
1
- # tsdown-config-silverwind [![](https://img.shields.io/npm/v/tsdown-config-silverwind.svg)](https://www.npmjs.org/package/tsdown-config-silverwind) [![](https://packagephobia.com/badge?p=tsdown-config-silverwind)](https://packagephobia.com/result?p=tsdown-config-silverwind) [![](https://img.shields.io/badge/licence-bsd-blue.svg)](https://raw.githubusercontent.com/silverwind/tsdown-config-silverwind/master/LICENSE)
1
+ # tsdown-config-silverwind
2
+ [![](https://img.shields.io/npm/v/tsdown-config-silverwind.svg)](https://www.npmjs.org/package/tsdown-config-silverwind) [![](https://packagephobia.com/badge?p=tsdown-config-silverwind)](https://packagephobia.com/result?p=tsdown-config-silverwind)
2
3
 
3
- Shared tsdown configuration
4
+ > Shared tsdown configuration
4
5
 
5
- ```js
6
+ ## Usage
7
+
8
+ ```sh
9
+ pnpm add -D tsdown-config-silverwind
10
+ ```
11
+
12
+ In `tsdown.config.ts`:
13
+
14
+ ```ts
6
15
  import {nodeLib} from "tsdown-config-silverwind";
7
16
  import {defineConfig} from "tsdown";
8
17
 
9
18
  export default defineConfig(nodeLib({url: import.meta.url}));
10
19
  ```
11
20
 
12
- © [silverwind](https://github.com/silverwind), distributed under BSD licence.
21
+ © [silverwind](https://github.com/silverwind), distributed under BSD licence
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ type CustomConfig = UserConfig & {
5
5
  };
6
6
  export declare function base({ url, entry, report, loader, outputOptions, deps, checks, ...other }: CustomConfig): UserConfig;
7
7
  export declare function nodeLib({ url, entry, outputOptions, ...other }: CustomConfig): UserConfig;
8
- export declare function webLib({ url, ...other }: CustomConfig): UserConfig;
9
- export declare function nodeCli({ url, entry, outputOptions, ...other }: CustomConfig): UserConfig;
8
+ export declare function webLib(config: CustomConfig): UserConfig;
9
+ export declare function nodeCli(config: CustomConfig): UserConfig;
10
10
  //#endregion
package/dist/index.js CHANGED
@@ -5,15 +5,24 @@ const suppressWarnings = ["TypeScript 7.0 does not yet have a stable API"];
5
5
  function isObject(obj) {
6
6
  return Object.prototype.toString.call(obj) === "[object Object]";
7
7
  }
8
+ function mergeOutputOptions(defaults, outputOptions) {
9
+ if (typeof outputOptions === "function") return (options, ...args) => outputOptions(Object.assign(options, defaults), ...args);
10
+ else return {
11
+ ...defaults,
12
+ ...isObject(outputOptions) && outputOptions
13
+ };
14
+ }
8
15
  function isSingleEntry(entry) {
9
- if (Array.isArray(entry)) return entry.length === 1;
10
- else if (isObject(entry)) return Object.keys(entry).length === 1;
11
- else return true;
16
+ if (Array.isArray(entry)) return entry.length === 1 && isSingleEntry(entry[0]);
17
+ else if (isObject(entry)) {
18
+ const keys = Object.keys(entry);
19
+ return keys.length === 1 && !keys[0].includes("*");
20
+ } else return typeof entry !== "string" || !/[*?(]|\[.*\]|\{[^}]*(?:,|\.\.)/.test(entry);
12
21
  }
13
22
  function base({ url, entry, report, loader, outputOptions, deps, checks, ...other }) {
14
23
  return {
15
24
  entry: entry ?? fileURLToPath(new URL("index.ts", url)),
16
- report: typeof report === "boolean" ? report : {
25
+ report: typeof report === "boolean" || typeof report === "string" ? report : {
17
26
  gzip: false,
18
27
  brotli: false,
19
28
  ...isObject(report) && report
@@ -25,10 +34,7 @@ function base({ url, entry, report, loader, outputOptions, deps, checks, ...othe
25
34
  ".txt": "text",
26
35
  ...loader
27
36
  },
28
- outputOptions: {
29
- comments: { legal: false },
30
- ...isObject(outputOptions) && outputOptions
31
- },
37
+ outputOptions: mergeOutputOptions({ comments: { legal: false } }, outputOptions),
32
38
  fixedExtension: false,
33
39
  failOnWarn: true,
34
40
  suppressWarnings,
@@ -51,34 +57,23 @@ function nodeLib({ url, entry, outputOptions, ...other }) {
51
57
  entry,
52
58
  platform: "node",
53
59
  minify: false,
54
- outputOptions: {
55
- ...isSingleEntry(entry) && { codeSplitting: false },
56
- ...isObject(outputOptions) && outputOptions
57
- },
60
+ outputOptions: mergeOutputOptions(isSingleEntry(entry) ? { codeSplitting: false } : {}, outputOptions),
58
61
  url,
59
62
  ...other
60
63
  });
61
64
  }
62
- function webLib({ url, ...other }) {
65
+ function webLib(config) {
63
66
  return base({
64
67
  platform: "browser",
65
68
  target: "esnext",
66
69
  minify: false,
67
- url,
68
- ...other
70
+ ...config
69
71
  });
70
72
  }
71
- function nodeCli({ url, entry, outputOptions, ...other }) {
73
+ function nodeCli(config) {
72
74
  return nodeLib({
73
- entry,
74
- platform: "node",
75
75
  minify: true,
76
- outputOptions: {
77
- ...isSingleEntry(entry) && { codeSplitting: false },
78
- ...isObject(outputOptions) && outputOptions
79
- },
80
- url,
81
- ...other
76
+ ...config
82
77
  });
83
78
  }
84
79
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tsdown-config-silverwind",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "description": "Shared tsdown configuration",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "silverwind/tsdown-config-silverwind"
8
+ "url": "git+https://github.com/silverwind/tsdown-config-silverwind.git"
9
9
  },
10
10
  "license": "BSD-2-Clause",
11
11
  "type": "module",
@@ -23,18 +23,17 @@
23
23
  "tsdown": "*"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "26.6.1",
26
+ "@types/node": "26.6.3",
27
27
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
28
- "eslint": "10.10.0",
29
- "eslint-config-silverwind": "149.0.0",
30
- "jest-extended": "7.0.0",
28
+ "eslint": "10.11.0",
29
+ "eslint-config-silverwind": "151.0.1",
31
30
  "tsdown": "0.23.0",
32
31
  "typescript": "6.0.3",
33
- "typescript-config-silverwind": "20.0.4",
34
- "updates": "18.1.0",
35
- "updates-config-silverwind": "4.0.6",
36
- "versions": "15.4.0",
37
- "vitest": "5.0.1",
38
- "vitest-config-silverwind": "12.0.3"
32
+ "typescript-config-silverwind": "21.0.1",
33
+ "updates": "19.0.2",
34
+ "updates-config-silverwind": "4.0.7",
35
+ "versions": "15.5.1",
36
+ "vitest": "5.0.2",
37
+ "vitest-config-silverwind": "12.0.5"
39
38
  }
40
39
  }