tsdown 0.15.5 → 0.15.6

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from "./config-CCGWF4al.mjs";
2
- import { build, buildSingle, shimFile } from "./src-BwhXafj8.mjs";
2
+ import { build, buildSingle, shimFile } from "./src-Bl9Gdsdl.mjs";
3
3
  import { globalLogger } from "./logger-BjPuONhe.mjs";
4
4
 
5
5
  export { build, buildSingle, defineConfig, globalLogger, shimFile };
@@ -1,5 +1,5 @@
1
1
  import { globalLogger } from "./logger-BjPuONhe.mjs";
2
- import { version } from "./package-D65FBThx.mjs";
2
+ import { version } from "./package-f3XEXjm-.mjs";
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.15.6";
3
+
4
+ //#endregion
5
+ export { version };
package/dist/plugins.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./config-CCGWF4al.mjs";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-BwhXafj8.mjs";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-Bl9Gdsdl.mjs";
3
3
  import "./logger-BjPuONhe.mjs";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.mjs CHANGED
@@ -2,12 +2,12 @@
2
2
  import { createRequire as __cjs_createRequire } from "node:module";
3
3
  const __cjs_require = __cjs_createRequire(import.meta.url);
4
4
  import { globalLogger, resolveComma, toArray } from "./logger-BjPuONhe.mjs";
5
- import { version } from "./package-D65FBThx.mjs";
5
+ import { version } from "./package-f3XEXjm-.mjs";
6
6
  import module from "node:module";
7
7
  import process from "node:process";
8
8
  import { dim } from "ansis";
9
9
  import { VERSION } from "rolldown";
10
- const debug = __cjs_require("debug");
10
+ const Debug = __cjs_require("debug");
11
11
  import { cac } from "cac";
12
12
 
13
13
  //#region src/cli.ts
@@ -24,7 +24,7 @@ cli.command("[...files]", "Bundle files", {
24
24
  await build$1(flags);
25
25
  });
26
26
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
27
- const { migrate } = await import("./migrate-BMP9puR2.mjs");
27
+ const { migrate } = await import("./migrate-CeG6I3xh.mjs");
28
28
  await migrate(args);
29
29
  });
30
30
  async function runCLI() {
@@ -33,10 +33,10 @@ async function runCLI() {
33
33
  let namespace;
34
34
  if (cli.options.debug === true) namespace = "tsdown:*";
35
35
  else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
36
- const enabled = debug.disable();
36
+ const enabled = Debug.disable();
37
37
  if (enabled) namespace += `,${enabled}`;
38
- debug.enable(namespace);
39
- debug("tsdown:debug")("Debugging enabled", namespace);
38
+ Debug.enable(namespace);
39
+ Debug("tsdown:debug")("Debugging enabled", namespace);
40
40
  }
41
41
  try {
42
42
  await cli.runMatchedCommand();
@@ -13,7 +13,7 @@ import child_process from "node:child_process";
13
13
  import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
14
14
  import { tmpdir } from "node:os";
15
15
  import { promisify } from "node:util";
16
- const debug = __cjs_require("debug");
16
+ const Debug = __cjs_require("debug");
17
17
  const coerce = __cjs_require("semver/functions/coerce.js");
18
18
  const satisfies = __cjs_require("semver/functions/satisfies.js");
19
19
  import { glob } from "tinyglobby";
@@ -69,7 +69,7 @@ function lowestCommonAncestor(...filepaths) {
69
69
 
70
70
  //#endregion
71
71
  //#region src/features/attw.ts
72
- const debug$8 = debug("tsdown:attw");
72
+ const debug$7 = Debug("tsdown:attw");
73
73
  const exec$1 = promisify(child_process.exec);
74
74
  /**
75
75
  * ATTW profiles.
@@ -115,7 +115,7 @@ async function attw(options) {
115
115
  }
116
116
  const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
117
117
  const t = performance.now();
118
- debug$8("Running attw check");
118
+ debug$7("Running attw check");
119
119
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
120
120
  let attwCore;
121
121
  try {
@@ -148,7 +148,7 @@ async function attw(options) {
148
148
  } else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
149
149
  } catch (error) {
150
150
  options.logger.error("ATTW check failed:", error);
151
- debug$8("Found errors, setting exit code to 1");
151
+ debug$7("Found errors, setting exit code to 1");
152
152
  process.exitCode = 1;
153
153
  } finally {
154
154
  await fsRemove(tempDir);
@@ -172,7 +172,7 @@ function warnLegacyCJS(config) {
172
172
 
173
173
  //#endregion
174
174
  //#region src/features/clean.ts
175
- const debug$7 = debug("tsdown:clean");
175
+ const debug$6 = Debug("tsdown:clean");
176
176
  const RE_LAST_SLASH = /[/\\]$/;
177
177
  async function cleanOutDir(configs) {
178
178
  const removes = /* @__PURE__ */ new Set();
@@ -189,10 +189,10 @@ async function cleanOutDir(configs) {
189
189
  if (!removes.size) return;
190
190
  globalLogger.info(`Cleaning ${removes.size} files`);
191
191
  await Promise.all([...removes].map(async (file) => {
192
- debug$7("Removing", file);
192
+ debug$6("Removing", file);
193
193
  await fsRemove(file);
194
194
  }));
195
- debug$7("Removed %d files", removes.size);
195
+ debug$6("Removed %d files", removes.size);
196
196
  }
197
197
  function resolveClean(clean, outDir, cwd) {
198
198
  if (clean === true) clean = [slash(outDir)];
@@ -350,7 +350,7 @@ async function createHooks$1(options) {
350
350
 
351
351
  //#endregion
352
352
  //#region src/features/publint.ts
353
- const debug$6 = debug("tsdown:publint");
353
+ const debug$5 = Debug("tsdown:publint");
354
354
  async function publint(options) {
355
355
  if (!options.publint) return;
356
356
  if (!options.pkg) {
@@ -358,11 +358,11 @@ async function publint(options) {
358
358
  return;
359
359
  }
360
360
  const t = performance.now();
361
- debug$6("Running publint");
361
+ debug$5("Running publint");
362
362
  const { publint: publint$1 } = await import("publint");
363
363
  const { formatMessage } = await import("publint/utils");
364
364
  const { messages } = await publint$1(options.publint === true ? {} : options.publint);
365
- debug$6("Found %d issues", messages.length);
365
+ debug$5("Found %d issues", messages.length);
366
366
  if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
367
367
  let hasError = false;
368
368
  for (const message of messages) {
@@ -376,7 +376,7 @@ async function publint(options) {
376
376
  options.logger[logType](formattedMessage);
377
377
  }
378
378
  if (hasError) {
379
- debug$6("Found errors, setting exit code to 1");
379
+ debug$5("Found errors, setting exit code to 1");
380
380
  process.exitCode = 1;
381
381
  }
382
382
  }
@@ -462,11 +462,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
462
462
 
463
463
  //#endregion
464
464
  //#region src/utils/package.ts
465
- const debug$5 = debug("tsdown:package");
465
+ const debug$4 = Debug("tsdown:package");
466
466
  async function readPackageJson(dir) {
467
467
  const packageJsonPath = up$1({ cwd: dir });
468
468
  if (!packageJsonPath) return;
469
- debug$5("Reading package.json:", packageJsonPath);
469
+ debug$4("Reading package.json:", packageJsonPath);
470
470
  const contents = await readFile(packageJsonPath, "utf8");
471
471
  return {
472
472
  ...JSON.parse(contents),
@@ -592,7 +592,7 @@ async function nativeImport(id) {
592
592
 
593
593
  //#endregion
594
594
  //#region src/options/index.ts
595
- const debug$4 = debug("tsdown:options");
595
+ const debug$3 = Debug("tsdown:options");
596
596
  const DEFAULT_EXCLUDE_WORKSPACE = [
597
597
  "**/node_modules/**",
598
598
  "**/dist/**",
@@ -600,20 +600,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
600
600
  "**/t?(e)mp/**"
601
601
  ];
602
602
  async function resolveOptions(options) {
603
- debug$4("options %O", options);
603
+ debug$3("options %O", options);
604
604
  const { configs: rootConfigs, file } = await loadConfigFile(options);
605
605
  const files = [];
606
606
  if (file) {
607
607
  files.push(file);
608
- debug$4("loaded root config file %s", file);
609
- debug$4("root configs %O", rootConfigs);
610
- } else debug$4("no root config file found");
608
+ debug$3("loaded root config file %s", file);
609
+ debug$3("root configs %O", rootConfigs);
610
+ } else debug$3("no root config file found");
611
611
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
612
612
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
613
613
  if (workspaceFiles) files.push(...workspaceFiles);
614
614
  return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
615
615
  }))).flat();
616
- debug$4("resolved configs %O", configs);
616
+ debug$3("resolved configs %O", configs);
617
617
  return {
618
618
  configs,
619
619
  files
@@ -656,16 +656,16 @@ async function resolveWorkspace(config, options) {
656
656
  const files = [];
657
657
  return {
658
658
  configs: (await Promise.all(packages.map(async (cwd) => {
659
- debug$4("loading workspace config %s", cwd);
659
+ debug$3("loading workspace config %s", cwd);
660
660
  const { configs, file } = await loadConfigFile({
661
661
  ...options,
662
662
  config: workspaceConfig,
663
663
  cwd
664
664
  }, cwd);
665
665
  if (file) {
666
- debug$4("loaded workspace config file %s", file);
666
+ debug$3("loaded workspace config file %s", file);
667
667
  files.push(file);
668
- } else debug$4("no workspace config file found in %s", cwd);
668
+ } else debug$3("no workspace config file found in %s", cwd);
669
669
  return configs.map((config$1) => ({
670
670
  ...normalized,
671
671
  cwd,
@@ -770,7 +770,7 @@ async function mergeUserOptions(defaults, user, args) {
770
770
 
771
771
  //#endregion
772
772
  //#region src/features/external.ts
773
- const debug$3 = debug("tsdown:external");
773
+ const debug$2 = Debug("tsdown:external");
774
774
  function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle }) {
775
775
  const deps = pkg && Array.from(getProductionDeps(pkg));
776
776
  return {
@@ -779,7 +779,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
779
779
  if (extraOptions.isEntry || !importer) return;
780
780
  const shouldExternal = await externalStrategy(this, id, importer, extraOptions);
781
781
  const nodeBuiltinModule = id.startsWith("node:") || builtinModules.includes(id);
782
- debug$3("shouldExternal: %s = %s", id, shouldExternal);
782
+ debug$2("shouldExternal: %s = %s", id, shouldExternal);
783
783
  if (shouldExternal === true || shouldExternal === "absolute") return {
784
784
  id,
785
785
  external: shouldExternal,
@@ -787,7 +787,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
787
787
  };
788
788
  if (inlineOnly && !RE_DTS.test(importer) && !nodeBuiltinModule && id[0] !== "." && !path.isAbsolute(id)) {
789
789
  const shouldInline = shouldExternal === "no-external" || matchPattern(id, inlineOnly);
790
- debug$3("shouldInline: %s = %s", id, shouldInline);
790
+ debug$2("shouldInline: %s = %s", id, shouldInline);
791
791
  if (shouldInline) return;
792
792
  const resolved = await this.resolve(id, importer, extraOptions);
793
793
  if (!resolved) return;
@@ -966,7 +966,7 @@ function formatBytes(bytes) {
966
966
 
967
967
  //#endregion
968
968
  //#region src/features/report.ts
969
- const debug$2 = debug("tsdown:report");
969
+ const debug$1 = Debug("tsdown:report");
970
970
  const brotliCompressAsync = promisify(brotliCompress);
971
971
  const gzipAsync = promisify(gzip);
972
972
  const defaultOptions = {
@@ -1016,21 +1016,21 @@ function ReportPlugin(userOptions, logger, cwd, cjsDts, name, isMultiFormat) {
1016
1016
  };
1017
1017
  }
1018
1018
  async function calcSize(options, chunk) {
1019
- debug$2(`Calculating size for`, chunk.fileName);
1019
+ debug$1(`Calculating size for`, chunk.fileName);
1020
1020
  const content = chunk.type === "chunk" ? chunk.code : chunk.source;
1021
1021
  const raw = Buffer.byteLength(content, "utf8");
1022
- debug$2("[size]", chunk.fileName, raw);
1022
+ debug$1("[size]", chunk.fileName, raw);
1023
1023
  let gzip$1 = Infinity;
1024
1024
  let brotli = Infinity;
1025
- if (raw > options.maxCompressSize) debug$2(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
1025
+ if (raw > options.maxCompressSize) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
1026
1026
  else {
1027
1027
  if (options.gzip) {
1028
1028
  gzip$1 = (await gzipAsync(content)).length;
1029
- debug$2("[gzip]", chunk.fileName, gzip$1);
1029
+ debug$1("[gzip]", chunk.fileName, gzip$1);
1030
1030
  }
1031
1031
  if (options.brotli) {
1032
1032
  brotli = (await brotliCompressAsync(content)).length;
1033
- debug$2("[brotli]", chunk.fileName, brotli);
1033
+ debug$1("[brotli]", chunk.fileName, brotli);
1034
1034
  }
1035
1035
  }
1036
1036
  return {
@@ -1077,7 +1077,7 @@ function getShimsInject(format, platform) {
1077
1077
 
1078
1078
  //#endregion
1079
1079
  //#region src/features/rolldown.ts
1080
- const debug$1 = debug("tsdown:rolldown");
1080
+ const debug = Debug("tsdown:rolldown");
1081
1081
  async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
1082
1082
  const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
1083
1083
  const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
@@ -1085,7 +1085,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
1085
1085
  ...inputOptions,
1086
1086
  output: outputOptions
1087
1087
  };
1088
- debug$1("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
1088
+ debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
1089
1089
  return rolldownConfig;
1090
1090
  }
1091
1091
  async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
@@ -1228,6 +1228,7 @@ async function watchBuild(options, configFiles, rebuild, restart) {
1228
1228
  const { watch } = await import("chokidar");
1229
1229
  const debouncedOnChange = debounce(onChange, 100);
1230
1230
  const watcher = watch(files, {
1231
+ cwd: options.cwd,
1231
1232
  ignoreInitial: true,
1232
1233
  ignorePermissionErrors: true,
1233
1234
  ignored: [
@@ -1240,7 +1241,7 @@ async function watchBuild(options, configFiles, rebuild, restart) {
1240
1241
  let pending = [];
1241
1242
  let pendingPromise;
1242
1243
  watcher.on("all", (type, file) => {
1243
- pending.push(file);
1244
+ pending.push(path.resolve(options.cwd, file));
1244
1245
  debouncedOnChange();
1245
1246
  });
1246
1247
  return watcher;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.15.5",
3
+ "version": "0.15.6",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.15.5";
3
-
4
- //#endregion
5
- export { version };