tsdown-config-silverwind 4.1.2 → 4.1.4
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 +13 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -27
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
# tsdown-config-silverwind
|
|
1
|
+
# tsdown-config-silverwind
|
|
2
|
+
[](https://www.npmjs.org/package/tsdown-config-silverwind) [](https://packagephobia.com/result?p=tsdown-config-silverwind)
|
|
2
3
|
|
|
3
|
-
Shared tsdown configuration
|
|
4
|
+
> Shared tsdown configuration
|
|
4
5
|
|
|
5
|
-
|
|
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(
|
|
9
|
-
export declare function nodeCli(
|
|
8
|
+
export declare function webLib(config: CustomConfig): UserConfig;
|
|
9
|
+
export declare function nodeCli(config: CustomConfig): UserConfig;
|
|
10
10
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
|
|
3
3
|
//#region index.ts
|
|
4
|
-
const suppressWarnings = ["TypeScript 7.0 does not yet have a stable API"];
|
|
5
4
|
function isObject(obj) {
|
|
6
5
|
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
7
6
|
}
|
|
7
|
+
function mergeOutputOptions(defaults, outputOptions) {
|
|
8
|
+
if (typeof outputOptions === "function") return (options, ...args) => outputOptions(Object.assign(options, defaults), ...args);
|
|
9
|
+
else return {
|
|
10
|
+
...defaults,
|
|
11
|
+
...isObject(outputOptions) && outputOptions
|
|
12
|
+
};
|
|
13
|
+
}
|
|
8
14
|
function isSingleEntry(entry) {
|
|
9
|
-
if (Array.isArray(entry)) return entry.length === 1;
|
|
10
|
-
else if (isObject(entry))
|
|
11
|
-
|
|
15
|
+
if (Array.isArray(entry)) return entry.length === 1 && isSingleEntry(entry[0]);
|
|
16
|
+
else if (isObject(entry)) {
|
|
17
|
+
const keys = Object.keys(entry);
|
|
18
|
+
return keys.length === 1 && !keys[0].includes("*");
|
|
19
|
+
} else return typeof entry !== "string" || !/[*?(]|\[.*\]|\{[^}]*(?:,|\.\.)/.test(entry);
|
|
12
20
|
}
|
|
13
21
|
function base({ url, entry, report, loader, outputOptions, deps, checks, ...other }) {
|
|
14
22
|
return {
|
|
15
23
|
entry: entry ?? fileURLToPath(new URL("index.ts", url)),
|
|
16
|
-
report: typeof report === "boolean" ? report : {
|
|
24
|
+
report: typeof report === "boolean" || typeof report === "string" ? report : {
|
|
17
25
|
gzip: false,
|
|
18
26
|
brotli: false,
|
|
19
27
|
...isObject(report) && report
|
|
@@ -25,20 +33,16 @@ function base({ url, entry, report, loader, outputOptions, deps, checks, ...othe
|
|
|
25
33
|
".txt": "text",
|
|
26
34
|
...loader
|
|
27
35
|
},
|
|
28
|
-
outputOptions: {
|
|
29
|
-
comments: { legal: false },
|
|
30
|
-
...isObject(outputOptions) && outputOptions
|
|
31
|
-
},
|
|
36
|
+
outputOptions: mergeOutputOptions({ comments: { legal: false } }, outputOptions),
|
|
32
37
|
fixedExtension: false,
|
|
33
38
|
failOnWarn: true,
|
|
34
|
-
suppressWarnings,
|
|
35
39
|
checks: {
|
|
36
40
|
pluginTimings: false,
|
|
37
41
|
moduleLevelDirective: false,
|
|
38
42
|
...checks
|
|
39
43
|
},
|
|
40
44
|
globImport: false,
|
|
41
|
-
dts:
|
|
45
|
+
dts: true,
|
|
42
46
|
deps: {
|
|
43
47
|
onlyBundle: false,
|
|
44
48
|
...deps
|
|
@@ -51,34 +55,23 @@ function nodeLib({ url, entry, outputOptions, ...other }) {
|
|
|
51
55
|
entry,
|
|
52
56
|
platform: "node",
|
|
53
57
|
minify: false,
|
|
54
|
-
outputOptions: {
|
|
55
|
-
...isSingleEntry(entry) && { codeSplitting: false },
|
|
56
|
-
...isObject(outputOptions) && outputOptions
|
|
57
|
-
},
|
|
58
|
+
outputOptions: mergeOutputOptions(isSingleEntry(entry) ? { codeSplitting: false } : {}, outputOptions),
|
|
58
59
|
url,
|
|
59
60
|
...other
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
function webLib(
|
|
63
|
+
function webLib(config) {
|
|
63
64
|
return base({
|
|
64
65
|
platform: "browser",
|
|
65
66
|
target: "esnext",
|
|
66
67
|
minify: false,
|
|
67
|
-
|
|
68
|
-
...other
|
|
68
|
+
...config
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function nodeCli(
|
|
71
|
+
function nodeCli(config) {
|
|
72
72
|
return nodeLib({
|
|
73
|
-
entry,
|
|
74
|
-
platform: "node",
|
|
75
73
|
minify: true,
|
|
76
|
-
|
|
77
|
-
...isSingleEntry(entry) && { codeSplitting: false },
|
|
78
|
-
...isObject(outputOptions) && outputOptions
|
|
79
|
-
},
|
|
80
|
-
url,
|
|
81
|
-
...other
|
|
74
|
+
...config
|
|
82
75
|
});
|
|
83
76
|
}
|
|
84
77
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown-config-silverwind",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"description": "Shared tsdown configuration",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": {
|
|
@@ -23,18 +23,17 @@
|
|
|
23
23
|
"tsdown": "*"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "26.6.
|
|
26
|
+
"@types/node": "26.6.3",
|
|
27
27
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
28
28
|
"eslint": "10.11.0",
|
|
29
|
-
"eslint-config-silverwind": "151.0.
|
|
30
|
-
"jest-extended": "7.0.0",
|
|
29
|
+
"eslint-config-silverwind": "151.0.1",
|
|
31
30
|
"tsdown": "0.23.0",
|
|
32
31
|
"typescript": "6.0.3",
|
|
33
|
-
"typescript-config-silverwind": "21.0.
|
|
34
|
-
"updates": "19.0.
|
|
35
|
-
"updates-config-silverwind": "4.0.
|
|
36
|
-
"versions": "15.5.
|
|
32
|
+
"typescript-config-silverwind": "21.0.1",
|
|
33
|
+
"updates": "19.0.2",
|
|
34
|
+
"updates-config-silverwind": "4.0.7",
|
|
35
|
+
"versions": "15.5.1",
|
|
37
36
|
"vitest": "5.0.2",
|
|
38
|
-
"vitest-config-silverwind": "12.0.
|
|
37
|
+
"vitest-config-silverwind": "12.0.5"
|
|
39
38
|
}
|
|
40
39
|
}
|