tsdown 0.12.1 → 0.12.2

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.
@@ -214,6 +214,12 @@ interface Options$3 {
214
214
  * ```
215
215
  */
216
216
  target?: string | string[] | false;
217
+ /**
218
+ * Determines whether unbundle mode is enabled.
219
+ * When set to true, the output files will mirror the input file structure.
220
+ * @default false
221
+ */
222
+ unbundle?: boolean;
217
223
  define?: Record<string, string>;
218
224
  /** @default false */
219
225
  shims?: boolean;
@@ -298,7 +304,7 @@ interface Options$3 {
298
304
  */
299
305
  report?: boolean | ReportOptions;
300
306
  /**
301
- * **[experimental]** Generate exports map for `package.json`.
307
+ * **[experimental]** Generate package exports for `package.json`.
302
308
  *
303
309
  * This will set the `main`, `module`, `types`, `exports` fields in `package.json`
304
310
  * to point to the generated files.
@@ -367,7 +373,7 @@ interface Options$3 {
367
373
  */
368
374
  type UserConfig = Arrayable<Omit<Options$3, "config" | "filter">>;
369
375
  type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
370
- type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name">, {
376
+ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "unbundle">, {
371
377
  format: NormalizedFormat[];
372
378
  target?: string[];
373
379
  clean: string[];
package/dist/config.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { UserConfig, UserConfigFn, defineConfig$1 as defineConfig } from "./config-BVsukpAr.js";
1
+ import { UserConfig, UserConfigFn, defineConfig$1 as defineConfig } from "./config-DQmC8Ss1.js";
2
2
  export { UserConfig, UserConfigFn, defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig$1 as defineConfig, logger, pkgRoot } from "./config-BVsukpAr.js";
1
+ import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig$1 as defineConfig, logger, pkgRoot } from "./config-DQmC8Ss1.js";
2
2
  export { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot };
package/dist/index.js CHANGED
@@ -494,10 +494,7 @@ async function resolveEntry(entry, cwd, name) {
494
494
  async function toObjectEntry(entry, cwd) {
495
495
  if (typeof entry === "string") entry = [entry];
496
496
  if (!Array.isArray(entry)) return entry;
497
- const resolvedEntry = await glob(entry, {
498
- cwd,
499
- absolute: true
500
- });
497
+ const resolvedEntry = (await glob(entry, { cwd })).map((file) => path.resolve(cwd, file));
501
498
  const base = lowestCommonAncestor(...resolvedEntry);
502
499
  return Object.fromEntries(resolvedEntry.map((file) => {
503
500
  const relative = path.relative(base, file);
@@ -868,7 +865,7 @@ async function buildSingle(config, clean) {
868
865
  }
869
866
  }
870
867
  async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
871
- const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, removeNodeProtocol, loader, name } = config;
868
+ const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, removeNodeProtocol, loader, name, unbundle } = config;
872
869
  const plugins = [];
873
870
  if (removeNodeProtocol) plugins.push(NodeProtocolPlugin());
874
871
  if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
@@ -926,7 +923,9 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
926
923
  target,
927
924
  minify: !cjsDts && minify,
928
925
  entryFileNames,
929
- chunkFileNames
926
+ chunkFileNames,
927
+ preserveModules: unbundle,
928
+ preserveModulesRoot: unbundle ? lowestCommonAncestor(...Object.values(entry)) : void 0
930
929
  }, config.outputOptions, [format]);
931
930
  return {
932
931
  ...inputOptions,
@@ -1,5 +1,5 @@
1
1
  import { logger$1 as logger } from "./logger-CS4H_tpu.js";
2
- import { version } from "./package-CkWLthTs.js";
2
+ import { version } from "./package-BnhpFGoQ.js";
3
3
  import process from "node:process";
4
4
  import { bold, green, underline } from "ansis";
5
5
  import { readFile, unlink, writeFile } from "node:fs/promises";
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.12.2";
3
+
4
+ //#endregion
5
+ export { version };
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./config-BVsukpAr.js";
1
+ import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./config-DQmC8Ss1.js";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/run.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { logger$1 as logger, resolveComma, toArray } from "./logger-CS4H_tpu.js";
3
- import { version } from "./package-CkWLthTs.js";
3
+ import { version } from "./package-BnhpFGoQ.js";
4
4
  import module from "node:module";
5
5
  import process from "node:process";
6
6
  import { dim } from "ansis";
@@ -14,7 +14,7 @@ cli.help().version(version);
14
14
  cli.command("[...files]", "Bundle files", {
15
15
  ignoreOptionDefaultValue: true,
16
16
  allowUnknownOptions: true
17
- }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--silent", "Suppress non-error logs").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("--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("--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("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
17
+ }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--silent", "Suppress non-error logs").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("--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("--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 workspace packages, e.g. /regex/ or substring").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
18
18
  logger.setSilent(!!flags.silent);
19
19
  logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
20
20
  const { build: build$1 } = await import("./index.js");
@@ -22,7 +22,7 @@ cli.command("[...files]", "Bundle files", {
22
22
  await build$1(flags);
23
23
  });
24
24
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
25
- const { migrate } = await import("./migrate-BPmYzyBD.js");
25
+ const { migrate } = await import("./migrate-DRENvqVO.js");
26
26
  await migrate(args);
27
27
  });
28
28
  async function runCLI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -70,7 +70,7 @@
70
70
  "diff": "^8.0.1",
71
71
  "empathic": "^1.1.0",
72
72
  "hookable": "^5.5.3",
73
- "rolldown": "1.0.0-beta.9",
73
+ "rolldown": "1.0.0-beta.9-commit.51df2b7",
74
74
  "rolldown-plugin-dts": "^0.13.4",
75
75
  "semver": "^7.7.2",
76
76
  "tinyexec": "^1.0.1",
@@ -96,7 +96,7 @@
96
96
  "typedoc-plugin-markdown": "^4.6.3",
97
97
  "typescript": "~5.8.3",
98
98
  "unocss": "^66.1.2",
99
- "unplugin-lightningcss": "^0.4.0",
99
+ "unplugin-lightningcss": "^0.4.1",
100
100
  "unplugin-unused": "^0.5.0",
101
101
  "vite": "^6.3.5",
102
102
  "vitepress": "^1.6.3",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.12.1";
3
-
4
- //#endregion
5
- export { version };