tsdown-config-silverwind 1.2.0 → 1.3.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/dist/index.d.ts +5 -1
- package/dist/index.js +36 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,5 +12,9 @@ declare function webLib({
|
|
|
12
12
|
url,
|
|
13
13
|
...other
|
|
14
14
|
}: CustomConfig): Options;
|
|
15
|
+
declare function nodeCli({
|
|
16
|
+
url,
|
|
17
|
+
...other
|
|
18
|
+
}: CustomConfig): Options;
|
|
15
19
|
//#endregion
|
|
16
|
-
export { CustomConfig, nodeLib, webLib };
|
|
20
|
+
export { CustomConfig, nodeCli, nodeLib, webLib };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { platform } from "node:os";
|
|
2
3
|
|
|
3
4
|
//#region index.ts
|
|
4
|
-
|
|
5
|
+
function isObject(obj) {
|
|
6
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
7
|
+
}
|
|
8
|
+
function fixWindowsPath(entry) {
|
|
9
|
+
return entry.replaceAll("\\", "/");
|
|
10
|
+
}
|
|
11
|
+
function fixEntry(entry) {
|
|
12
|
+
if (platform() !== "win32") return entry;
|
|
13
|
+
if (typeof entry === "string") return fixWindowsPath(entry);
|
|
14
|
+
else if (Array.isArray(entry)) return entry.map((entry$1) => fixWindowsPath(entry$1));
|
|
15
|
+
else if (isObject(entry)) return Object.fromEntries(Object.entries(entry).map(([key, value]) => {
|
|
16
|
+
return [key, fixWindowsPath(value)];
|
|
17
|
+
}));
|
|
18
|
+
else return entry;
|
|
19
|
+
}
|
|
20
|
+
const base = ({ url, entry, report, loader,...other }) => {
|
|
5
21
|
return {
|
|
6
|
-
entry: fileURLToPath(new URL("index.ts", url)),
|
|
7
|
-
report: {
|
|
22
|
+
entry: fixEntry(entry ?? fileURLToPath(new URL("index.ts", url))),
|
|
23
|
+
report: typeof report === "boolean" ? report : {
|
|
8
24
|
gzip: false,
|
|
9
|
-
brotli: false
|
|
25
|
+
brotli: false,
|
|
26
|
+
...isObject(report) && { report }
|
|
27
|
+
},
|
|
28
|
+
loader: {
|
|
29
|
+
".svg": "text",
|
|
30
|
+
".md": "text",
|
|
31
|
+
".xml": "text",
|
|
32
|
+
".txt": "text",
|
|
33
|
+
...loader
|
|
10
34
|
},
|
|
11
35
|
...other
|
|
12
36
|
};
|
|
@@ -25,6 +49,13 @@ function webLib({ url,...other }) {
|
|
|
25
49
|
...other
|
|
26
50
|
});
|
|
27
51
|
}
|
|
52
|
+
function nodeCli({ url,...other }) {
|
|
53
|
+
return nodeLib({
|
|
54
|
+
platform: "node",
|
|
55
|
+
url,
|
|
56
|
+
...other
|
|
57
|
+
});
|
|
58
|
+
}
|
|
28
59
|
|
|
29
60
|
//#endregion
|
|
30
|
-
export { nodeLib, webLib };
|
|
61
|
+
export { nodeCli, nodeLib, webLib };
|