@storm-software/tsdown 0.28.23 → 0.28.25
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 -2
- package/bin/tsdown.cjs +245 -122
- package/dist/build.cjs +4 -5
- package/dist/build.js +3 -4
- package/dist/{chunk-PR5HLZXS.js → chunk-2YE3GBQH.js} +2 -7
- package/dist/{chunk-DEWYQH4B.cjs → chunk-65E5RX7I.cjs} +2 -7
- package/dist/{chunk-3RXXV65R.cjs → chunk-GBBMOENP.cjs} +436 -257
- package/dist/{chunk-X56SYHGK.js → chunk-IUBNNUNA.js} +386 -207
- package/dist/{chunk-2G7S4JNP.cjs → chunk-IUFIA7M2.cjs} +197 -134
- package/dist/{chunk-2WT22RMQ.js → chunk-J4T3BYOA.js} +196 -133
- package/dist/clean.cjs +2 -3
- package/dist/clean.js +1 -2
- package/dist/config.cjs +2 -3
- package/dist/config.js +1 -2
- package/dist/index.cjs +5 -6
- package/dist/index.js +4 -5
- package/dist/types.cjs +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-USNT2KNT.cjs +0 -6
- /package/dist/{chunk-GGNOJ77I.js → chunk-6F4PWJZI.js} +0 -0
- /package/dist/{chunk-SFZRYJZ2.cjs → chunk-ZBPRDZS4.cjs} +0 -0
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 -->
|
|
@@ -40,7 +40,6 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
40
40
|
|
|
41
41
|
<!-- START doctoc -->
|
|
42
42
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
43
|
-
|
|
44
43
|
## Table of Contents
|
|
45
44
|
|
|
46
45
|
- [Storm TSDown Package](#storm-tsdown-package)
|
package/bin/tsdown.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
9
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
10
|
for (let key of __getOwnPropNames(from))
|
|
@@ -55,7 +54,6 @@ function isPlainObject(value) {
|
|
|
55
54
|
}
|
|
56
55
|
return true;
|
|
57
56
|
}
|
|
58
|
-
__name(isPlainObject, "isPlainObject");
|
|
59
57
|
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
60
58
|
if (!isPlainObject(defaults)) {
|
|
61
59
|
return _defu(baseObject, {}, namespace, merger);
|
|
@@ -87,14 +85,12 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
|
87
85
|
}
|
|
88
86
|
return object;
|
|
89
87
|
}
|
|
90
|
-
__name(_defu, "_defu");
|
|
91
88
|
function createDefu(merger) {
|
|
92
89
|
return (...arguments_) => (
|
|
93
90
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
94
91
|
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
95
92
|
);
|
|
96
93
|
}
|
|
97
|
-
__name(createDefu, "createDefu");
|
|
98
94
|
var defu = createDefu();
|
|
99
95
|
var defuFn = createDefu((object, key, currentValue) => {
|
|
100
96
|
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
@@ -124,29 +120,19 @@ async function clean(name = "TSDown", directory, config) {
|
|
|
124
120
|
await cleanDirectories(name, directory, config);
|
|
125
121
|
stopwatch();
|
|
126
122
|
}
|
|
127
|
-
__name(clean, "clean");
|
|
128
123
|
async function cleanDirectories(name = "TSDown", directory, config) {
|
|
129
|
-
await (0, import_promises.rm)(directory, {
|
|
130
|
-
recursive: true,
|
|
131
|
-
force: true
|
|
132
|
-
});
|
|
124
|
+
await (0, import_promises.rm)(directory, { recursive: true, force: true });
|
|
133
125
|
}
|
|
134
|
-
__name(cleanDirectories, "cleanDirectories");
|
|
135
126
|
|
|
136
127
|
// src/config.ts
|
|
137
128
|
var DEFAULT_BUILD_OPTIONS = {
|
|
138
129
|
platform: "node",
|
|
139
130
|
target: "node22",
|
|
140
|
-
format: [
|
|
141
|
-
"esm",
|
|
142
|
-
"cjs"
|
|
143
|
-
],
|
|
131
|
+
format: ["esm", "cjs"],
|
|
144
132
|
tsconfig: "tsconfig.json",
|
|
145
133
|
mode: "production",
|
|
146
134
|
globalName: "globalThis",
|
|
147
|
-
unused: {
|
|
148
|
-
level: "error"
|
|
149
|
-
},
|
|
135
|
+
unused: { level: "error" },
|
|
150
136
|
injectShims: true,
|
|
151
137
|
watch: false,
|
|
152
138
|
bundle: true,
|
|
@@ -156,7 +142,7 @@ var DEFAULT_BUILD_OPTIONS = {
|
|
|
156
142
|
};
|
|
157
143
|
|
|
158
144
|
// src/build.ts
|
|
159
|
-
var resolveOptions =
|
|
145
|
+
var resolveOptions = async (userOptions) => {
|
|
160
146
|
const projectRoot = userOptions.projectRoot;
|
|
161
147
|
const workspaceRoot = (0, import_find_workspace_root.findWorkspaceRoot)(projectRoot);
|
|
162
148
|
if (!workspaceRoot) {
|
|
@@ -168,7 +154,11 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
168
154
|
const projectGraph = await (0, import_devkit.createProjectGraphAsync)({
|
|
169
155
|
exitOnError: true
|
|
170
156
|
});
|
|
171
|
-
const projectJsonPath = (0, import_correct_paths.joinPaths)(
|
|
157
|
+
const projectJsonPath = (0, import_correct_paths.joinPaths)(
|
|
158
|
+
workspaceRoot.dir,
|
|
159
|
+
projectRoot,
|
|
160
|
+
"project.json"
|
|
161
|
+
);
|
|
172
162
|
if (!(0, import_node_fs.existsSync)(projectJsonPath)) {
|
|
173
163
|
throw new Error("Cannot find project.json configuration");
|
|
174
164
|
}
|
|
@@ -177,12 +167,18 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
177
167
|
const projectName = projectJson.name;
|
|
178
168
|
const projectConfigurations = (0, import_devkit.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
179
169
|
if (!projectConfigurations?.projects?.[projectName]) {
|
|
180
|
-
throw new Error(
|
|
170
|
+
throw new Error(
|
|
171
|
+
"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."
|
|
172
|
+
);
|
|
181
173
|
}
|
|
182
174
|
const options = defu(userOptions, DEFAULT_BUILD_OPTIONS);
|
|
183
175
|
options.name ??= `${projectName}-${options.format}`;
|
|
184
176
|
options.target ??= import_build_tools.DEFAULT_TARGET;
|
|
185
|
-
const packageJsonPath = (0, import_correct_paths.joinPaths)(
|
|
177
|
+
const packageJsonPath = (0, import_correct_paths.joinPaths)(
|
|
178
|
+
workspaceRoot.dir,
|
|
179
|
+
options.projectRoot,
|
|
180
|
+
"package.json"
|
|
181
|
+
);
|
|
186
182
|
if (!(0, import_node_fs.existsSync)(packageJsonPath)) {
|
|
187
183
|
throw new Error("Cannot find package.json configuration");
|
|
188
184
|
}
|
|
@@ -191,11 +187,18 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
191
187
|
...options,
|
|
192
188
|
config,
|
|
193
189
|
...userOptions,
|
|
194
|
-
tsconfig: (0, import_correct_paths.joinPaths)(
|
|
190
|
+
tsconfig: (0, import_correct_paths.joinPaths)(
|
|
191
|
+
projectRoot,
|
|
192
|
+
userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"
|
|
193
|
+
),
|
|
195
194
|
format: options.format || "cjs",
|
|
196
|
-
entryPoints: await (0, import_build_tools.getEntryPoints)(
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
entryPoints: await (0, import_build_tools.getEntryPoints)(
|
|
196
|
+
config,
|
|
197
|
+
projectRoot,
|
|
198
|
+
projectJson.sourceRoot,
|
|
199
|
+
userOptions.entry || ["./src/index.ts"],
|
|
200
|
+
userOptions.emitOnAll
|
|
201
|
+
),
|
|
199
202
|
outdir: userOptions.outputPath || (0, import_correct_paths.joinPaths)("dist", projectRoot),
|
|
200
203
|
plugins: [],
|
|
201
204
|
name: userOptions.name || projectName,
|
|
@@ -210,9 +213,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
210
213
|
generatePackageJson: userOptions.generatePackageJson !== false,
|
|
211
214
|
clean: userOptions.clean !== false,
|
|
212
215
|
emitOnAll: userOptions.emitOnAll === true,
|
|
213
|
-
dts: userOptions.dts === true ? {
|
|
214
|
-
transformer: "oxc"
|
|
215
|
-
} : userOptions.dts,
|
|
216
|
+
dts: userOptions.dts === true ? { transformer: "oxc" } : userOptions.dts,
|
|
216
217
|
bundleDts: userOptions.dts,
|
|
217
218
|
assets: userOptions.assets ?? [],
|
|
218
219
|
shims: userOptions.injectShims !== true,
|
|
@@ -236,7 +237,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
236
237
|
};
|
|
237
238
|
stopwatch();
|
|
238
239
|
return result;
|
|
239
|
-
}
|
|
240
|
+
};
|
|
240
241
|
async function generatePackageJson(options) {
|
|
241
242
|
if (options.generatePackageJson !== false && (0, import_node_fs.existsSync)((0, import_correct_paths.joinPaths)(options.projectRoot, "package.json"))) {
|
|
242
243
|
(0, import_console2.writeDebug)(" \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -245,51 +246,74 @@ async function generatePackageJson(options) {
|
|
|
245
246
|
if (!(0, import_node_fs.existsSync)(packageJsonPath)) {
|
|
246
247
|
throw new Error("Cannot find package.json configuration");
|
|
247
248
|
}
|
|
248
|
-
const packageJsonFile = await import_promises2.default.readFile(
|
|
249
|
+
const packageJsonFile = await import_promises2.default.readFile(
|
|
250
|
+
(0, import_correct_paths.joinPaths)(
|
|
251
|
+
options.config.workspaceRoot,
|
|
252
|
+
options.projectRoot,
|
|
253
|
+
"package.json"
|
|
254
|
+
),
|
|
255
|
+
"utf8"
|
|
256
|
+
);
|
|
249
257
|
if (!packageJsonFile) {
|
|
250
258
|
throw new Error("Cannot find package.json configuration file");
|
|
251
259
|
}
|
|
252
260
|
let packageJson = JSON.parse(packageJsonFile);
|
|
253
|
-
packageJson = await (0, import_build_tools.addPackageDependencies)(
|
|
254
|
-
|
|
261
|
+
packageJson = await (0, import_build_tools.addPackageDependencies)(
|
|
262
|
+
options.config.workspaceRoot,
|
|
263
|
+
options.projectRoot,
|
|
264
|
+
options.projectName,
|
|
265
|
+
packageJson
|
|
266
|
+
);
|
|
267
|
+
packageJson = await (0, import_build_tools.addWorkspacePackageJsonFields)(
|
|
268
|
+
options.config,
|
|
269
|
+
options.projectRoot,
|
|
270
|
+
options.sourceRoot,
|
|
271
|
+
options.projectName,
|
|
272
|
+
false,
|
|
273
|
+
packageJson
|
|
274
|
+
);
|
|
255
275
|
packageJson.exports ??= {};
|
|
256
276
|
packageJson.exports["./package.json"] ??= "./package.json";
|
|
257
|
-
packageJson.exports["."] ??= (0, import_build_tools.addPackageJsonExport)(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
];
|
|
277
|
+
packageJson.exports["."] ??= (0, import_build_tools.addPackageJsonExport)(
|
|
278
|
+
"index",
|
|
279
|
+
packageJson.type,
|
|
280
|
+
options.sourceRoot
|
|
281
|
+
);
|
|
282
|
+
let entryPoints = [{ in: "./src/index.ts", out: "./src/index.ts" }];
|
|
264
283
|
if (options.entryPoints) {
|
|
265
284
|
if (Array.isArray(options.entryPoints)) {
|
|
266
|
-
entryPoints = options.entryPoints.map(
|
|
267
|
-
in: entryPoint,
|
|
268
|
-
|
|
269
|
-
} : entryPoint);
|
|
285
|
+
entryPoints = options.entryPoints.map(
|
|
286
|
+
(entryPoint) => typeof entryPoint === "string" ? { in: entryPoint, out: entryPoint } : entryPoint
|
|
287
|
+
);
|
|
270
288
|
}
|
|
271
289
|
for (const entryPoint of entryPoints) {
|
|
272
290
|
const split = entryPoint.out.split(".");
|
|
273
291
|
split.pop();
|
|
274
292
|
const entry = split.join(".").replaceAll("\\", "/");
|
|
275
|
-
packageJson.exports[`./${entry}`] ??= (0, import_build_tools.addPackageJsonExport)(
|
|
293
|
+
packageJson.exports[`./${entry}`] ??= (0, import_build_tools.addPackageJsonExport)(
|
|
294
|
+
entry,
|
|
295
|
+
packageJson.type,
|
|
296
|
+
options.sourceRoot
|
|
297
|
+
);
|
|
276
298
|
}
|
|
277
299
|
}
|
|
278
300
|
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
279
301
|
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
280
302
|
packageJson.types = "./dist/index.d.ts";
|
|
281
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
282
|
-
|
|
283
|
-
ret[key.replace("/index", "")]
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
303
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
304
|
+
(ret, key) => {
|
|
305
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
306
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
307
|
+
}
|
|
308
|
+
return ret;
|
|
309
|
+
},
|
|
310
|
+
packageJson.exports
|
|
311
|
+
);
|
|
287
312
|
await (0, import_devkit.writeJsonFile)((0, import_correct_paths.joinPaths)(options.outdir, "package.json"), packageJson);
|
|
288
313
|
stopwatch();
|
|
289
314
|
}
|
|
290
315
|
return options;
|
|
291
316
|
}
|
|
292
|
-
__name(generatePackageJson, "generatePackageJson");
|
|
293
317
|
async function executeTSDown(options) {
|
|
294
318
|
(0, import_console2.writeDebug)(` \u{1F680} Running ${options.name} build`, options.config);
|
|
295
319
|
const stopwatch = (0, import_console2.getStopwatch)(`${options.name} build`);
|
|
@@ -302,60 +326,78 @@ async function executeTSDown(options) {
|
|
|
302
326
|
stopwatch();
|
|
303
327
|
return options;
|
|
304
328
|
}
|
|
305
|
-
__name(executeTSDown, "executeTSDown");
|
|
306
329
|
async function copyBuildAssets(options) {
|
|
307
|
-
(0, import_console2.writeDebug)(
|
|
330
|
+
(0, import_console2.writeDebug)(
|
|
331
|
+
` \u{1F4CB} Copying asset files to output directory: ${options.outdir}`,
|
|
332
|
+
options.config
|
|
333
|
+
);
|
|
308
334
|
const stopwatch = (0, import_console2.getStopwatch)(`${options.name} asset copy`);
|
|
309
|
-
await (0, import_build_tools.copyAssets)(
|
|
335
|
+
await (0, import_build_tools.copyAssets)(
|
|
336
|
+
options.config,
|
|
337
|
+
options.assets ?? [],
|
|
338
|
+
options.outdir,
|
|
339
|
+
options.projectRoot,
|
|
340
|
+
options.sourceRoot,
|
|
341
|
+
true,
|
|
342
|
+
false
|
|
343
|
+
);
|
|
310
344
|
stopwatch();
|
|
311
345
|
return options;
|
|
312
346
|
}
|
|
313
|
-
__name(copyBuildAssets, "copyBuildAssets");
|
|
314
347
|
async function reportResults(options) {
|
|
315
|
-
(0, import_console2.writeSuccess)(
|
|
348
|
+
(0, import_console2.writeSuccess)(
|
|
349
|
+
` \u{1F4E6} The ${options.name} build completed successfully`,
|
|
350
|
+
options.config
|
|
351
|
+
);
|
|
316
352
|
}
|
|
317
|
-
__name(reportResults, "reportResults");
|
|
318
353
|
async function cleanOutputPath(options) {
|
|
319
354
|
if (options.clean !== false && options.outdir) {
|
|
320
|
-
(0, import_console2.writeDebug)(
|
|
355
|
+
(0, import_console2.writeDebug)(
|
|
356
|
+
` \u{1F9F9} Cleaning ${options.name} output path: ${options.outdir}`,
|
|
357
|
+
options.config
|
|
358
|
+
);
|
|
321
359
|
const stopwatch = (0, import_console2.getStopwatch)(`${options.name} output clean`);
|
|
322
360
|
await cleanDirectories(options.name, options.outdir, options.config);
|
|
323
361
|
stopwatch();
|
|
324
362
|
}
|
|
325
363
|
return options;
|
|
326
364
|
}
|
|
327
|
-
__name(cleanOutputPath, "cleanOutputPath");
|
|
328
365
|
async function build(options) {
|
|
329
366
|
(0, import_console2.writeDebug)(` \u26A1 Executing Storm TSDown pipeline`);
|
|
330
367
|
const stopwatch = (0, import_console2.getStopwatch)("TSDown pipeline");
|
|
331
368
|
try {
|
|
332
|
-
const opts = Array.isArray(options) ? options : [
|
|
333
|
-
options
|
|
334
|
-
];
|
|
369
|
+
const opts = Array.isArray(options) ? options : [options];
|
|
335
370
|
if (opts.length === 0) {
|
|
336
371
|
throw new Error("No build options were provided");
|
|
337
372
|
}
|
|
338
|
-
const resolved = await Promise.all(
|
|
373
|
+
const resolved = await Promise.all(
|
|
374
|
+
opts.map(async (opt) => await resolveOptions(opt))
|
|
375
|
+
);
|
|
339
376
|
if (resolved.length > 0) {
|
|
340
377
|
await cleanOutputPath(resolved[0]);
|
|
341
378
|
await generatePackageJson(resolved[0]);
|
|
342
|
-
await Promise.all(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
379
|
+
await Promise.all(
|
|
380
|
+
resolved.map(async (opt) => {
|
|
381
|
+
await executeTSDown(opt);
|
|
382
|
+
await copyBuildAssets(opt);
|
|
383
|
+
await reportResults(opt);
|
|
384
|
+
})
|
|
385
|
+
);
|
|
347
386
|
} else {
|
|
348
|
-
(0, import_console2.writeWarning)(
|
|
387
|
+
(0, import_console2.writeWarning)(
|
|
388
|
+
" \u{1F6A7} No options were passed to TSBuild. Please check the parameters passed to the `build` function."
|
|
389
|
+
);
|
|
349
390
|
}
|
|
350
391
|
(0, import_console2.writeSuccess)(" \u{1F3C1} TSDown pipeline build completed successfully");
|
|
351
392
|
} catch (error) {
|
|
352
|
-
(0, import_console2.writeFatal)(
|
|
393
|
+
(0, import_console2.writeFatal)(
|
|
394
|
+
"Fatal errors that the build process could not recover from have occured. The build process has been terminated."
|
|
395
|
+
);
|
|
353
396
|
throw error;
|
|
354
397
|
} finally {
|
|
355
398
|
stopwatch();
|
|
356
399
|
}
|
|
357
400
|
}
|
|
358
|
-
__name(build, "build");
|
|
359
401
|
|
|
360
402
|
// bin/tsdown.ts
|
|
361
403
|
async function createProgram(config) {
|
|
@@ -370,34 +412,57 @@ async function createProgram(config) {
|
|
|
370
412
|
const program = new import_commander.Command("storm-tsdown");
|
|
371
413
|
program.version("1.0.0", "-v --version", "display CLI version");
|
|
372
414
|
program.description("\u26A1 Run the Storm TSDown pipeline").showHelpAfterError().showSuggestionAfterError();
|
|
373
|
-
const projectRootOption = new import_commander.Option(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
"
|
|
379
|
-
"
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
"
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
415
|
+
const projectRootOption = new import_commander.Option(
|
|
416
|
+
"-p --project-root <path>",
|
|
417
|
+
"The path to the root of the project to build. This path is defined relative to the workspace root."
|
|
418
|
+
).makeOptionMandatory(true);
|
|
419
|
+
const sourceRootOption = new import_commander.Option(
|
|
420
|
+
"-s --source-root <path>",
|
|
421
|
+
"The path of the project's source folder to build"
|
|
422
|
+
);
|
|
423
|
+
const nameOption = new import_commander.Option(
|
|
424
|
+
"-n --name <value>",
|
|
425
|
+
"The name of the project to build"
|
|
426
|
+
);
|
|
427
|
+
const outputPathOption = new import_commander.Option(
|
|
428
|
+
"-o --output-path <path>",
|
|
429
|
+
"The path of the project's source folder to build"
|
|
430
|
+
).default("dist/{projectRoot}");
|
|
431
|
+
const platformOption = new import_commander.Option(
|
|
432
|
+
"-p --platform <value>",
|
|
433
|
+
"The platform to build the distribution for"
|
|
434
|
+
).choices(["node", "neutral", "browser"]).default("node");
|
|
435
|
+
const formatOption = new import_commander.Option(
|
|
436
|
+
"-f, --format <value...>",
|
|
437
|
+
"The format to build the distribution in"
|
|
438
|
+
).choices(["esm", "cjs", "iife"]).argParser((value, previous) => {
|
|
387
439
|
if (previous === void 0) {
|
|
388
|
-
return [
|
|
389
|
-
value
|
|
390
|
-
];
|
|
440
|
+
return [value];
|
|
391
441
|
} else if (!previous.includes(value)) {
|
|
392
442
|
previous.push(value);
|
|
393
443
|
}
|
|
394
444
|
return previous;
|
|
395
445
|
}).default("esm");
|
|
396
|
-
const cleanOption = new import_commander.Option(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
const
|
|
446
|
+
const cleanOption = new import_commander.Option(
|
|
447
|
+
"-c --clean",
|
|
448
|
+
"Should the output directory be cleaned before building"
|
|
449
|
+
).default(true);
|
|
450
|
+
const noCleanOption = new import_commander.Option(
|
|
451
|
+
"--no-clean",
|
|
452
|
+
"Should the output directory be cleaned before building"
|
|
453
|
+
).default(false);
|
|
454
|
+
const bundleOption = new import_commander.Option(
|
|
455
|
+
"-b --bundle",
|
|
456
|
+
"Should the output be bundled"
|
|
457
|
+
).default(true);
|
|
458
|
+
const noBundleOption = new import_commander.Option(
|
|
459
|
+
"--no-bundle",
|
|
460
|
+
"Should the output be bundled"
|
|
461
|
+
).default(false);
|
|
462
|
+
const targetOption = new import_commander.Option(
|
|
463
|
+
"-t --target <value>",
|
|
464
|
+
"The target to build the distribution for"
|
|
465
|
+
).choices([
|
|
401
466
|
"ESNext",
|
|
402
467
|
"ES2015",
|
|
403
468
|
"ES2016",
|
|
@@ -409,52 +474,104 @@ async function createProgram(config) {
|
|
|
409
474
|
"ES2022",
|
|
410
475
|
"ES2023"
|
|
411
476
|
]).default("ESNext");
|
|
412
|
-
const watchOption = new import_commander.Option(
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
477
|
+
const watchOption = new import_commander.Option(
|
|
478
|
+
"-w --watch",
|
|
479
|
+
"Should the build process watch for changes"
|
|
480
|
+
).default(false);
|
|
481
|
+
const debugOption = new import_commander.Option(
|
|
482
|
+
"-d --debug",
|
|
483
|
+
"Should the build process run in debug mode"
|
|
484
|
+
).default(false);
|
|
485
|
+
const bannerOption = new import_commander.Option(
|
|
486
|
+
"--banner <value>",
|
|
487
|
+
"The banner to prepend to the output"
|
|
488
|
+
);
|
|
489
|
+
const footerOption = new import_commander.Option(
|
|
490
|
+
"--footer <value>",
|
|
491
|
+
"The footer to prepend to the output"
|
|
492
|
+
);
|
|
493
|
+
const splittingOption = new import_commander.Option(
|
|
494
|
+
"--splitting",
|
|
495
|
+
"Should the output be split into multiple files"
|
|
496
|
+
).default(true);
|
|
497
|
+
const treeShakingOption = new import_commander.Option(
|
|
498
|
+
"--tree-shaking",
|
|
499
|
+
"Should tree shaking be enabled"
|
|
500
|
+
).default(true);
|
|
501
|
+
const generatePackageJsonOption = new import_commander.Option(
|
|
502
|
+
"--generate-package-json",
|
|
503
|
+
"Should a package.json be generated for the output"
|
|
504
|
+
).default(true);
|
|
505
|
+
const emitOnAllOption = new import_commander.Option(
|
|
506
|
+
"--emit-on-all",
|
|
507
|
+
"Should the output be emitted on all platforms"
|
|
508
|
+
).default(false);
|
|
509
|
+
const metafileOption = new import_commander.Option(
|
|
510
|
+
"--metafile",
|
|
511
|
+
"Should a metafile be generated for the output"
|
|
512
|
+
).default(true);
|
|
513
|
+
const minifyOption = new import_commander.Option(
|
|
514
|
+
"--minify",
|
|
515
|
+
"Should the output be minified"
|
|
516
|
+
).default(true);
|
|
517
|
+
const includeSrcOption = new import_commander.Option(
|
|
518
|
+
"--include-src",
|
|
519
|
+
"Should the source files be included in the output"
|
|
520
|
+
).default(false);
|
|
521
|
+
const verboseOption = new import_commander.Option(
|
|
522
|
+
"--verbose",
|
|
523
|
+
"Should the build process be verbose"
|
|
524
|
+
).default(false);
|
|
525
|
+
const injectShimsOption = new import_commander.Option(
|
|
526
|
+
"--inject-shims",
|
|
527
|
+
"Should shims be injected into the output"
|
|
528
|
+
).default(true);
|
|
529
|
+
const dtsOption = new import_commander.Option(
|
|
530
|
+
"--emit-types",
|
|
531
|
+
"Should types be emitted for the output"
|
|
532
|
+
).default(true);
|
|
533
|
+
program.command("build", { isDefault: true }).alias("bundle").description(
|
|
534
|
+
"Run a TypeScript build using TSDown, API-Extractor, and TSC (for type generation)."
|
|
535
|
+
).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(dtsOption).action(buildAction(config));
|
|
536
|
+
program.command("clean").alias("clear").description(
|
|
537
|
+
"Clean the output directory of the project. This command will remove the 'dist' folder."
|
|
538
|
+
).addOption(nameOption).action(cleanAction(config));
|
|
430
539
|
return program;
|
|
431
540
|
} catch (e) {
|
|
432
|
-
(0, import_console3.writeFatal)(
|
|
541
|
+
(0, import_console3.writeFatal)(
|
|
542
|
+
`A fatal error occurred while running the program: ${e.message}`,
|
|
543
|
+
config
|
|
544
|
+
);
|
|
433
545
|
process.exit(1);
|
|
434
546
|
}
|
|
435
547
|
}
|
|
436
|
-
|
|
437
|
-
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
548
|
+
var buildAction = (config) => async (options) => {
|
|
438
549
|
try {
|
|
439
550
|
await build({
|
|
440
551
|
...options,
|
|
441
552
|
format: options.format
|
|
442
553
|
});
|
|
443
554
|
} catch (e) {
|
|
444
|
-
(0, import_console3.writeFatal)(
|
|
555
|
+
(0, import_console3.writeFatal)(
|
|
556
|
+
`A fatal error occurred while cleaning the TSDown output directory: ${e.message}`,
|
|
557
|
+
config
|
|
558
|
+
);
|
|
445
559
|
(0, import_process_handler.exitWithError)(config);
|
|
446
560
|
process.exit(1);
|
|
447
561
|
}
|
|
448
|
-
}
|
|
449
|
-
var cleanAction =
|
|
562
|
+
};
|
|
563
|
+
var cleanAction = (config) => async (options) => {
|
|
450
564
|
try {
|
|
451
565
|
await clean(options.name, options.output, config);
|
|
452
566
|
} catch (e) {
|
|
453
|
-
(0, import_console3.writeFatal)(
|
|
567
|
+
(0, import_console3.writeFatal)(
|
|
568
|
+
`A fatal error occurred while cleaning the TSDown output directory: ${e.message}`,
|
|
569
|
+
config
|
|
570
|
+
);
|
|
454
571
|
(0, import_process_handler.exitWithError)(config);
|
|
455
572
|
process.exit(1);
|
|
456
573
|
}
|
|
457
|
-
}
|
|
574
|
+
};
|
|
458
575
|
void (async () => {
|
|
459
576
|
const config = await (0, import_get_config2.getConfig)();
|
|
460
577
|
const stopwatch = (0, import_console3.getStopwatch)("Storm TSDown executable");
|
|
@@ -462,12 +579,18 @@ void (async () => {
|
|
|
462
579
|
(0, import_process_handler.handleProcess)(config);
|
|
463
580
|
const program = await createProgram(config);
|
|
464
581
|
await program.parseAsync(process.argv);
|
|
465
|
-
(0, import_console3.writeSuccess)(
|
|
582
|
+
(0, import_console3.writeSuccess)(
|
|
583
|
+
`\u{1F389} Storm TSDown executable has completed successfully!`,
|
|
584
|
+
config
|
|
585
|
+
);
|
|
466
586
|
(0, import_process_handler.exitWithSuccess)(config);
|
|
467
587
|
} catch (error) {
|
|
468
|
-
(0, import_console3.writeFatal)(
|
|
588
|
+
(0, import_console3.writeFatal)(
|
|
589
|
+
`A fatal error occurred while running Storm TSDown executable:
|
|
469
590
|
|
|
470
|
-
${error.message}`,
|
|
591
|
+
${error.message}`,
|
|
592
|
+
config
|
|
593
|
+
);
|
|
471
594
|
(0, import_process_handler.exitWithError)(config);
|
|
472
595
|
process.exit(1);
|
|
473
596
|
} finally {
|
package/dist/build.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
7
|
-
require('./chunk-USNT2KNT.cjs');
|
|
4
|
+
var _chunkGBBMOENPcjs = require('./chunk-GBBMOENP.cjs');
|
|
5
|
+
require('./chunk-IUFIA7M2.cjs');
|
|
6
|
+
require('./chunk-65E5RX7I.cjs');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
exports.build =
|
|
10
|
+
exports.build = _chunkGBBMOENPcjs.build; exports.cleanOutputPath = _chunkGBBMOENPcjs.cleanOutputPath;
|
package/dist/build.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build,
|
|
3
3
|
cleanOutputPath
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-SHUYVCID.js";
|
|
4
|
+
} from "./chunk-IUBNNUNA.js";
|
|
5
|
+
import "./chunk-J4T3BYOA.js";
|
|
6
|
+
import "./chunk-2YE3GBQH.js";
|
|
8
7
|
export {
|
|
9
8
|
build,
|
|
10
9
|
cleanOutputPath
|
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
var DEFAULT_BUILD_OPTIONS = {
|
|
3
3
|
platform: "node",
|
|
4
4
|
target: "node22",
|
|
5
|
-
format: [
|
|
6
|
-
"esm",
|
|
7
|
-
"cjs"
|
|
8
|
-
],
|
|
5
|
+
format: ["esm", "cjs"],
|
|
9
6
|
tsconfig: "tsconfig.json",
|
|
10
7
|
mode: "production",
|
|
11
8
|
globalName: "globalThis",
|
|
12
|
-
unused: {
|
|
13
|
-
level: "error"
|
|
14
|
-
},
|
|
9
|
+
unused: { level: "error" },
|
|
15
10
|
injectShims: true,
|
|
16
11
|
watch: false,
|
|
17
12
|
bundle: true,
|