tsdown-config-silverwind 1.2.1 → 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 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
@@ -2,14 +2,35 @@ import { fileURLToPath } from "node:url";
2
2
  import { platform } from "node:os";
3
3
 
4
4
  //#region index.ts
5
- const base = ({ url,...other }) => {
6
- let entry = fileURLToPath(new URL("index.ts", url));
7
- if (platform() === "win32") entry = entry.replaceAll("\\", "/");
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 }) => {
8
21
  return {
9
- entry,
10
- report: {
22
+ entry: fixEntry(entry ?? fileURLToPath(new URL("index.ts", url))),
23
+ report: typeof report === "boolean" ? report : {
11
24
  gzip: false,
12
- 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
13
34
  },
14
35
  ...other
15
36
  };
@@ -28,6 +49,13 @@ function webLib({ url,...other }) {
28
49
  ...other
29
50
  });
30
51
  }
52
+ function nodeCli({ url,...other }) {
53
+ return nodeLib({
54
+ platform: "node",
55
+ url,
56
+ ...other
57
+ });
58
+ }
31
59
 
32
60
  //#endregion
33
- export { nodeLib, webLib };
61
+ export { nodeCli, nodeLib, webLib };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown-config-silverwind",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Shared tsdown configuration",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "repository": "silverwind/tsdown-config-silverwind",