tsdown 0.5.1 → 0.5.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.
package/dist/index.js CHANGED
@@ -58,12 +58,35 @@ async function cleanOutDir(cwd, patterns) {
58
58
  }
59
59
  }
60
60
 
61
+ //#endregion
62
+ //#region src/utils/general.ts
63
+ function toArray(val, defaultValue) {
64
+ if (Array.isArray(val)) return val;
65
+ else if (val == null) {
66
+ if (defaultValue) return [defaultValue];
67
+ return [];
68
+ } else return [val];
69
+ }
70
+ function debounce(fn, wait) {
71
+ let timeout;
72
+ return function(...args) {
73
+ if (timeout) clearTimeout(timeout);
74
+ timeout = setTimeout(() => {
75
+ timeout = undefined;
76
+ fn.apply(this, args);
77
+ }, wait);
78
+ };
79
+ }
80
+
61
81
  //#endregion
62
82
  //#region src/features/dts.ts
63
83
  const TEMP_DTS_DIR = ".tsdown-types";
64
- async function bundleDts(options, jsExtension) {
84
+ function getTempDtsDir(format) {
85
+ return `${TEMP_DTS_DIR}-${format}`;
86
+ }
87
+ async function bundleDts(options, jsExtension, format) {
65
88
  const ext = jsExtension.replace("j", "t");
66
- const dtsOutDir = path$5.resolve(options.outDir, TEMP_DTS_DIR);
89
+ const dtsOutDir = path$5.resolve(options.outDir, getTempDtsDir(format));
67
90
  const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path$5.resolve(dtsOutDir, `${key}.d.${ext}`)]));
68
91
  const build$2 = await rollup({
69
92
  input: dtsEntry,
@@ -83,7 +106,7 @@ async function bundleDts(options, jsExtension) {
83
106
  await rm(dtsOutDir, {
84
107
  recursive: true,
85
108
  force: true
86
- });
109
+ }).catch(() => {});
87
110
  }
88
111
 
89
112
  //#endregion
@@ -177,26 +200,6 @@ function shortcuts(restart) {
177
200
  rl.on("line", onInput);
178
201
  }
179
202
 
180
- //#endregion
181
- //#region src/utils/general.ts
182
- function toArray(val, defaultValue) {
183
- if (Array.isArray(val)) return val;
184
- else if (val == null) {
185
- if (defaultValue) return [defaultValue];
186
- return [];
187
- } else return [val];
188
- }
189
- function debounce(fn, wait) {
190
- let timeout;
191
- return function(...args) {
192
- if (timeout) clearTimeout(timeout);
193
- timeout = setTimeout(() => {
194
- timeout = undefined;
195
- fn.apply(this, args);
196
- }, wait);
197
- };
198
- }
199
-
200
203
  //#endregion
201
204
  //#region src/features/watch.ts
202
205
  const endsWithPackageJson = /[\\/]package\.json$/;
@@ -374,16 +377,6 @@ async function buildSingle(resolved) {
374
377
  if (watch) return () => rebuild();
375
378
  async function rebuild(first) {
376
379
  const startTime = performance.now();
377
- const plugins = [
378
- pkg && ExternalPlugin(pkg, resolved.skipNodeModulesBundle),
379
- unused && Unused.rolldown(unused === true ? {} : unused),
380
- dts && IsolatedDecl.rolldown({
381
- ...dts,
382
- extraOutdir: resolved.bundleDts ? TEMP_DTS_DIR : dts.extraOutdir
383
- }),
384
- target && transformPlugin({ target: target && (typeof target === "string" ? target : target.join(",")) }),
385
- userPlugins
386
- ].filter((plugin) => !!plugin);
387
380
  await Promise.all(format.map(async (format$1) => {
388
381
  const inputOptions = await mergeUserOptions({
389
382
  input: entry,
@@ -392,7 +385,16 @@ async function buildSingle(resolved) {
392
385
  treeshake,
393
386
  platform,
394
387
  define,
395
- plugins,
388
+ plugins: [
389
+ pkg && ExternalPlugin(pkg, resolved.skipNodeModulesBundle),
390
+ unused && Unused.rolldown(unused === true ? {} : unused),
391
+ dts && IsolatedDecl.rolldown({
392
+ ...dts,
393
+ extraOutdir: resolved.bundleDts ? getTempDtsDir(format$1) : dts.extraOutdir
394
+ }),
395
+ target && transformPlugin({ target: target && (typeof target === "string" ? target : target.join(",")) }),
396
+ userPlugins
397
+ ].filter((plugin) => !!plugin),
396
398
  inject: { ...shims && getShimsInject(format$1, platform) }
397
399
  }, resolved.inputOptions, [format$1]);
398
400
  const extension = resolveOutputExtension(pkg, format$1);
@@ -409,7 +411,7 @@ async function buildSingle(resolved) {
409
411
  ...inputOptions,
410
412
  output: outputOptions
411
413
  });
412
- if (resolved.dts && resolved.bundleDts) await bundleDts(resolved, extension);
414
+ if (resolved.dts && resolved.bundleDts) await bundleDts(resolved, extension, format$1);
413
415
  }));
414
416
  logger.success(`${first ? "Build" : "Rebuild"} complete in ${Math.round(performance.now() - startTime)}ms`);
415
417
  await onSuccess?.();
package/dist/run.js CHANGED
@@ -5,7 +5,7 @@ import pc from "picocolors";
5
5
  import { cac } from "cac";
6
6
 
7
7
  //#region package.json
8
- var version = "0.5.1";
8
+ var version = "0.5.2";
9
9
 
10
10
  //#endregion
11
11
  //#region src/cli.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "An even faster bundler powered by Rolldown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -68,6 +68,7 @@
68
68
  "tsup": "^8.3.5",
69
69
  "tsx": "^4.19.2",
70
70
  "typescript": "~5.7.2",
71
+ "unplugin-ast": "^0.13.1",
71
72
  "vitest": "^2.2.0-beta.2"
72
73
  },
73
74
  "engines": {