@kubb/studio 5.12.7 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -241,7 +241,7 @@ function getElapsedMs(hrStart) {
241
241
  }
242
242
  //#endregion
243
243
  //#region package.json
244
- var version = "5.12.7";
244
+ var version = "5.13.0";
245
245
  //#endregion
246
246
  //#region src/resolveConfig.ts
247
247
  /**
@@ -3269,6 +3269,22 @@ function header(path, size) {
3269
3269
  return value;
3270
3270
  }
3271
3271
  /**
3272
+ * Loads `tsdown` on first use. It is an optional peer dependency: it is large, and only snapshots need it.
3273
+ */
3274
+ async function loadTsdown(load = () => import("tsdown")) {
3275
+ try {
3276
+ return await load();
3277
+ } catch (error) {
3278
+ if (error.code !== "ERR_MODULE_NOT_FOUND" || !error.message.includes("'tsdown'")) throw error;
3279
+ throw new _kubb_core.Diagnostics.Error({
3280
+ code: _kubb_core.Diagnostics.code.missingDependency,
3281
+ severity: "error",
3282
+ message: "Missing dependency: tsdown. A snapshot builds its dist files with tsdown, which Kubb does not install by default.",
3283
+ help: "Run `npm i -D tsdown` in the project, then try again."
3284
+ });
3285
+ }
3286
+ }
3287
+ /**
3272
3288
  * Packs a generation's files into a gzipped, npm-installable tarball: a `package/` root with the
3273
3289
  * generated sources, a `tsdown`-built `dist/` (esm + cjs), and a `package.json` manifest.
3274
3290
  */
@@ -3297,7 +3313,7 @@ async function createSnapshotPackage({ files, packageInfo }) {
3297
3313
  }));
3298
3314
  const entry = [...sources.keys()].filter((path) => /\.(?:[cm]?[jt]sx?)$/.test(path)).map((path) => (0, node_path.join)(root, path));
3299
3315
  if (entry.length) {
3300
- const { build } = await import("tsdown");
3316
+ const { build } = await loadTsdown();
3301
3317
  await build({
3302
3318
  entry,
3303
3319
  outDir: dist,