@storm-software/tsdown 0.22.4 → 0.22.6
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 +1 -1
- package/dist/clean.d.cts +10 -10
- package/dist/clean.d.ts +10 -10
- package/package.json +4 -4
- package/dist/tsdown.cjs +0 -440
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
package/dist/clean.d.cts
CHANGED
|
@@ -40,15 +40,15 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
40
40
|
build: z.ZodDefault<z.ZodString>;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
42
|
build: string;
|
|
43
|
-
config?: string | undefined;
|
|
44
43
|
cache?: string | undefined;
|
|
45
44
|
data?: string | undefined;
|
|
45
|
+
config?: string | undefined;
|
|
46
46
|
temp?: string | undefined;
|
|
47
47
|
log?: string | undefined;
|
|
48
48
|
}, {
|
|
49
|
-
config?: string | undefined;
|
|
50
49
|
cache?: string | undefined;
|
|
51
50
|
data?: string | undefined;
|
|
51
|
+
config?: string | undefined;
|
|
52
52
|
temp?: string | undefined;
|
|
53
53
|
log?: string | undefined;
|
|
54
54
|
build?: string | undefined;
|
|
@@ -794,7 +794,6 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
794
794
|
}>]>>]>]>;
|
|
795
795
|
extensions: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
796
796
|
}, "strip", z.ZodTypeAny, {
|
|
797
|
-
env: "development" | "staging" | "production";
|
|
798
797
|
organization: string;
|
|
799
798
|
license: string;
|
|
800
799
|
homepage: string;
|
|
@@ -806,21 +805,22 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
806
805
|
name: string;
|
|
807
806
|
email: string;
|
|
808
807
|
};
|
|
808
|
+
env: "development" | "staging" | "production";
|
|
809
809
|
workspaceRoot: string;
|
|
810
810
|
externalPackagePatterns: string[];
|
|
811
811
|
skipCache: boolean;
|
|
812
812
|
directories: {
|
|
813
813
|
build: string;
|
|
814
|
-
config?: string | undefined;
|
|
815
814
|
cache?: string | undefined;
|
|
816
815
|
data?: string | undefined;
|
|
816
|
+
config?: string | undefined;
|
|
817
817
|
temp?: string | undefined;
|
|
818
818
|
log?: string | undefined;
|
|
819
819
|
};
|
|
820
820
|
packageManager: "npm" | "yarn" | "pnpm" | "bun";
|
|
821
821
|
timezone: string;
|
|
822
822
|
locale: string;
|
|
823
|
-
logLevel: "silent" | "
|
|
823
|
+
logLevel: "silent" | "fatal" | "error" | "warn" | "success" | "info" | "debug" | "trace" | "all";
|
|
824
824
|
registry: {
|
|
825
825
|
npm?: string | undefined;
|
|
826
826
|
github?: string | undefined;
|
|
@@ -977,9 +977,9 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
977
977
|
};
|
|
978
978
|
}>;
|
|
979
979
|
extensions: Record<string, any>;
|
|
980
|
-
name?: string | undefined;
|
|
981
980
|
$schema?: string | null | undefined;
|
|
982
981
|
extends?: string | string[] | undefined;
|
|
982
|
+
name?: string | undefined;
|
|
983
983
|
namespace?: string | undefined;
|
|
984
984
|
repository?: string | undefined;
|
|
985
985
|
preid?: string | undefined;
|
|
@@ -989,9 +989,9 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
989
989
|
email?: string | undefined;
|
|
990
990
|
};
|
|
991
991
|
directories: {
|
|
992
|
-
config?: string | undefined;
|
|
993
992
|
cache?: string | undefined;
|
|
994
993
|
data?: string | undefined;
|
|
994
|
+
config?: string | undefined;
|
|
995
995
|
temp?: string | undefined;
|
|
996
996
|
log?: string | undefined;
|
|
997
997
|
build?: string | undefined;
|
|
@@ -1143,10 +1143,9 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
1143
1143
|
background?: string | undefined;
|
|
1144
1144
|
};
|
|
1145
1145
|
}>;
|
|
1146
|
-
name?: string | undefined;
|
|
1147
|
-
env?: "development" | "staging" | "production" | undefined;
|
|
1148
1146
|
$schema?: string | null | undefined;
|
|
1149
1147
|
extends?: string | string[] | undefined;
|
|
1148
|
+
name?: string | undefined;
|
|
1150
1149
|
namespace?: string | undefined;
|
|
1151
1150
|
organization?: string | undefined;
|
|
1152
1151
|
repository?: string | undefined;
|
|
@@ -1157,13 +1156,14 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
1157
1156
|
branch?: string | undefined;
|
|
1158
1157
|
preid?: string | undefined;
|
|
1159
1158
|
owner?: string | undefined;
|
|
1159
|
+
env?: "development" | "staging" | "production" | undefined;
|
|
1160
1160
|
workspaceRoot?: string | undefined;
|
|
1161
1161
|
externalPackagePatterns?: string[] | undefined;
|
|
1162
1162
|
skipCache?: boolean | undefined;
|
|
1163
1163
|
packageManager?: "npm" | "yarn" | "pnpm" | "bun" | undefined;
|
|
1164
1164
|
timezone?: string | undefined;
|
|
1165
1165
|
locale?: string | undefined;
|
|
1166
|
-
logLevel?: "silent" | "
|
|
1166
|
+
logLevel?: "silent" | "fatal" | "error" | "warn" | "success" | "info" | "debug" | "trace" | "all" | undefined;
|
|
1167
1167
|
registry?: {
|
|
1168
1168
|
npm?: string | undefined;
|
|
1169
1169
|
github?: string | undefined;
|
package/dist/clean.d.ts
CHANGED
|
@@ -40,15 +40,15 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
40
40
|
build: z.ZodDefault<z.ZodString>;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
42
|
build: string;
|
|
43
|
-
config?: string | undefined;
|
|
44
43
|
cache?: string | undefined;
|
|
45
44
|
data?: string | undefined;
|
|
45
|
+
config?: string | undefined;
|
|
46
46
|
temp?: string | undefined;
|
|
47
47
|
log?: string | undefined;
|
|
48
48
|
}, {
|
|
49
|
-
config?: string | undefined;
|
|
50
49
|
cache?: string | undefined;
|
|
51
50
|
data?: string | undefined;
|
|
51
|
+
config?: string | undefined;
|
|
52
52
|
temp?: string | undefined;
|
|
53
53
|
log?: string | undefined;
|
|
54
54
|
build?: string | undefined;
|
|
@@ -794,7 +794,6 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
794
794
|
}>]>>]>]>;
|
|
795
795
|
extensions: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
796
796
|
}, "strip", z.ZodTypeAny, {
|
|
797
|
-
env: "development" | "staging" | "production";
|
|
798
797
|
organization: string;
|
|
799
798
|
license: string;
|
|
800
799
|
homepage: string;
|
|
@@ -806,21 +805,22 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
806
805
|
name: string;
|
|
807
806
|
email: string;
|
|
808
807
|
};
|
|
808
|
+
env: "development" | "staging" | "production";
|
|
809
809
|
workspaceRoot: string;
|
|
810
810
|
externalPackagePatterns: string[];
|
|
811
811
|
skipCache: boolean;
|
|
812
812
|
directories: {
|
|
813
813
|
build: string;
|
|
814
|
-
config?: string | undefined;
|
|
815
814
|
cache?: string | undefined;
|
|
816
815
|
data?: string | undefined;
|
|
816
|
+
config?: string | undefined;
|
|
817
817
|
temp?: string | undefined;
|
|
818
818
|
log?: string | undefined;
|
|
819
819
|
};
|
|
820
820
|
packageManager: "npm" | "yarn" | "pnpm" | "bun";
|
|
821
821
|
timezone: string;
|
|
822
822
|
locale: string;
|
|
823
|
-
logLevel: "silent" | "
|
|
823
|
+
logLevel: "silent" | "fatal" | "error" | "warn" | "success" | "info" | "debug" | "trace" | "all";
|
|
824
824
|
registry: {
|
|
825
825
|
npm?: string | undefined;
|
|
826
826
|
github?: string | undefined;
|
|
@@ -977,9 +977,9 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
977
977
|
};
|
|
978
978
|
}>;
|
|
979
979
|
extensions: Record<string, any>;
|
|
980
|
-
name?: string | undefined;
|
|
981
980
|
$schema?: string | null | undefined;
|
|
982
981
|
extends?: string | string[] | undefined;
|
|
982
|
+
name?: string | undefined;
|
|
983
983
|
namespace?: string | undefined;
|
|
984
984
|
repository?: string | undefined;
|
|
985
985
|
preid?: string | undefined;
|
|
@@ -989,9 +989,9 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
989
989
|
email?: string | undefined;
|
|
990
990
|
};
|
|
991
991
|
directories: {
|
|
992
|
-
config?: string | undefined;
|
|
993
992
|
cache?: string | undefined;
|
|
994
993
|
data?: string | undefined;
|
|
994
|
+
config?: string | undefined;
|
|
995
995
|
temp?: string | undefined;
|
|
996
996
|
log?: string | undefined;
|
|
997
997
|
build?: string | undefined;
|
|
@@ -1143,10 +1143,9 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
1143
1143
|
background?: string | undefined;
|
|
1144
1144
|
};
|
|
1145
1145
|
}>;
|
|
1146
|
-
name?: string | undefined;
|
|
1147
|
-
env?: "development" | "staging" | "production" | undefined;
|
|
1148
1146
|
$schema?: string | null | undefined;
|
|
1149
1147
|
extends?: string | string[] | undefined;
|
|
1148
|
+
name?: string | undefined;
|
|
1150
1149
|
namespace?: string | undefined;
|
|
1151
1150
|
organization?: string | undefined;
|
|
1152
1151
|
repository?: string | undefined;
|
|
@@ -1157,13 +1156,14 @@ declare const StormConfigSchema: z.ZodObject<{
|
|
|
1157
1156
|
branch?: string | undefined;
|
|
1158
1157
|
preid?: string | undefined;
|
|
1159
1158
|
owner?: string | undefined;
|
|
1159
|
+
env?: "development" | "staging" | "production" | undefined;
|
|
1160
1160
|
workspaceRoot?: string | undefined;
|
|
1161
1161
|
externalPackagePatterns?: string[] | undefined;
|
|
1162
1162
|
skipCache?: boolean | undefined;
|
|
1163
1163
|
packageManager?: "npm" | "yarn" | "pnpm" | "bun" | undefined;
|
|
1164
1164
|
timezone?: string | undefined;
|
|
1165
1165
|
locale?: string | undefined;
|
|
1166
|
-
logLevel?: "silent" | "
|
|
1166
|
+
logLevel?: "silent" | "fatal" | "error" | "warn" | "success" | "info" | "debug" | "trace" | "all" | undefined;
|
|
1167
1167
|
registry?: {
|
|
1168
1168
|
npm?: string | undefined;
|
|
1169
1169
|
github?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/tsdown",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing `tsdown` utilities for building Storm Software libraries and applications",
|
|
6
6
|
"repository": {
|
|
@@ -173,9 +173,9 @@
|
|
|
173
173
|
"@microsoft/api-extractor": "^7.48.1",
|
|
174
174
|
"@nx/devkit": "^20.3.1",
|
|
175
175
|
"@nx/js": "^20.3.1",
|
|
176
|
-
"@storm-software/build-tools": "0.136.
|
|
177
|
-
"@storm-software/config": "1.99.
|
|
178
|
-
"@storm-software/config-tools": "1.142.
|
|
176
|
+
"@storm-software/build-tools": "0.136.2",
|
|
177
|
+
"@storm-software/config": "1.99.2",
|
|
178
|
+
"@storm-software/config-tools": "1.142.2",
|
|
179
179
|
"@types/node": "^22.10.2",
|
|
180
180
|
"defu": "6.1.4",
|
|
181
181
|
"rollup": "4.29.1",
|
package/dist/tsdown.cjs
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
-
|
|
5
|
-
// bin/tsdown.ts
|
|
6
|
-
var import_get_config2 = require("@storm-software/config-tools/get-config");
|
|
7
|
-
var import_console3 = require("@storm-software/config-tools/logger/console");
|
|
8
|
-
var import_find_workspace_root2 = require("@storm-software/config-tools/utilities/find-workspace-root");
|
|
9
|
-
var import_process_handler = require("@storm-software/config-tools/utilities/process-handler");
|
|
10
|
-
var import_commander = require("commander");
|
|
11
|
-
|
|
12
|
-
// src/build.ts
|
|
13
|
-
var import_node2 = require("@humanfs/node");
|
|
14
|
-
var import_devkit = require("@nx/devkit");
|
|
15
|
-
var import_build_tools = require("@storm-software/build-tools");
|
|
16
|
-
var import_get_config = require("@storm-software/config-tools/get-config");
|
|
17
|
-
var import_console2 = require("@storm-software/config-tools/logger/console");
|
|
18
|
-
var import_get_log_level = require("@storm-software/config-tools/logger/get-log-level");
|
|
19
|
-
var import_correct_paths = require("@storm-software/config-tools/utilities/correct-paths");
|
|
20
|
-
|
|
21
|
-
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
22
|
-
function isPlainObject(value) {
|
|
23
|
-
if (value === null || typeof value !== "object") {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const prototype = Object.getPrototypeOf(value);
|
|
27
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (Symbol.iterator in value) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (Symbol.toStringTag in value) {
|
|
34
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
__name(isPlainObject, "isPlainObject");
|
|
39
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
40
|
-
if (!isPlainObject(defaults)) {
|
|
41
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
42
|
-
}
|
|
43
|
-
const object = Object.assign({}, defaults);
|
|
44
|
-
for (const key in baseObject) {
|
|
45
|
-
if (key === "__proto__" || key === "constructor") {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
const value = baseObject[key];
|
|
49
|
-
if (value === null || value === void 0) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
56
|
-
object[key] = [...value, ...object[key]];
|
|
57
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
58
|
-
object[key] = _defu(
|
|
59
|
-
value,
|
|
60
|
-
object[key],
|
|
61
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
62
|
-
merger
|
|
63
|
-
);
|
|
64
|
-
} else {
|
|
65
|
-
object[key] = value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return object;
|
|
69
|
-
}
|
|
70
|
-
__name(_defu, "_defu");
|
|
71
|
-
function createDefu(merger) {
|
|
72
|
-
return (...arguments_) => (
|
|
73
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
74
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
__name(createDefu, "createDefu");
|
|
78
|
-
var defu = createDefu();
|
|
79
|
-
var defuFn = createDefu((object, key, currentValue) => {
|
|
80
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
81
|
-
object[key] = currentValue(object[key]);
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
86
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
87
|
-
object[key] = currentValue(object[key]);
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// src/build.ts
|
|
93
|
-
var import_find_workspace_root = require("nx/src/utils/find-workspace-root");
|
|
94
|
-
var import_tsdown = require("tsdown");
|
|
95
|
-
|
|
96
|
-
// src/clean.ts
|
|
97
|
-
var import_node = require("@humanfs/node");
|
|
98
|
-
var import_console = require("@storm-software/config-tools/logger/console");
|
|
99
|
-
async function clean(name = "ESBuild", directory, config) {
|
|
100
|
-
(0, import_console.writeDebug)(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
|
|
101
|
-
const stopwatch = (0, import_console.getStopwatch)(`${name} output clean`);
|
|
102
|
-
await import_node.hfs.deleteAll(directory);
|
|
103
|
-
stopwatch();
|
|
104
|
-
}
|
|
105
|
-
__name(clean, "clean");
|
|
106
|
-
|
|
107
|
-
// src/config.ts
|
|
108
|
-
var DEFAULT_BUILD_OPTIONS = {
|
|
109
|
-
platform: "node",
|
|
110
|
-
target: "node22",
|
|
111
|
-
format: [
|
|
112
|
-
"esm",
|
|
113
|
-
"cjs"
|
|
114
|
-
],
|
|
115
|
-
tsconfig: "tsconfig.json",
|
|
116
|
-
envName: "production",
|
|
117
|
-
globalName: "globalThis",
|
|
118
|
-
unused: {
|
|
119
|
-
level: "error"
|
|
120
|
-
},
|
|
121
|
-
injectShims: true,
|
|
122
|
-
watch: false,
|
|
123
|
-
bundle: true,
|
|
124
|
-
treeshake: true,
|
|
125
|
-
clean: true,
|
|
126
|
-
debug: false
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// src/build.ts
|
|
130
|
-
var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
131
|
-
const projectRoot = userOptions.projectRoot;
|
|
132
|
-
const workspaceRoot = (0, import_find_workspace_root.findWorkspaceRoot)(projectRoot);
|
|
133
|
-
if (!workspaceRoot) {
|
|
134
|
-
throw new Error("Cannot find Nx workspace root");
|
|
135
|
-
}
|
|
136
|
-
const config = await (0, import_get_config.getConfig)(workspaceRoot.dir);
|
|
137
|
-
(0, import_console2.writeDebug)(" \u2699\uFE0F Resolving build options", config);
|
|
138
|
-
const stopwatch = (0, import_console2.getStopwatch)("Build options resolution");
|
|
139
|
-
const projectGraph = await (0, import_devkit.createProjectGraphAsync)({
|
|
140
|
-
exitOnError: true
|
|
141
|
-
});
|
|
142
|
-
const projectJsonPath = (0, import_correct_paths.joinPaths)(workspaceRoot.dir, projectRoot, "project.json");
|
|
143
|
-
if (!await import_node2.hfs.isFile(projectJsonPath)) {
|
|
144
|
-
throw new Error("Cannot find project.json configuration");
|
|
145
|
-
}
|
|
146
|
-
const projectJson = await import_node2.hfs.json(projectJsonPath);
|
|
147
|
-
const projectName = projectJson.name;
|
|
148
|
-
const projectConfigurations = (0, import_devkit.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
149
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
150
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
151
|
-
}
|
|
152
|
-
const options = defu(userOptions, DEFAULT_BUILD_OPTIONS);
|
|
153
|
-
options.name ??= `${projectName}-${options.format}`;
|
|
154
|
-
options.target ??= import_build_tools.DEFAULT_TARGET;
|
|
155
|
-
const packageJsonPath = (0, import_correct_paths.joinPaths)(workspaceRoot.dir, options.projectRoot, "package.json");
|
|
156
|
-
if (!await import_node2.hfs.isFile(packageJsonPath)) {
|
|
157
|
-
throw new Error("Cannot find package.json configuration");
|
|
158
|
-
}
|
|
159
|
-
const env = (0, import_build_tools.getEnv)("tsdown", options);
|
|
160
|
-
const result = {
|
|
161
|
-
...options,
|
|
162
|
-
config,
|
|
163
|
-
...userOptions,
|
|
164
|
-
tsconfig: (0, import_correct_paths.joinPaths)(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
|
|
165
|
-
format: options.format || "cjs",
|
|
166
|
-
entryPoints: await (0, import_build_tools.getEntryPoints)(config, projectRoot, projectJson.sourceRoot, userOptions.entry || [
|
|
167
|
-
"./src/index.ts"
|
|
168
|
-
], userOptions.emitOnAll),
|
|
169
|
-
outdir: userOptions.outputPath || (0, import_correct_paths.joinPaths)("dist", projectRoot),
|
|
170
|
-
plugins: [],
|
|
171
|
-
name: userOptions.name || projectName,
|
|
172
|
-
projectConfigurations,
|
|
173
|
-
projectName,
|
|
174
|
-
projectGraph,
|
|
175
|
-
sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || (0, import_correct_paths.joinPaths)(projectRoot, "src"),
|
|
176
|
-
minify: userOptions.minify || !userOptions.debug,
|
|
177
|
-
verbose: userOptions.verbose || (0, import_get_log_level.isVerbose)() || userOptions.debug === true,
|
|
178
|
-
includeSrc: userOptions.includeSrc === true,
|
|
179
|
-
metafile: userOptions.metafile !== false,
|
|
180
|
-
generatePackageJson: userOptions.generatePackageJson !== false,
|
|
181
|
-
clean: userOptions.clean !== false,
|
|
182
|
-
emitOnAll: userOptions.emitOnAll === true,
|
|
183
|
-
dts: userOptions.emitTypes === true ? {
|
|
184
|
-
transformer: "oxc"
|
|
185
|
-
} : userOptions.emitTypes,
|
|
186
|
-
bundleDts: userOptions.emitTypes,
|
|
187
|
-
assets: userOptions.assets ?? [],
|
|
188
|
-
shims: userOptions.injectShims !== true,
|
|
189
|
-
bundle: userOptions.bundle !== false,
|
|
190
|
-
watch: userOptions.watch === true,
|
|
191
|
-
define: {
|
|
192
|
-
STORM_FORMAT: JSON.stringify(options.format || "cjs"),
|
|
193
|
-
...options.format === "cjs" && options.injectShims ? {
|
|
194
|
-
"import.meta.url": "importMetaUrl"
|
|
195
|
-
} : {},
|
|
196
|
-
...Object.keys(env || {}).reduce((res, key) => {
|
|
197
|
-
const value = JSON.stringify(env[key]);
|
|
198
|
-
return {
|
|
199
|
-
...res,
|
|
200
|
-
[`process.env.${key}`]: value,
|
|
201
|
-
[`import.meta.env.${key}`]: value
|
|
202
|
-
};
|
|
203
|
-
}, {}),
|
|
204
|
-
...options.define
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
stopwatch();
|
|
208
|
-
return result;
|
|
209
|
-
}, "resolveOptions");
|
|
210
|
-
async function generatePackageJson(options) {
|
|
211
|
-
if (options.generatePackageJson !== false && await import_node2.hfs.isFile((0, import_correct_paths.joinPaths)(options.projectRoot, "package.json"))) {
|
|
212
|
-
(0, import_console2.writeDebug)(" \u270D\uFE0F Writing package.json file", options.config);
|
|
213
|
-
const stopwatch = (0, import_console2.getStopwatch)("Write package.json file");
|
|
214
|
-
const packageJsonPath = (0, import_correct_paths.joinPaths)(options.projectRoot, "project.json");
|
|
215
|
-
if (!await import_node2.hfs.isFile(packageJsonPath)) {
|
|
216
|
-
throw new Error("Cannot find package.json configuration");
|
|
217
|
-
}
|
|
218
|
-
let packageJson = await import_node2.hfs.json((0, import_correct_paths.joinPaths)(options.config.workspaceRoot, options.projectRoot, "package.json"));
|
|
219
|
-
if (!packageJson) {
|
|
220
|
-
throw new Error("Cannot find package.json configuration file");
|
|
221
|
-
}
|
|
222
|
-
packageJson = await (0, import_build_tools.addPackageDependencies)(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
223
|
-
packageJson = await (0, import_build_tools.addWorkspacePackageJsonFields)(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
224
|
-
packageJson.exports ??= {};
|
|
225
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
226
|
-
packageJson.exports["."] ??= (0, import_build_tools.addPackageJsonExport)("index", packageJson.type, options.sourceRoot);
|
|
227
|
-
let entryPoints = [
|
|
228
|
-
{
|
|
229
|
-
in: "./src/index.ts",
|
|
230
|
-
out: "./src/index.ts"
|
|
231
|
-
}
|
|
232
|
-
];
|
|
233
|
-
if (options.entryPoints) {
|
|
234
|
-
if (Array.isArray(options.entryPoints)) {
|
|
235
|
-
entryPoints = options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
|
|
236
|
-
in: entryPoint,
|
|
237
|
-
out: entryPoint
|
|
238
|
-
} : entryPoint);
|
|
239
|
-
}
|
|
240
|
-
for (const entryPoint of entryPoints) {
|
|
241
|
-
const split = entryPoint.out.split(".");
|
|
242
|
-
split.pop();
|
|
243
|
-
const entry = split.join(".").replaceAll("\\", "/");
|
|
244
|
-
packageJson.exports[`./${entry}`] ??= (0, import_build_tools.addPackageJsonExport)(entry, packageJson.type, options.sourceRoot);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
248
|
-
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
249
|
-
packageJson.types = "./dist/index.d.ts";
|
|
250
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
251
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
252
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
253
|
-
}
|
|
254
|
-
return ret;
|
|
255
|
-
}, packageJson.exports);
|
|
256
|
-
await (0, import_devkit.writeJsonFile)((0, import_correct_paths.joinPaths)(options.outdir, "package.json"), packageJson);
|
|
257
|
-
stopwatch();
|
|
258
|
-
}
|
|
259
|
-
return options;
|
|
260
|
-
}
|
|
261
|
-
__name(generatePackageJson, "generatePackageJson");
|
|
262
|
-
async function executeTSDown(options) {
|
|
263
|
-
(0, import_console2.writeDebug)(` \u{1F680} Running ${options.name} build`, options.config);
|
|
264
|
-
const stopwatch = (0, import_console2.getStopwatch)(`${options.name} build`);
|
|
265
|
-
await (0, import_tsdown.build)({
|
|
266
|
-
...options,
|
|
267
|
-
entry: options.entryPoints,
|
|
268
|
-
outDir: options.outdir,
|
|
269
|
-
config: false
|
|
270
|
-
});
|
|
271
|
-
stopwatch();
|
|
272
|
-
return options;
|
|
273
|
-
}
|
|
274
|
-
__name(executeTSDown, "executeTSDown");
|
|
275
|
-
async function copyBuildAssets(options) {
|
|
276
|
-
(0, import_console2.writeDebug)(` \u{1F4CB} Copying asset files to output directory: ${options.outdir}`, options.config);
|
|
277
|
-
const stopwatch = (0, import_console2.getStopwatch)(`${options.name} asset copy`);
|
|
278
|
-
await (0, import_build_tools.copyAssets)(options.config, options.assets ?? [], options.outdir, options.projectRoot, options.sourceRoot, true, false);
|
|
279
|
-
stopwatch();
|
|
280
|
-
return options;
|
|
281
|
-
}
|
|
282
|
-
__name(copyBuildAssets, "copyBuildAssets");
|
|
283
|
-
async function reportResults(options) {
|
|
284
|
-
(0, import_console2.writeSuccess)(` \u{1F4E6} The ${options.name} build completed successfully`, options.config);
|
|
285
|
-
}
|
|
286
|
-
__name(reportResults, "reportResults");
|
|
287
|
-
async function cleanOutputPath(options) {
|
|
288
|
-
if (options.clean !== false && options.outdir) {
|
|
289
|
-
await clean(options.name, options.outdir, options.config);
|
|
290
|
-
}
|
|
291
|
-
return options;
|
|
292
|
-
}
|
|
293
|
-
__name(cleanOutputPath, "cleanOutputPath");
|
|
294
|
-
async function build(options) {
|
|
295
|
-
(0, import_console2.writeDebug)(` \u26A1 Executing Storm TSDown pipeline`);
|
|
296
|
-
const stopwatch = (0, import_console2.getStopwatch)("TSDown pipeline");
|
|
297
|
-
try {
|
|
298
|
-
const opts = Array.isArray(options) ? options : [
|
|
299
|
-
options
|
|
300
|
-
];
|
|
301
|
-
if (opts.length === 0) {
|
|
302
|
-
throw new Error("No build options were provided");
|
|
303
|
-
}
|
|
304
|
-
const resolved = await Promise.all(opts.map(async (opt) => await resolveOptions(opt)));
|
|
305
|
-
if (resolved.length > 0) {
|
|
306
|
-
await cleanOutputPath(resolved[0]);
|
|
307
|
-
await generatePackageJson(resolved[0]);
|
|
308
|
-
await Promise.all(resolved.map(async (opt) => {
|
|
309
|
-
await executeTSDown(opt);
|
|
310
|
-
await copyBuildAssets(opt);
|
|
311
|
-
await reportResults(opt);
|
|
312
|
-
}));
|
|
313
|
-
} else {
|
|
314
|
-
(0, import_console2.writeWarning)(" \u{1F6A7} No options were passed to TSBuild. Please check the parameters passed to the `build` function.");
|
|
315
|
-
}
|
|
316
|
-
(0, import_console2.writeSuccess)(" \u{1F3C1} TSDown pipeline build completed successfully");
|
|
317
|
-
} catch (error) {
|
|
318
|
-
(0, import_console2.writeFatal)(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
|
|
319
|
-
throw error;
|
|
320
|
-
} finally {
|
|
321
|
-
stopwatch();
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
__name(build, "build");
|
|
325
|
-
|
|
326
|
-
// bin/tsdown.ts
|
|
327
|
-
async function createProgram(config) {
|
|
328
|
-
try {
|
|
329
|
-
(0, import_console3.writeInfo)("\u26A1 Running Storm TSDown pipeline", config);
|
|
330
|
-
const root = (0, import_find_workspace_root2.findWorkspaceRootSafe)();
|
|
331
|
-
process.env.STORM_WORKSPACE_ROOT ??= root;
|
|
332
|
-
process.env.NX_WORKSPACE_ROOT_PATH ??= root;
|
|
333
|
-
root && process.chdir(root);
|
|
334
|
-
const program = new import_commander.Command("storm-tsdown");
|
|
335
|
-
program.version("1.0.0", "-v --version", "display CLI version");
|
|
336
|
-
program.description("\u26A1 Run the Storm TSDown pipeline").showHelpAfterError().showSuggestionAfterError();
|
|
337
|
-
const projectRootOption = new import_commander.Option("-p --project-root <path>", "The path to the root of the project to build. This path is defined relative to the workspace root.").makeOptionMandatory(true);
|
|
338
|
-
const sourceRootOption = new import_commander.Option("-s --source-root <path>", "The path of the project's source folder to build");
|
|
339
|
-
const nameOption = new import_commander.Option("-n --name <value>", "The name of the project to build");
|
|
340
|
-
const outputPathOption = new import_commander.Option("-o --output-path <path>", "The path of the project's source folder to build").default("dist/{projectRoot}");
|
|
341
|
-
const platformOption = new import_commander.Option("-p --platform <value>", "The platform to build the distribution for").choices([
|
|
342
|
-
"node",
|
|
343
|
-
"neutral",
|
|
344
|
-
"browser"
|
|
345
|
-
]).default("node");
|
|
346
|
-
const formatOption = new import_commander.Option("-f, --format <value...>", "The format to build the distribution in").choices([
|
|
347
|
-
"esm",
|
|
348
|
-
"cjs",
|
|
349
|
-
"iife"
|
|
350
|
-
]).argParser((value, previous) => {
|
|
351
|
-
if (previous === void 0) {
|
|
352
|
-
return [
|
|
353
|
-
value
|
|
354
|
-
];
|
|
355
|
-
} else if (!previous.includes(value)) {
|
|
356
|
-
previous.push(value);
|
|
357
|
-
}
|
|
358
|
-
return previous;
|
|
359
|
-
}).default("esm");
|
|
360
|
-
const cleanOption = new import_commander.Option("-c --clean", "Should the output directory be cleaned before building").default(true);
|
|
361
|
-
const noCleanOption = new import_commander.Option("--no-clean", "Should the output directory be cleaned before building").default(false);
|
|
362
|
-
const bundleOption = new import_commander.Option("-b --bundle", "Should the output be bundled").default(true);
|
|
363
|
-
const noBundleOption = new import_commander.Option("--no-bundle", "Should the output be bundled").default(false);
|
|
364
|
-
const targetOption = new import_commander.Option("-t --target <value>", "The target to build the distribution for").choices([
|
|
365
|
-
"ESNext",
|
|
366
|
-
"ES2015",
|
|
367
|
-
"ES2016",
|
|
368
|
-
"ES2017",
|
|
369
|
-
"ES2018",
|
|
370
|
-
"ES2019",
|
|
371
|
-
"ES2020",
|
|
372
|
-
"ES2021",
|
|
373
|
-
"ES2022",
|
|
374
|
-
"ES2023"
|
|
375
|
-
]).default("ESNext");
|
|
376
|
-
const watchOption = new import_commander.Option("-w --watch", "Should the build process watch for changes").default(false);
|
|
377
|
-
const debugOption = new import_commander.Option("-d --debug", "Should the build process run in debug mode").default(false);
|
|
378
|
-
const bannerOption = new import_commander.Option("--banner <value>", "The banner to prepend to the output");
|
|
379
|
-
const footerOption = new import_commander.Option("--footer <value>", "The footer to prepend to the output");
|
|
380
|
-
const splittingOption = new import_commander.Option("--splitting", "Should the output be split into multiple files").default(true);
|
|
381
|
-
const treeShakingOption = new import_commander.Option("--tree-shaking", "Should tree shaking be enabled").default(true);
|
|
382
|
-
const generatePackageJsonOption = new import_commander.Option("--generate-package-json", "Should a package.json be generated for the output").default(true);
|
|
383
|
-
const emitOnAllOption = new import_commander.Option("--emit-on-all", "Should the output be emitted on all platforms").default(false);
|
|
384
|
-
const metafileOption = new import_commander.Option("--metafile", "Should a metafile be generated for the output").default(true);
|
|
385
|
-
const minifyOption = new import_commander.Option("--minify", "Should the output be minified").default(true);
|
|
386
|
-
const includeSrcOption = new import_commander.Option("--include-src", "Should the source files be included in the output").default(false);
|
|
387
|
-
const verboseOption = new import_commander.Option("--verbose", "Should the build process be verbose").default(false);
|
|
388
|
-
const injectShimsOption = new import_commander.Option("--inject-shims", "Should shims be injected into the output").default(true);
|
|
389
|
-
const emitTypesOption = new import_commander.Option("--emit-types", "Should types be emitted for the output").default(true);
|
|
390
|
-
program.command("build", {
|
|
391
|
-
isDefault: true
|
|
392
|
-
}).alias("bundle").description("Run a TypeScript build using TSDown, API-Extractor, and TSC (for type generation).").addOption(nameOption).addOption(projectRootOption).addOption(sourceRootOption).addOption(outputPathOption).addOption(platformOption).addOption(formatOption).addOption(targetOption).addOption(bundleOption).addOption(noBundleOption).addOption(cleanOption).addOption(noCleanOption).addOption(watchOption).addOption(debugOption).addOption(bannerOption).addOption(footerOption).addOption(splittingOption).addOption(treeShakingOption).addOption(generatePackageJsonOption).addOption(emitOnAllOption).addOption(metafileOption).addOption(minifyOption).addOption(includeSrcOption).addOption(verboseOption).addOption(injectShimsOption).addOption(emitTypesOption).action(buildAction(config));
|
|
393
|
-
program.command("clean").alias("clear").description("Clean the output directory of the project. This command will remove the 'dist' folder.").addOption(nameOption).action(cleanAction(config));
|
|
394
|
-
return program;
|
|
395
|
-
} catch (e) {
|
|
396
|
-
(0, import_console3.writeFatal)(`A fatal error occurred while running the program: ${e.message}`, config);
|
|
397
|
-
process.exit(1);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
__name(createProgram, "createProgram");
|
|
401
|
-
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
402
|
-
try {
|
|
403
|
-
await build({
|
|
404
|
-
...options,
|
|
405
|
-
format: options.format
|
|
406
|
-
});
|
|
407
|
-
} catch (e) {
|
|
408
|
-
(0, import_console3.writeFatal)(`A fatal error occurred while cleaning the TSDown output directory: ${e.message}`, config);
|
|
409
|
-
(0, import_process_handler.exitWithError)(config);
|
|
410
|
-
process.exit(1);
|
|
411
|
-
}
|
|
412
|
-
}, "buildAction");
|
|
413
|
-
var cleanAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
414
|
-
try {
|
|
415
|
-
await clean(options.name, options.output, config);
|
|
416
|
-
} catch (e) {
|
|
417
|
-
(0, import_console3.writeFatal)(`A fatal error occurred while cleaning the TSDown output directory: ${e.message}`, config);
|
|
418
|
-
(0, import_process_handler.exitWithError)(config);
|
|
419
|
-
process.exit(1);
|
|
420
|
-
}
|
|
421
|
-
}, "cleanAction");
|
|
422
|
-
void (async () => {
|
|
423
|
-
const config = await (0, import_get_config2.getConfig)();
|
|
424
|
-
const stopwatch = (0, import_console3.getStopwatch)("Storm TSDown executable");
|
|
425
|
-
try {
|
|
426
|
-
(0, import_process_handler.handleProcess)(config);
|
|
427
|
-
const program = await createProgram(config);
|
|
428
|
-
await program.parseAsync(process.argv);
|
|
429
|
-
(0, import_console3.writeSuccess)(`\u{1F389} Storm TSDown executable has completed successfully!`, config);
|
|
430
|
-
(0, import_process_handler.exitWithSuccess)(config);
|
|
431
|
-
} catch (error) {
|
|
432
|
-
(0, import_console3.writeFatal)(`A fatal error occurred while running Storm TSDown executable:
|
|
433
|
-
|
|
434
|
-
${error.message}`, config);
|
|
435
|
-
(0, import_process_handler.exitWithError)(config);
|
|
436
|
-
process.exit(1);
|
|
437
|
-
} finally {
|
|
438
|
-
stopwatch();
|
|
439
|
-
}
|
|
440
|
-
})();
|