@storm-software/tsdown 0.15.1
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/LICENSE +201 -0
- package/README.md +275 -0
- package/dist/build.cjs +9 -0
- package/dist/build.d.cts +14 -0
- package/dist/build.d.ts +14 -0
- package/dist/build.js +9 -0
- package/dist/chunk-5KRF6IVW.cjs +25 -0
- package/dist/chunk-EPTKG5AH.cjs +565 -0
- package/dist/chunk-GGNOJ77I.js +0 -0
- package/dist/chunk-IZXAJLBV.js +565 -0
- package/dist/chunk-JQTUX47V.cjs +1015 -0
- package/dist/chunk-Q6N3BEI2.js +1015 -0
- package/dist/chunk-SFZRYJZ2.cjs +1 -0
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-UQLCBJOS.js +25 -0
- package/dist/chunk-USNT2KNT.cjs +6 -0
- package/dist/clean.cjs +7 -0
- package/dist/clean.d.cts +1194 -0
- package/dist/clean.d.ts +1194 -0
- package/dist/clean.js +7 -0
- package/dist/config.cjs +7 -0
- package/dist/config.d.cts +8 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +7 -0
- package/dist/index.cjs +16 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +16 -0
- package/dist/tsdown.cjs +440 -0
- package/dist/types.cjs +1 -0
- package/dist/types.d.cts +20 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +1 -0
- package/package.json +1 -0
package/dist/clean.js
ADDED
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TSDownResolvedOptions } from './types.cjs';
|
|
2
|
+
import '@nx/devkit';
|
|
3
|
+
import '@storm-software/build-tools';
|
|
4
|
+
import 'tsdown';
|
|
5
|
+
|
|
6
|
+
declare const DEFAULT_BUILD_OPTIONS: Required<Pick<TSDownResolvedOptions, "platform" | "target" | "format" | "tsconfig" | "envName" | "unused" | "globalName" | "injectShims" | "watch" | "bundle" | "treeshake" | "clean" | "debug">>;
|
|
7
|
+
|
|
8
|
+
export { DEFAULT_BUILD_OPTIONS };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TSDownResolvedOptions } from './types.js';
|
|
2
|
+
import '@nx/devkit';
|
|
3
|
+
import '@storm-software/build-tools';
|
|
4
|
+
import 'tsdown';
|
|
5
|
+
|
|
6
|
+
declare const DEFAULT_BUILD_OPTIONS: Required<Pick<TSDownResolvedOptions, "platform" | "target" | "format" | "tsconfig" | "envName" | "unused" | "globalName" | "injectShims" | "watch" | "bundle" | "treeshake" | "clean" | "debug">>;
|
|
7
|
+
|
|
8
|
+
export { DEFAULT_BUILD_OPTIONS };
|
package/dist/config.js
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkJQTUX47Vcjs = require('./chunk-JQTUX47V.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkEPTKG5AHcjs = require('./chunk-EPTKG5AH.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk5KRF6IVWcjs = require('./chunk-5KRF6IVW.cjs');
|
|
10
|
+
require('./chunk-USNT2KNT.cjs');
|
|
11
|
+
require('./chunk-SFZRYJZ2.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.DEFAULT_BUILD_OPTIONS = _chunk5KRF6IVWcjs.DEFAULT_BUILD_OPTIONS; exports.build = _chunkJQTUX47Vcjs.build; exports.clean = _chunkEPTKG5AHcjs.clean;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { build } from './build.cjs';
|
|
2
|
+
export { clean } from './clean.cjs';
|
|
3
|
+
export { DEFAULT_BUILD_OPTIONS } from './config.cjs';
|
|
4
|
+
export { MaybePromise, TSDownCLIOptions, TSDownOptions, TSDownResolvedOptions } from './types.cjs';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '@nx/devkit';
|
|
7
|
+
import '@storm-software/build-tools';
|
|
8
|
+
import 'tsdown';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { build } from './build.js';
|
|
2
|
+
export { clean } from './clean.js';
|
|
3
|
+
export { DEFAULT_BUILD_OPTIONS } from './config.js';
|
|
4
|
+
export { MaybePromise, TSDownCLIOptions, TSDownOptions, TSDownResolvedOptions } from './types.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '@nx/devkit';
|
|
7
|
+
import '@storm-software/build-tools';
|
|
8
|
+
import 'tsdown';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
build
|
|
3
|
+
} from "./chunk-Q6N3BEI2.js";
|
|
4
|
+
import {
|
|
5
|
+
clean
|
|
6
|
+
} from "./chunk-IZXAJLBV.js";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_BUILD_OPTIONS
|
|
9
|
+
} from "./chunk-UQLCBJOS.js";
|
|
10
|
+
import "./chunk-SHUYVCID.js";
|
|
11
|
+
import "./chunk-GGNOJ77I.js";
|
|
12
|
+
export {
|
|
13
|
+
DEFAULT_BUILD_OPTIONS,
|
|
14
|
+
build,
|
|
15
|
+
clean
|
|
16
|
+
};
|
package/dist/tsdown.cjs
ADDED
|
@@ -0,0 +1,440 @@
|
|
|
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_create_storm_config2 = require("@storm-software/config-tools/create-storm-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_create_storm_config = require("@storm-software/config-tools/create-storm-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_create_storm_config.loadStormConfig)(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
|
+
...options.define,
|
|
197
|
+
...Object.keys(env || {}).reduce((res, key) => {
|
|
198
|
+
const value = JSON.stringify(env[key]);
|
|
199
|
+
return {
|
|
200
|
+
...res,
|
|
201
|
+
[`process.env.${key}`]: value,
|
|
202
|
+
[`import.meta.env.${key}`]: value
|
|
203
|
+
};
|
|
204
|
+
}, {})
|
|
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.projectName, 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_create_storm_config2.loadStormConfig)();
|
|
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
|
+
})();
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('./chunk-SFZRYJZ2.cjs');
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProjectGraph, ProjectsConfigurations } from '@nx/devkit';
|
|
2
|
+
import { TypeScriptBuildOptions, TypeScriptBuildResolvedOptions, AdditionalCLIOptions } from '@storm-software/build-tools';
|
|
3
|
+
import { Options } from 'tsdown';
|
|
4
|
+
|
|
5
|
+
type ExternalTSDownOptions = Omit<Options, "config" | "outDir" | "entryPoints">;
|
|
6
|
+
type TSDownOptions = Omit<Omit<ExternalTSDownOptions, "dts" | "bundleDts">, "outbase" | "outfile" | "outExtension" | "banner"> & Omit<TypeScriptBuildOptions, "format"> & {
|
|
7
|
+
emitTypes?: boolean;
|
|
8
|
+
injectShims?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type TSDownResolvedOptions = Omit<TypeScriptBuildResolvedOptions, "target" | "format" | "sourcemap" | "env"> & ExternalTSDownOptions & {
|
|
11
|
+
injectShims: boolean;
|
|
12
|
+
outdir: string;
|
|
13
|
+
projectGraph: ProjectGraph;
|
|
14
|
+
projectConfigurations: ProjectsConfigurations;
|
|
15
|
+
entryPoints: string[];
|
|
16
|
+
};
|
|
17
|
+
type TSDownCLIOptions = AdditionalCLIOptions & Pick<TSDownOptions, "name" | "entry" | "outputPath" | "platform" | "format" | "bundle" | "target" | "watch" | "clean" | "debug" | "banner" | "footer" | "splitting" | "treeShaking" | "generatePackageJson" | "emitOnAll" | "metafile" | "minify" | "includeSrc" | "verbose" | "emitTypes" | "injectShims">;
|
|
18
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
19
|
+
|
|
20
|
+
export type { MaybePromise, TSDownCLIOptions, TSDownOptions, TSDownResolvedOptions };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProjectGraph, ProjectsConfigurations } from '@nx/devkit';
|
|
2
|
+
import { TypeScriptBuildOptions, TypeScriptBuildResolvedOptions, AdditionalCLIOptions } from '@storm-software/build-tools';
|
|
3
|
+
import { Options } from 'tsdown';
|
|
4
|
+
|
|
5
|
+
type ExternalTSDownOptions = Omit<Options, "config" | "outDir" | "entryPoints">;
|
|
6
|
+
type TSDownOptions = Omit<Omit<ExternalTSDownOptions, "dts" | "bundleDts">, "outbase" | "outfile" | "outExtension" | "banner"> & Omit<TypeScriptBuildOptions, "format"> & {
|
|
7
|
+
emitTypes?: boolean;
|
|
8
|
+
injectShims?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type TSDownResolvedOptions = Omit<TypeScriptBuildResolvedOptions, "target" | "format" | "sourcemap" | "env"> & ExternalTSDownOptions & {
|
|
11
|
+
injectShims: boolean;
|
|
12
|
+
outdir: string;
|
|
13
|
+
projectGraph: ProjectGraph;
|
|
14
|
+
projectConfigurations: ProjectsConfigurations;
|
|
15
|
+
entryPoints: string[];
|
|
16
|
+
};
|
|
17
|
+
type TSDownCLIOptions = AdditionalCLIOptions & Pick<TSDownOptions, "name" | "entry" | "outputPath" | "platform" | "format" | "bundle" | "target" | "watch" | "clean" | "debug" | "banner" | "footer" | "splitting" | "treeShaking" | "generatePackageJson" | "emitOnAll" | "metafile" | "minify" | "includeSrc" | "verbose" | "emitTypes" | "injectShims">;
|
|
18
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
19
|
+
|
|
20
|
+
export type { MaybePromise, TSDownCLIOptions, TSDownOptions, TSDownResolvedOptions };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./chunk-GGNOJ77I.js";
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@storm-software/tsdown","version":"0.15.1","type":"module","description":"A package containing `tsdown` utilities for building Storm Software libraries and applications","repository":{"type":"github","url":"https://github.com/storm-software/storm-ops.git","directory":"packages/tsdown"},"homepage":"https://stormsoftware.com","bugs":"https://github.com/storm-software/storm-ops/issues","author":{"name":"Storm Software","email":"contact@stormsoftware.com","url":"https://stormsoftware.com"},"maintainers":[{"name":"Storm Software","email":"contact@stormsoftware.com","url":"https://stormsoftware.com"},{"name":"Pat Sullivan","email":"admin@stormsoftware.com","url":"https://patsullivan.org"}],"contributors":[{"name":"Storm Software","email":"contact@stormsoftware.com","url":"https://stormsoftware.com"}],"funding":{"type":"github","url":"https://github.com/sponsors/storm-software"},"license":"Apache-2.0","private":false,"packageManager":"pnpm@9.15.2","engines":{"node":">=22.4.0","pnpm":">=9.15.2"},"bin":{"storm-tsdown":"./bin/storm-tsdown.js","storm-tsdown-cjs":"./bin/storm-tsdown.cjs","storm-tsdown-esm":"./bin/storm-tsdown.js"},"main":"./dist/index.cjs","module":"./dist/index.js","exports":{"./package.json":"./package.json","./types":{"import":{"types":"./dist/types.d.ts","default":"./dist/types.js"},"require":{"types":"./dist/types.d.cts","default":"./dist/types.cjs"},"default":{"types":"./dist/types.d.ts","default":"./dist/types.js"}},"./index":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"default":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"default":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./config":{"import":{"types":"./dist/config.d.ts","default":"./dist/config.js"},"require":{"types":"./dist/config.d.cts","default":"./dist/config.cjs"},"default":{"types":"./dist/config.d.ts","default":"./dist/config.js"}},"./clean":{"import":{"types":"./dist/clean.d.ts","default":"./dist/clean.js"},"require":{"types":"./dist/clean.d.cts","default":"./dist/clean.cjs"},"default":{"types":"./dist/clean.d.ts","default":"./dist/clean.js"}},"./build":{"import":{"types":"./dist/build/index.d.ts","default":"./dist/build/index.js"},"require":{"types":"./dist/build/index.d.cts","default":"./dist/build/index.cjs"},"default":{"types":"./dist/build/index.d.ts","default":"./dist/build/index.js"}},"./plugins/*":{"import":{"types":"./dist/plugins/*.d.ts","default":"./dist/plugins/*.js"},"require":{"types":"./dist/plugins/*.d.cts","default":"./dist/plugins/*.cjs"},"default":{"types":"./dist/plugins/*.d.ts","default":"./dist/plugins/*.js"}}},"types":"./dist/index.d.ts","files":["dist/**/*"],"keywords":["acidic","cyclone-ui","tsdown","monorepo","storm","storm-ops","storm-stack","sullivanpj"],"peerDependencies":{"@microsoft/api-extractor":"^7.48.1","@nx/devkit":"^20.3.1","@nx/js":"^20.3.1","@storm-software/build-tools":"workspace:*","@storm-software/config-tools":"workspace:*","spdx-exceptions":"^2.5.0","spdx-license-ids":"^3.0.20","tsdown":"0.5.3"},"peerDependenciesMeta":{"@microsoft/api-extractor":{"optional":true},"@nx/devkit":{"optional":false},"@nx/js":{"optional":false},"@storm-software/build-tools":{"optional":false},"@storm-software/config-tools":{"optional":false},"spdx-exceptions":{"optional":true},"spdx-license-ids":{"optional":true},"tsdown":{"optional":false}},"dependencies":{"@humanfs/node":"^0.16.6","chokidar":"^4.0.3","commander":"^12.1.0","es-toolkit":"^1.30.1","globby":"^14.0.2","nx":"^20.3.1","rolldown":"1.0.0-beta.1","source-map":"0.7.4","tsup":"8.3.5"},"devDependencies":{"@microsoft/api-extractor":"^7.48.1","@nx/devkit":"^20.3.1","@nx/js":"^20.3.1","@storm-software/build-tools":"0.123.2","@storm-software/config":"1.92.2","@storm-software/config-tools":"1.131.2","@types/node":"^22.10.2","defu":"6.1.4","rollup":"4.29.1","spdx-exceptions":"^2.5.0","spdx-license-ids":"^3.0.20","tsdown":"0.5.3"},"publishConfig":{"access":"public"},"sideEffects":false}
|