tsdown 0.18.4 → 0.19.0-beta.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.
@@ -1,4 +1,4 @@
1
- import { f as UserConfig, i as InlineConfig, m as UserConfigFn, p as UserConfigExport } from "./index-BfO1W_C3.mjs";
1
+ import { f as UserConfig, i as InlineConfig, m as UserConfigFn, p as UserConfigExport } from "./index-CIxE8YXE.mjs";
2
2
 
3
3
  //#region src/config/options.d.ts
4
4
  declare function mergeConfig(defaults: UserConfig, overrides: UserConfig): UserConfig;
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { a as globalLogger, c as matchPattern, f as resolveComma, h as toArray, i as getNameLabel, m as slash, n as createLogger, p as resolveRegex, r as generateColor, u as pkgExists } from "./logger-s1ImI5j1.mjs";
3
+ import { a as globalLogger, c as matchPattern, f as resolveComma, h as toArray, i as getNameLabel, m as slash, n as createLogger, p as resolveRegex, r as generateColor, u as pkgExists } from "./logger-D_2uXZBG.mjs";
4
4
  import { access, cp, readFile, rm, stat } from "node:fs/promises";
5
5
  import path, { dirname, extname, normalize, sep } from "node:path";
6
6
  import process, { env } from "node:process";
@@ -9,13 +9,13 @@ import { blue, underline } from "ansis";
9
9
  import { createDefu } from "defu";
10
10
  import { createDebug } from "obug";
11
11
  import { glob, isDynamicPattern } from "tinyglobby";
12
+ import { pathToFileURL } from "node:url";
12
13
  const picomatch = __cjs_require("picomatch");
13
14
  import { RE_CSS, RE_DTS } from "rolldown-plugin-dts/filename";
14
15
  import { readFileSync, writeFileSync } from "node:fs";
15
16
  const minVersion = __cjs_require("semver/ranges/min-version.js");
16
17
  import { up } from "empathic/find";
17
18
  import { up as up$1 } from "empathic/package";
18
- import { pathToFileURL } from "node:url";
19
19
  import { init, isSupported } from "import-without-cache";
20
20
  import { createConfigCoreLoader } from "unconfig-core";
21
21
 
@@ -70,12 +70,12 @@ function stripExtname(filePath) {
70
70
 
71
71
  //#endregion
72
72
  //#region src/features/clean.ts
73
- const debug$2 = createDebug("tsdown:clean");
73
+ const debug$3 = createDebug("tsdown:clean");
74
74
  const RE_LAST_SLASH = /[/\\]$/;
75
75
  async function cleanOutDir(configs) {
76
76
  const removes = /* @__PURE__ */ new Set();
77
77
  for (const config of configs) {
78
- if (config.debug && (config.debug.clean ?? true)) config.clean.push(".rolldown");
78
+ if (config.devtools && (config.devtools.clean ?? true)) config.clean.push("node_modules/.rolldown");
79
79
  if (!config.clean.length) continue;
80
80
  const files = await glob(config.clean, {
81
81
  cwd: config.cwd,
@@ -89,10 +89,10 @@ async function cleanOutDir(configs) {
89
89
  if (!removes.size) return;
90
90
  globalLogger.info(`Cleaning ${removes.size} files`);
91
91
  await Promise.all([...removes].map(async (file) => {
92
- debug$2("Removing", file);
92
+ debug$3("Removing", file);
93
93
  await fsRemove(file);
94
94
  }));
95
- debug$2("Removed %d files", removes.size);
95
+ debug$3("Removed %d files", removes.size);
96
96
  }
97
97
  function resolveClean(clean, outDir, cwd) {
98
98
  if (clean === true) clean = [slash(outDir)];
@@ -103,17 +103,23 @@ function resolveClean(clean, outDir, cwd) {
103
103
  async function cleanChunks(outDir, chunks) {
104
104
  await Promise.all(chunks.map(async (chunk) => {
105
105
  const filePath = path.resolve(outDir, chunk.fileName);
106
- debug$2("Removing chunk file", filePath);
106
+ debug$3("Removing chunk file", filePath);
107
107
  await fsRemove(filePath);
108
108
  }));
109
109
  }
110
110
 
111
111
  //#endregion
112
112
  //#region src/features/css.ts
113
+ const defaultCssBundleName = "style.css";
114
+ function resolveCssOptions(options = {}) {
115
+ return {
116
+ splitting: options.splitting ?? true,
117
+ fileName: options.fileName ?? defaultCssBundleName
118
+ };
119
+ }
113
120
  const RE_CSS_HASH = /-[\w-]+\.css$/;
114
121
  const RE_CHUNK_HASH = /-[\w-]+\.(m?js|cjs)$/;
115
122
  const RE_CHUNK_EXT = /\.(m?js|cjs)$/;
116
- const defaultCssBundleName = "style.css";
117
123
  /**
118
124
  * Normalize CSS file name by removing hash pattern and extension.
119
125
  * e.g., "async-DcjEOEdU.css" -> "async"
@@ -268,9 +274,8 @@ function detectIndentation(jsonText) {
268
274
  //#endregion
269
275
  //#region src/features/pkg/exports.ts
270
276
  async function writeExports(options, chunks) {
271
- const pkg = options.pkg;
272
- const exports = options.exports;
273
- const { publishExports, ...generated } = await generateExports(pkg, chunks, exports, options.logger);
277
+ const { pkg } = options;
278
+ const { publishExports, ...generated } = await generateExports(pkg, chunks, options);
274
279
  const updatedPkg = {
275
280
  ...pkg,
276
281
  ...generated,
@@ -289,12 +294,15 @@ function shouldExclude(fileName, exclude) {
289
294
  if (!exclude?.length) return false;
290
295
  return matchPattern(fileName, exclude);
291
296
  }
292
- async function generateExports(pkg, chunks, { devExports, all, packageJson = true, exclude, customExports }, logger) {
297
+ async function generateExports(pkg, chunks, options) {
298
+ let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy }, css, logger } = options;
293
299
  const pkgRoot = path.dirname(pkg.packageJsonPath);
294
300
  let main, module, cjsTypes, esmTypes;
295
301
  const exportsMap = /* @__PURE__ */ new Map();
296
302
  const formats = Object.keys(chunks);
297
303
  if (!formats.includes("cjs") && !formats.includes("es")) logger.warn(`No CJS or ESM formats found in chunks for package ${pkg.name}`);
304
+ const isPureESM = formats.length === 1 && formats[0] === "es";
305
+ legacy ??= !isPureESM;
298
306
  for (const [format, chunksByFormat] of Object.entries(chunks)) {
299
307
  if (format !== "es" && format !== "cjs") continue;
300
308
  const filteredChunks = chunksByFormat.filter((chunk) => chunk.type === "chunk" && chunk.isEntry && !shouldExclude(chunk.fileName, exclude));
@@ -305,8 +313,7 @@ async function generateExports(pkg, chunks, { devExports, all, packageJson = tru
305
313
  const isDts = name.endsWith(".d");
306
314
  if (isDts) name = name.slice(0, -2);
307
315
  const isIndex = onlyOneEntry || name === "index";
308
- const outDirRelative = slash(path.relative(pkgRoot, chunk.outDir));
309
- const distFile = `${outDirRelative ? `./${outDirRelative}` : "."}/${normalizedName}`;
316
+ const distFile = join$1(pkgRoot, chunk.outDir, normalizedName);
310
317
  if (isIndex) {
311
318
  name = ".";
312
319
  if (format === "cjs") if (isDts) cjsTypes = distFile;
@@ -332,6 +339,7 @@ async function generateExports(pkg, chunks, { devExports, all, packageJson = tru
332
339
  });
333
340
  let exports = Object.fromEntries(sortedExportsMap.map(([name, subExport]) => [name, genSubExport(devExports, subExport)]));
334
341
  exportMeta(exports, all, packageJson);
342
+ exportCss(exports, chunks, css, pkgRoot);
335
343
  if (customExports) exports = await customExports(exports, {
336
344
  pkg,
337
345
  chunks,
@@ -341,6 +349,7 @@ async function generateExports(pkg, chunks, { devExports, all, packageJson = tru
341
349
  if (devExports) {
342
350
  publishExports = Object.fromEntries(sortedExportsMap.map(([name, subExport]) => [name, genSubExport(false, subExport)]));
343
351
  exportMeta(publishExports, all, packageJson);
352
+ exportCss(publishExports, chunks, css, pkgRoot);
344
353
  if (customExports) publishExports = await customExports(publishExports, {
345
354
  pkg,
346
355
  chunks,
@@ -348,8 +357,8 @@ async function generateExports(pkg, chunks, { devExports, all, packageJson = tru
348
357
  });
349
358
  }
350
359
  return {
351
- main: main || module || pkg.main,
352
- module: module || pkg.module,
360
+ main: legacy ? main || module || pkg.main : void 0,
361
+ module: legacy ? module || pkg.module : void 0,
353
362
  types: cjsTypes || esmTypes || pkg.types,
354
363
  exports,
355
364
  publishExports
@@ -372,6 +381,14 @@ function exportMeta(exports, all, packageJson) {
372
381
  if (all) exports["./*"] = "./*";
373
382
  else if (packageJson) exports["./package.json"] = "./package.json";
374
383
  }
384
+ function exportCss(exports, chunks, { splitting }, pkgRoot) {
385
+ if (splitting) return;
386
+ for (const chunksByFormat of Object.values(chunks)) for (const chunk of chunksByFormat) if (chunk.type === "asset" && RE_CSS.test(chunk.fileName)) {
387
+ const filename = slash(chunk.fileName);
388
+ exports[`./${filename}`] = join$1(pkgRoot, chunk.outDir, filename);
389
+ return;
390
+ }
391
+ }
375
392
  function hasExportsTypes(pkg) {
376
393
  const exports = pkg?.exports;
377
394
  if (!exports) return false;
@@ -384,6 +401,10 @@ function hasExportsTypes(pkg) {
384
401
  }
385
402
  return false;
386
403
  }
404
+ function join$1(pkgRoot, outDir, fileName) {
405
+ const outDirRelative = slash(path.relative(pkgRoot, outDir));
406
+ return `${outDirRelative ? `./${outDirRelative}` : "."}/${fileName}`;
407
+ }
387
408
 
388
409
  //#endregion
389
410
  //#region src/features/target.ts
@@ -438,11 +459,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, color, nameLabel) {
438
459
 
439
460
  //#endregion
440
461
  //#region src/utils/package.ts
441
- const debug$1 = createDebug("tsdown:package");
462
+ const debug$2 = createDebug("tsdown:package");
442
463
  async function readPackageJson(dir) {
443
464
  const packageJsonPath = up$1({ cwd: dir });
444
465
  if (!packageJsonPath) return;
445
- debug$1("Reading package.json:", packageJsonPath);
466
+ debug$2("Reading package.json:", packageJsonPath);
446
467
  const contents = await readFile(packageJsonPath, "utf8");
447
468
  return {
448
469
  ...JSON.parse(contents),
@@ -468,10 +489,10 @@ function normalizeFormat(format) {
468
489
 
469
490
  //#endregion
470
491
  //#region src/config/file.ts
471
- const debug = createDebug("tsdown:config:file");
492
+ const debug$1 = createDebug("tsdown:config:file");
472
493
  async function loadViteConfig(prefix, cwd, configLoader) {
473
494
  const loader = resolveConfigLoader(configLoader);
474
- debug("Loading Vite config via loader: ", loader);
495
+ debug$1("Loading Vite config via loader: ", loader);
475
496
  const parser = createParser(loader);
476
497
  const [result] = await createConfigCoreLoader({
477
498
  sources: [{
@@ -516,7 +537,7 @@ async function loadConfigFile(inlineConfig, workspace) {
516
537
  }
517
538
  }
518
539
  const loader = resolveConfigLoader(inlineConfig.configLoader);
519
- debug("Using config loader:", loader);
540
+ debug$1("Using config loader:", loader);
520
541
  const parser = createParser(loader);
521
542
  const [result] = await createConfigCoreLoader({
522
543
  sources: overrideConfig ? [{
@@ -603,15 +624,15 @@ async function unrunImport(id) {
603
624
 
604
625
  //#endregion
605
626
  //#region src/config/options.ts
606
- const debugLog = createDebug("tsdown:config:options");
627
+ const debug = createDebug("tsdown:config:options");
607
628
  async function resolveUserConfig(userConfig, inlineConfig) {
608
- let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = "ci-only", customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint = false, attw = false, fromVite, alias, tsconfig, report = true, target, env: env$1 = {}, envFile, envPrefix = "TSDOWN_", copy, publicDir, hash = true, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, css, fixedExtension = platform === "node", debug: debug$3 = false, write = true } = userConfig;
629
+ let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = "ci-only", customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint = false, attw = false, fromVite, alias, tsconfig, report = true, target, env: env$1 = {}, envFile, envPrefix = "TSDOWN_", copy, publicDir, hash = true, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, css, fixedExtension = platform === "node", devtools = false, write = true } = userConfig;
609
630
  const pkg = await readPackageJson(cwd);
610
631
  if (workspace) name ||= pkg?.name;
611
632
  const color = generateColor(name);
612
633
  const nameLabel = getNameLabel(color, name);
613
634
  if (!filterConfig(inlineConfig.filter, cwd, name)) {
614
- debugLog("[filter] skipping config %s", cwd);
635
+ debug("[filter] skipping config %s", cwd);
615
636
  return [];
616
637
  }
617
638
  const logger = createLogger(logLevel, {
@@ -660,7 +681,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
660
681
  ...envFromProcess,
661
682
  ...env$1
662
683
  };
663
- debugLog(`Environment variables: %O`, env$1);
684
+ debug(`Environment variables: %O`, env$1);
664
685
  if (fromVite) {
665
686
  const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd, inlineConfig.configLoader);
666
687
  if (viteUserConfig) {
@@ -683,11 +704,11 @@ async function resolveUserConfig(userConfig, inlineConfig) {
683
704
  noExternal = (id) => matchPattern(id, noExternalPatterns);
684
705
  }
685
706
  if (inlineOnly != null) inlineOnly = toArray(inlineOnly);
686
- debug$3 = resolveFeatureOption(debug$3, {});
687
- if (debug$3) if (watch) {
688
- if (debug$3.devtools) logger.warn("Devtools is not supported in watch mode, disabling it.");
689
- debug$3.devtools = false;
690
- } else debug$3.devtools ??= !!pkgExists("@vitejs/devtools/cli");
707
+ devtools = resolveFeatureOption(devtools, {});
708
+ if (devtools) if (watch) {
709
+ if (devtools.ui) logger.warn("Devtools UI is not supported in watch mode, disabling it.");
710
+ devtools.ui = false;
711
+ } else devtools.ui ??= !!pkgExists("@vitejs/devtools/cli");
691
712
  const config = {
692
713
  ...userConfig,
693
714
  alias,
@@ -695,13 +716,9 @@ async function resolveUserConfig(userConfig, inlineConfig) {
695
716
  cjsDefault,
696
717
  clean,
697
718
  copy: publicDir || copy,
698
- css: {
699
- splitting: true,
700
- fileName: defaultCssBundleName,
701
- ...css
702
- },
719
+ css: resolveCssOptions(css),
703
720
  cwd,
704
- debug: debug$3,
721
+ devtools,
705
722
  dts,
706
723
  entry: resolvedEntry,
707
724
  env: env$1,
package/dist/config.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./index-BfO1W_C3.mjs";
2
- import { n as mergeConfig, t as defineConfig } from "./config-NHDK5cAy.mjs";
1
+ import { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./index-CIxE8YXE.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-FSGZ1pUf.mjs";
3
3
  export { UserConfig, UserConfigExport, UserConfigFn, defineConfig, mergeConfig };
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./logger-s1ImI5j1.mjs";
2
- import { n as mergeConfig, t as defineConfig } from "./config-DlCfPR2i.mjs";
1
+ import "./logger-D_2uXZBG.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-qNEP9juZ.mjs";
3
3
 
4
4
  export { defineConfig, mergeConfig };
@@ -59,14 +59,14 @@ interface CssOptions {
59
59
  fileName?: string;
60
60
  }
61
61
  //#endregion
62
- //#region src/features/debug.d.ts
63
- interface DebugOptions extends NonNullable<InputOptions["debug"]> {
62
+ //#region src/features/devtools.d.ts
63
+ interface DevtoolsOptions extends NonNullable<InputOptions["devtools"]> {
64
64
  /**
65
65
  * **[experimental]** Enable devtools integration. `@vitejs/devtools` must be installed as a dependency.
66
66
  *
67
67
  * Defaults to true, if `@vitejs/devtools` is installed.
68
68
  */
69
- devtools?: boolean | Partial<StartOptions>;
69
+ ui?: boolean | Partial<StartOptions>;
70
70
  /**
71
71
  * Clean devtools stale sessions.
72
72
  *
@@ -498,19 +498,6 @@ interface TsdownBundle extends AsyncDisposable {
498
498
  config: ResolvedConfig;
499
499
  }
500
500
  //#endregion
501
- //#region src/utils/logger.d.ts
502
- type LogType = "error" | "warn" | "info";
503
- type LogLevel = LogType | "silent";
504
- interface Logger {
505
- level: LogLevel;
506
- info: (...args: any[]) => void;
507
- warn: (...args: any[]) => void;
508
- warnOnce: (...args: any[]) => void;
509
- error: (...args: any[]) => void;
510
- success: (...args: any[]) => void;
511
- }
512
- declare const globalLogger: Logger;
513
- //#endregion
514
501
  //#region src/features/pkg/exports.d.ts
515
502
  interface ExportsOptions {
516
503
  /**
@@ -539,6 +526,15 @@ interface ExportsOptions {
539
526
  * ```
540
527
  */
541
528
  exclude?: (RegExp | string)[];
529
+ /**
530
+ * Generate legacy fields (`main` and `module`) for older Node.js and bundlers
531
+ * that do not support package `exports` field.
532
+ *
533
+ * Defaults to false, if only ESM builds are included, true otherwise.
534
+ *
535
+ * @see {@link https://github.com/publint/publint/issues/24}
536
+ */
537
+ legacy?: boolean;
542
538
  customExports?: (exports: Record<string, any>, context: {
543
539
  pkg: PackageJson;
544
540
  chunks: ChunksByFormat;
@@ -549,6 +545,19 @@ interface ExportsOptions {
549
545
  //#region src/features/pkg/publint.d.ts
550
546
  interface PublintOptions extends Options {}
551
547
  //#endregion
548
+ //#region src/utils/logger.d.ts
549
+ type LogType = "error" | "warn" | "info";
550
+ type LogLevel = LogType | "silent";
551
+ interface Logger {
552
+ level: LogLevel;
553
+ info: (...args: any[]) => void;
554
+ warn: (...args: any[]) => void;
555
+ warnOnce: (...args: any[]) => void;
556
+ error: (...args: any[]) => void;
557
+ success: (...args: any[]) => void;
558
+ }
559
+ declare const globalLogger: Logger;
560
+ //#endregion
552
561
  //#region src/features/report.d.ts
553
562
  interface ReportOptions {
554
563
  /**
@@ -885,15 +894,15 @@ interface UserConfig {
885
894
  */
886
895
  ignoreWatch?: Arrayable<string | RegExp>;
887
896
  /**
888
- * **[experimental]** Enable debug mode.
897
+ * **[experimental]** Enable devtools.
889
898
  *
890
- * Both debug mode and Vite DevTools are still under development, and this is for early testers only.
899
+ *DevTools is still under development, and this is for early testers only.
891
900
  *
892
901
  * This may slow down the build process significantly.
893
902
  *
894
903
  * @default false
895
904
  */
896
- debug?: WithEnabled<DebugOptions>;
905
+ devtools?: WithEnabled<DevtoolsOptions>;
897
906
  /**
898
907
  * You can specify command to be executed after a successful build, specially useful for Watch mode
899
908
  */
@@ -1010,10 +1019,10 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
1010
1019
  report: false | ReportOptions;
1011
1020
  tsconfig: false | string;
1012
1021
  exports: false | ExportsOptions;
1013
- debug: false | DebugOptions;
1022
+ devtools: false | DevtoolsOptions;
1014
1023
  publint: false | PublintOptions;
1015
1024
  attw: false | AttwOptions;
1016
1025
  unused: false | UnusedOptions;
1017
1026
  }>;
1018
1027
  //#endregion
1019
- export { OutExtensionFactory as A, CopyOptions as B, RolldownChunk as C, ChunkAddonFunction as D, ChunkAddon as E, RolldownContext as F, TsdownHooks as I, DebugOptions as L, PackageJsonWithPath as M, PackageType as N, ChunkAddonObject as O, BuildContext as P, CssOptions as R, globalLogger as S, AttwOptions as T, CopyOptionsFn as V, ReportOptions as _, NoExternalFn as a, ExportsOptions as b, Sourcemap as c, UnusedOptions as d, UserConfig as f, Workspace as g, WithEnabled as h, InlineConfig as i, OutExtensionObject as j, OutExtensionContext as k, TreeshakingOptions as l, UserConfigFn as m, DtsOptions as n, NormalizedFormat as o, UserConfigExport as p, Format as r, ResolvedConfig as s, CIOption as t, TsdownInputOption as u, ReportPlugin as v, TsdownBundle as w, Logger as x, PublintOptions as y, CopyEntry as z };
1028
+ export { OutExtensionFactory as A, CopyOptions as B, RolldownChunk as C, ChunkAddonFunction as D, ChunkAddon as E, RolldownContext as F, TsdownHooks as I, DevtoolsOptions as L, PackageJsonWithPath as M, PackageType as N, ChunkAddonObject as O, BuildContext as P, CssOptions as R, ExportsOptions as S, AttwOptions as T, CopyOptionsFn as V, ReportOptions as _, NoExternalFn as a, globalLogger as b, Sourcemap as c, UnusedOptions as d, UserConfig as f, Workspace as g, WithEnabled as h, InlineConfig as i, OutExtensionObject as j, OutExtensionContext as k, TreeshakingOptions as l, UserConfigFn as m, DtsOptions as n, NormalizedFormat as o, UserConfigExport as p, Format as r, ResolvedConfig as s, CIOption as t, TsdownInputOption as u, ReportPlugin as v, TsdownBundle as w, PublintOptions as x, Logger as y, CopyEntry as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as OutExtensionFactory, B as CopyOptions, C as RolldownChunk, D as ChunkAddonFunction, E as ChunkAddon, F as RolldownContext, I as TsdownHooks, L as DebugOptions, M as PackageJsonWithPath, N as PackageType, O as ChunkAddonObject, P as BuildContext, R as CssOptions, S as globalLogger, T as AttwOptions, V as CopyOptionsFn, _ as ReportOptions, a as NoExternalFn, b as ExportsOptions, c as Sourcemap, d as UnusedOptions, f as UserConfig, g as Workspace, h as WithEnabled, i as InlineConfig, j as OutExtensionObject, k as OutExtensionContext, l as TreeshakingOptions, m as UserConfigFn, n as DtsOptions, o as NormalizedFormat, p as UserConfigExport, r as Format, s as ResolvedConfig, t as CIOption, u as TsdownInputOption, w as TsdownBundle, x as Logger, y as PublintOptions, z as CopyEntry } from "./index-BfO1W_C3.mjs";
2
- import { n as mergeConfig, t as defineConfig } from "./config-NHDK5cAy.mjs";
1
+ import { A as OutExtensionFactory, B as CopyOptions, C as RolldownChunk, D as ChunkAddonFunction, E as ChunkAddon, F as RolldownContext, I as TsdownHooks, L as DevtoolsOptions, M as PackageJsonWithPath, N as PackageType, O as ChunkAddonObject, P as BuildContext, R as CssOptions, S as ExportsOptions, T as AttwOptions, V as CopyOptionsFn, _ as ReportOptions, a as NoExternalFn, b as globalLogger, c as Sourcemap, d as UnusedOptions, f as UserConfig, g as Workspace, h as WithEnabled, i as InlineConfig, j as OutExtensionObject, k as OutExtensionContext, l as TreeshakingOptions, m as UserConfigFn, n as DtsOptions, o as NormalizedFormat, p as UserConfigExport, r as Format, s as ResolvedConfig, t as CIOption, u as TsdownInputOption, w as TsdownBundle, x as PublintOptions, y as Logger, z as CopyEntry } from "./index-CIxE8YXE.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-FSGZ1pUf.mjs";
3
3
  import * as Rolldown from "rolldown";
4
4
 
5
5
  //#region src/index.d.ts
@@ -8,4 +8,4 @@ import * as Rolldown from "rolldown";
8
8
  */
9
9
  declare function build(userOptions?: InlineConfig): Promise<TsdownBundle[]>;
10
10
  //#endregion
11
- export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, CssOptions, DebugOptions, DtsOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, Rolldown, RolldownChunk, RolldownContext, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, defineConfig, globalLogger, mergeConfig };
11
+ export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, CssOptions, DevtoolsOptions, DtsOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, Rolldown, RolldownChunk, RolldownContext, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, defineConfig, globalLogger, mergeConfig };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as globalLogger } from "./logger-s1ImI5j1.mjs";
2
- import { n as mergeConfig, t as defineConfig } from "./config-DlCfPR2i.mjs";
3
- import { i as shimFile, n as build, r as buildSingle, t as Rolldown } from "./src-DrqLE2Pt.mjs";
1
+ import { a as globalLogger } from "./logger-D_2uXZBG.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-qNEP9juZ.mjs";
3
+ import { i as shimFile, n as build, r as buildSingle, t as Rolldown } from "./src-BjKgxr08.mjs";
4
4
 
5
5
  export { Rolldown, build, buildSingle, defineConfig, globalLogger, mergeConfig, shimFile };
@@ -3,6 +3,7 @@ const __cjs_require = __cjs_createRequire(import.meta.url);
3
3
  import { createRequire } from "node:module";
4
4
  import process from "node:process";
5
5
  import { bgRed, bgYellow, blue, green, rgb, yellow } from "ansis";
6
+ import { pathToFileURL } from "node:url";
6
7
  const picomatch = __cjs_require("picomatch");
7
8
 
8
9
  //#region rolldown:runtime
@@ -46,7 +47,7 @@ function pkgExists(moduleName) {
46
47
  }
47
48
  async function importWithError(moduleName, resolvePaths) {
48
49
  let resolved;
49
- if (resolvePaths) resolved = __require.resolve(moduleName, { paths: resolvePaths });
50
+ if (resolvePaths) resolved = pathToFileURL(__require.resolve(moduleName, { paths: resolvePaths })).href;
50
51
  try {
51
52
  return await import(resolved || moduleName);
52
53
  } catch (error) {
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.19.0-beta.1";
3
+
4
+ //#endregion
5
+ export { version as t };
@@ -1,4 +1,4 @@
1
- import { s as ResolvedConfig, v as ReportPlugin, w as TsdownBundle, x as Logger } from "./index-BfO1W_C3.mjs";
1
+ import { s as ResolvedConfig, v as ReportPlugin, w as TsdownBundle, y as Logger } from "./index-CIxE8YXE.mjs";
2
2
  import { Plugin } from "rolldown";
3
3
 
4
4
  //#region src/features/external.d.ts
package/dist/plugins.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import "./logger-s1ImI5j1.mjs";
2
- import "./config-DlCfPR2i.mjs";
3
- import { a as WatchPlugin, c as NodeProtocolPlugin, l as ExternalPlugin, o as ShebangPlugin, s as ReportPlugin } from "./src-DrqLE2Pt.mjs";
1
+ import "./logger-D_2uXZBG.mjs";
2
+ import "./config-qNEP9juZ.mjs";
3
+ import { a as WatchPlugin, c as NodeProtocolPlugin, l as ExternalPlugin, o as ShebangPlugin, s as ReportPlugin } from "./src-BjKgxr08.mjs";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
package/dist/run.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { a as globalLogger, f as resolveComma, h as toArray } from "./logger-s1ImI5j1.mjs";
3
- import { t as version } from "./package-BZkqghxy.mjs";
2
+ import { a as globalLogger, f as resolveComma, h as toArray } from "./logger-D_2uXZBG.mjs";
3
+ import { t as version } from "./package-qmfxt6gc.mjs";
4
4
  import module from "node:module";
5
5
  import process from "node:process";
6
6
  import { dim } from "ansis";
@@ -10,17 +10,17 @@ import { x } from "tinyexec";
10
10
  import { cac } from "cac";
11
11
 
12
12
  //#region src/features/debug.ts
13
- const debug = createDebug("tsdown:debug");
14
- function enableDebugLog(cliOptions) {
15
- const { debugLogs } = cliOptions;
16
- if (!debugLogs) return;
13
+ const debugLog = createDebug("tsdown:debug");
14
+ function enableDebug(cliOptions) {
15
+ const { debug } = cliOptions;
16
+ if (!debug) return;
17
17
  let namespace;
18
- if (debugLogs === true) namespace = "tsdown:*";
19
- else namespace = resolveComma(toArray(debugLogs)).map((v) => `tsdown:${v}`).join(",");
18
+ if (debug === true) namespace = "tsdown:*";
19
+ else namespace = resolveComma(toArray(debug)).map((v) => `tsdown:${v}`).join(",");
20
20
  const ns = namespaces();
21
21
  if (ns) namespace += `,${ns}`;
22
22
  enable(namespace);
23
- debug("Debugging enabled", namespace);
23
+ debugLog("Debugging enabled", namespace);
24
24
  }
25
25
 
26
26
  //#endregion
@@ -30,7 +30,7 @@ cli.help().version(version);
30
30
  cli.command("[...files]", "Bundle files", {
31
31
  ignoreOptionDefaultValue: true,
32
32
  allowUnknownOptions: true
33
- }).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug", "Enable debug mode").option("--debug-logs [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
33
+ }).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
34
34
  globalLogger.level = flags.logLevel || (flags.silent ? "error" : "info");
35
35
  globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
36
36
  const { build: build$1 } = await import("./index.mjs");
@@ -57,7 +57,7 @@ cli.command("migrate", "[deprecated] Migrate from tsup to tsdown. Use \"npx tsdo
57
57
  });
58
58
  async function runCLI() {
59
59
  cli.parse(process.argv, { run: false });
60
- enableDebugLog(cli.options);
60
+ enableDebug(cli.options);
61
61
  try {
62
62
  await cli.runMatchedCommand();
63
63
  } catch (error) {
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { a as globalLogger, c as matchPattern, d as promiseWithResolvers, f as resolveComma, h as toArray, l as noop, m as slash, o as prettyFormat, s as importWithError, t as LogLevels } from "./logger-s1ImI5j1.mjs";
4
- import { a as loadConfigFile, c as formatBytes, d as cleanOutDir, f as fsCopy, h as lowestCommonAncestor, i as resolveUserConfig, l as CssCodeSplitPlugin, m as fsRemove, o as getPackageType, p as fsExists, r as mergeUserOptions, s as writeExports, u as cleanChunks } from "./config-DlCfPR2i.mjs";
5
- import { t as version } from "./package-BZkqghxy.mjs";
3
+ import { a as globalLogger, c as matchPattern, d as promiseWithResolvers, f as resolveComma, h as toArray, l as noop, m as slash, o as prettyFormat, s as importWithError, t as LogLevels } from "./logger-D_2uXZBG.mjs";
4
+ import { a as loadConfigFile, c as formatBytes, d as cleanOutDir, f as fsCopy, h as lowestCommonAncestor, i as resolveUserConfig, l as CssCodeSplitPlugin, m as fsRemove, o as getPackageType, p as fsExists, r as mergeUserOptions, s as writeExports, u as cleanChunks } from "./config-qNEP9juZ.mjs";
5
+ import { t as version } from "./package-qmfxt6gc.mjs";
6
6
  import { builtinModules, isBuiltin } from "node:module";
7
7
  import { chmod, mkdtemp, readFile, writeFile } from "node:fs/promises";
8
8
  import path, { join } from "node:path";
@@ -11,8 +11,8 @@ import util, { formatWithOptions, promisify } from "node:util";
11
11
  import { blue, bold, dim, green, underline } from "ansis";
12
12
  import { createDebug } from "obug";
13
13
  import { glob, isDynamicPattern } from "tinyglobby";
14
- import { RE_CSS, RE_DTS, RE_JS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
15
14
  import { fileURLToPath } from "node:url";
15
+ import { RE_CSS, RE_DTS, RE_JS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
16
16
  import { clearRequireCache } from "import-without-cache";
17
17
  import * as Rolldown from "rolldown";
18
18
  import { VERSION, build, watch } from "rolldown";
@@ -171,6 +171,17 @@ function renameTarget(target, rename, src) {
171
171
  return typeof rename === "string" ? rename : rename(parsedPath.name, parsedPath.ext.replace(".", ""), src);
172
172
  }
173
173
 
174
+ //#endregion
175
+ //#region src/features/devtools.ts
176
+ async function startDevtoolsUI(config) {
177
+ const { start } = await importWithError("@vitejs/devtools/cli-commands");
178
+ await start({
179
+ host: "127.0.0.1",
180
+ open: true,
181
+ ...typeof config.ui === "object" ? config.ui : {}
182
+ });
183
+ }
184
+
174
185
  //#endregion
175
186
  //#region src/features/hooks.ts
176
187
  async function createHooks(options) {
@@ -742,7 +753,7 @@ async function getBuildOptions(config, format, configFiles, bundle, cjsDts = fal
742
753
  return rolldownConfig;
743
754
  }
744
755
  async function resolveInputOptions(config, format, configFiles, bundle, cjsDts, isDualFormat) {
745
- const { alias, cjsDefault, cwd, debug: debug$7, dts, entry, env: env$1, external, globImport, loader, logger, nameLabel, nodeProtocol, platform, plugins: userPlugins, report, shims, target, treeshake, tsconfig, unused, watch: watch$1 } = config;
756
+ const { alias, cjsDefault, cwd, devtools, dts, entry, env: env$1, external, globImport, loader, logger, nameLabel, nodeProtocol, platform, plugins: userPlugins, report, shims, target, treeshake, tsconfig, unused, watch: watch$1 } = config;
746
757
  const plugins = [];
747
758
  if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
748
759
  if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
@@ -806,7 +817,7 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
806
817
  if (log.code === "MIXED_EXPORT") return;
807
818
  defaultHandler(level, log);
808
819
  } : void 0,
809
- debug: debug$7 || void 0,
820
+ devtools: devtools || void 0,
810
821
  checks: { pluginTimings: false }
811
822
  }, config.inputOptions, [format, { cjsDts }]);
812
823
  }
@@ -944,19 +955,11 @@ async function build$1(userOptions = {}) {
944
955
  const bundles = await Promise.all(configs.map((options) => {
945
956
  return buildSingle(options, configFiles, options.pkg ? configChunksByPkg[options.pkg.packageJsonPath].formats.size > 1 : true, clean, restart, done);
946
957
  }));
947
- const firstDevtoolsConfig = configs.find((config) => config.debug && config.debug.devtools);
958
+ const firstDevtoolsConfig = configs.find((config) => config.devtools && config.devtools.ui);
948
959
  if (configs.some((config) => config.watch)) {
949
960
  disposeCbs.push(shortcuts(restart));
950
961
  for (const bundle of bundles) disposeCbs.push(bundle[asyncDispose]);
951
- } else if (firstDevtoolsConfig) {
952
- const { start } = await importWithError("@vitejs/devtools/cli-commands");
953
- const devtoolsOptions = firstDevtoolsConfig.debug.devtools;
954
- await start({
955
- host: "127.0.0.1",
956
- open: true,
957
- ...typeof devtoolsOptions === "object" ? devtoolsOptions : {}
958
- });
959
- }
962
+ } else if (firstDevtoolsConfig) startDevtoolsUI(firstDevtoolsConfig.devtools);
960
963
  return bundles;
961
964
  }
962
965
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tsdown",
3
3
  "type": "module",
4
- "version": "0.18.4",
4
+ "version": "0.19.0-beta.1",
5
5
  "description": "The Elegant Bundler for Libraries",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -22,8 +22,6 @@
22
22
  "./package.json": "./package.json",
23
23
  "./client": "./client.d.ts"
24
24
  },
25
- "main": "./dist/index.mjs",
26
- "module": "./dist/index.mjs",
27
25
  "types": "./dist/index.d.mts",
28
26
  "typesVersions": {
29
27
  "*": {
@@ -84,14 +82,14 @@
84
82
  "import-without-cache": "^0.2.5",
85
83
  "obug": "^2.1.1",
86
84
  "picomatch": "^4.0.3",
87
- "rolldown": "1.0.0-beta.57",
85
+ "rolldown": "1.0.0-beta.58",
88
86
  "rolldown-plugin-dts": "^0.20.0",
89
87
  "semver": "^7.7.3",
90
88
  "tinyexec": "^1.0.2",
91
89
  "tinyglobby": "^0.2.15",
92
90
  "tree-kill": "^1.2.2",
93
91
  "unconfig-core": "^7.4.2",
94
- "unrun": "^0.2.21"
92
+ "unrun": "^0.2.22"
95
93
  },
96
94
  "devDependencies": {
97
95
  "@arethetypeswrong/core": "^0.18.2",
@@ -101,7 +99,7 @@
101
99
  "@types/node": "^25.0.3",
102
100
  "@types/picomatch": "^4.0.2",
103
101
  "@types/semver": "^7.7.1",
104
- "@typescript/native-preview": "7.0.0-dev.20251230.1",
102
+ "@typescript/native-preview": "7.0.0-dev.20260101.1",
105
103
  "@unocss/eslint-plugin": "^66.5.12",
106
104
  "@vitejs/devtools": "^0.0.0-alpha.22",
107
105
  "@vitest/coverage-v8": "4.0.16",
@@ -120,6 +118,7 @@
120
118
  "rolldown-plugin-require-cjs": "^0.3.3",
121
119
  "typescript": "~5.9.3",
122
120
  "unocss": "^66.5.12",
121
+ "unplugin-ast": "^0.15.4",
123
122
  "unplugin-lightningcss": "^0.4.4",
124
123
  "unplugin-unused": "^0.5.6",
125
124
  "vite": "^8.0.0-beta.5",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.18.4";
3
-
4
- //#endregion
5
- export { version as t };