tsdown 0.5.2 → 0.5.3

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.
Files changed (3) hide show
  1. package/dist/index.js +30 -30
  2. package/dist/run.js +1 -1
  3. package/package.json +14 -14
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { debug, logger } from "./logger-Pk57TMWT.js";
2
2
  import { ExternalPlugin } from "./external-9r3oq3tH.js";
3
- import path, { dirname, normalize, sep, default as path$1, default as path$2, default as path$3, default as path$4, default as path$5, default as path$6 } from "node:path";
4
- import process, { default as process$1, default as process$2, default as process$3 } from "node:process";
3
+ import path, { dirname, normalize, sep } from "node:path";
4
+ import process from "node:process";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { build as build$1 } from "rolldown";
7
7
  import { transformPlugin } from "rolldown/experimental";
@@ -13,12 +13,18 @@ import { rollup } from "rollup";
13
13
  import DtsPlugin from "rollup-plugin-dts";
14
14
  import { readPackageJSON } from "pkg-types";
15
15
  import readline from "node:readline";
16
- import pc, { default as pc$1, default as pc$2 } from "picocolors";
16
+ import pc from "picocolors";
17
17
  import { loadConfig } from "unconfig";
18
18
 
19
19
  //#region src/utils/fs.ts
20
- function fsExists(path$7) {
21
- return access(path$7).then(() => true, () => false);
20
+ function fsExists(path$1) {
21
+ return access(path$1).then(() => true, () => false);
22
+ }
23
+ function fsRemove(path$1) {
24
+ return rm(path$1, {
25
+ force: true,
26
+ recursive: true
27
+ }).catch(() => {});
22
28
  }
23
29
  function lowestCommonAncestor(...filepaths) {
24
30
  if (filepaths.length === 0) return "";
@@ -43,7 +49,7 @@ else {
43
49
  //#region src/features/clean.ts
44
50
  async function cleanOutDir(cwd, patterns) {
45
51
  const files = [];
46
- if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$6.resolve(cwd, file)));
52
+ if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path.resolve(cwd, file)));
47
53
  if (patterns.length) files.push(...await glob(patterns, {
48
54
  cwd,
49
55
  absolute: true
@@ -51,10 +57,7 @@ async function cleanOutDir(cwd, patterns) {
51
57
  logger.info("Cleaning output folder");
52
58
  for (const file of files) {
53
59
  debug("[clean]", "Removing", file);
54
- await rm(file, {
55
- force: true,
56
- recursive: true
57
- });
60
+ await fsRemove(file);
58
61
  }
59
62
  }
60
63
 
@@ -86,8 +89,8 @@ function getTempDtsDir(format) {
86
89
  }
87
90
  async function bundleDts(options, jsExtension, format) {
88
91
  const ext = jsExtension.replace("j", "t");
89
- const dtsOutDir = path$5.resolve(options.outDir, getTempDtsDir(format));
90
- const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path$5.resolve(dtsOutDir, `${key}.d.${ext}`)]));
92
+ const dtsOutDir = path.resolve(options.outDir, getTempDtsDir(format));
93
+ const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path.resolve(dtsOutDir, `${key}.d.${ext}`)]));
91
94
  const build$2 = await rollup({
92
95
  input: dtsEntry,
93
96
  onLog(level, log, defaultHandler) {
@@ -97,22 +100,19 @@ async function bundleDts(options, jsExtension, format) {
97
100
  });
98
101
  let outDir = options.outDir;
99
102
  const extraOutdir = options.dts.extraOutdir;
100
- if (extraOutdir) outDir = path$5.resolve(outDir, extraOutdir);
103
+ if (extraOutdir) outDir = path.resolve(outDir, extraOutdir);
101
104
  await build$2.write({
102
105
  dir: outDir,
103
106
  format: "es",
104
107
  entryFileNames: `[name].d.${ext}`
105
108
  });
106
- await rm(dtsOutDir, {
107
- recursive: true,
108
- force: true
109
- }).catch(() => {});
109
+ await fsRemove(dtsOutDir);
110
110
  }
111
111
 
112
112
  //#endregion
113
113
  //#region src/utils/package.ts
114
114
  async function readPackageJson(dir) {
115
- const packageJsonPath = path$4.join(dir, "package.json");
115
+ const packageJsonPath = path.join(dir, "package.json");
116
116
  const exists = await fsExists(packageJsonPath);
117
117
  if (!exists) return;
118
118
  debug("Reading package.json:", packageJsonPath);
@@ -141,7 +141,7 @@ function resolveOutputExtension(pkg, format) {
141
141
  //#region src/features/shims.ts
142
142
  function getShimsInject(format, platform) {
143
143
  if (format === "es" && platform === "node") {
144
- const shimFile = path$3.resolve(pkgRoot, "esm-shims.js");
144
+ const shimFile = path.resolve(pkgRoot, "esm-shims.js");
145
145
  return {
146
146
  __dirname: [shimFile, "__dirname"],
147
147
  __filename: [shimFile, "__filename"]
@@ -175,7 +175,7 @@ function shortcuts(restart) {
175
175
  key: "q",
176
176
  description: "quit",
177
177
  action() {
178
- process$3.exit(0);
178
+ process.exit(0);
179
179
  }
180
180
  }
181
181
  ];
@@ -186,7 +186,7 @@ function shortcuts(restart) {
186
186
  if (loggedKeys.has(shortcut$1.key)) continue;
187
187
  loggedKeys.add(shortcut$1.key);
188
188
  if (shortcut$1.action == null) continue;
189
- logger.info(pc$2.dim(" press ") + pc$2.bold(`${shortcut$1.key} + enter`) + pc$2.dim(` to ${shortcut$1.description}`));
189
+ logger.info(pc.dim(" press ") + pc.bold(`${shortcut$1.key} + enter`) + pc.dim(` to ${shortcut$1.description}`));
190
190
  }
191
191
  return;
192
192
  }
@@ -196,7 +196,7 @@ function shortcuts(restart) {
196
196
  await shortcut.action();
197
197
  actionRunning = false;
198
198
  }
199
- const rl = readline.createInterface({ input: process$3.stdin });
199
+ const rl = readline.createInterface({ input: process.stdin });
200
200
  rl.on("line", onInput);
201
201
  }
202
202
 
@@ -206,7 +206,7 @@ const endsWithPackageJson = /[\\/]package\.json$/;
206
206
  async function watchBuild(options, configFile, rebuild, restart) {
207
207
  const { watch } = await import("chokidar");
208
208
  const debouncedRebuild = debounce(rebuild, 100);
209
- const files = toArray(typeof options.watch === "boolean" ? process$2.cwd() : options.watch);
209
+ const files = toArray(typeof options.watch === "boolean" ? process.cwd() : options.watch);
210
210
  logger.info(`Watching for changes in ${files.join(", ")}`);
211
211
  if (configFile) files.push(configFile);
212
212
  const watcher = watch(files, {
@@ -236,7 +236,7 @@ async function resolveEntry(entry) {
236
236
  const objectEntry = await toObjectEntry(entry);
237
237
  const entries = Object.values(objectEntry);
238
238
  if (entries.length === 0) throw new Error(`Cannot find entry: ${JSON.stringify(entry)}`);
239
- logger.info(`entry: ${pc$1.blue(entries.join(", "))}`);
239
+ logger.info(`entry: ${pc.blue(entries.join(", "))}`);
240
240
  return objectEntry;
241
241
  }
242
242
  async function toObjectEntry(entry) {
@@ -245,8 +245,8 @@ async function toObjectEntry(entry) {
245
245
  const resolvedEntry = await glob(entry);
246
246
  const base = lowestCommonAncestor(...resolvedEntry);
247
247
  return Object.fromEntries(resolvedEntry.map((file) => {
248
- const relative = path$2.relative(base, file);
249
- return [relative.slice(0, relative.length - path$2.extname(relative).length), file];
248
+ const relative = path.relative(base, file);
249
+ return [relative.slice(0, relative.length - path.extname(relative).length), file];
250
250
  }));
251
251
  }
252
252
 
@@ -268,7 +268,7 @@ async function resolveOptions(options) {
268
268
  entry,
269
269
  plugins,
270
270
  format: normalizeFormat(format),
271
- outDir: path$1.resolve(outDir),
271
+ outDir: path.resolve(outDir),
272
272
  clean,
273
273
  silent,
274
274
  treeshake,
@@ -298,15 +298,15 @@ function normalizeFormat(format) {
298
298
  async function loadConfigFile(options) {
299
299
  let { config: filePath } = options;
300
300
  if (filePath === false) return [[]];
301
- let cwd = process$1.cwd();
301
+ let cwd = process.cwd();
302
302
  let overrideConfig = false;
303
303
  let stats;
304
304
  if (typeof filePath === "string" && (stats = await stat(filePath).catch(() => null))) {
305
- const resolved = path$1.resolve(filePath);
305
+ const resolved = path.resolve(filePath);
306
306
  if (stats.isFile()) {
307
307
  overrideConfig = true;
308
308
  filePath = resolved;
309
- cwd = path$1.dirname(filePath);
309
+ cwd = path.dirname(filePath);
310
310
  } else cwd = resolved;
311
311
  }
312
312
  const { config, sources } = await loadConfig({
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.2";
8
+ var version = "0.5.3";
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.2",
3
+ "version": "0.5.3",
4
4
  "description": "An even faster bundler powered by Rolldown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,35 +41,35 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "cac": "^6.7.14",
44
- "chokidar": "^4.0.1",
45
- "consola": "^3.2.3",
44
+ "chokidar": "^4.0.3",
45
+ "consola": "^3.3.3",
46
46
  "debug": "^4.4.0",
47
47
  "picocolors": "^1.1.1",
48
- "pkg-types": "^1.2.1",
49
- "rolldown": "nightly",
50
- "rollup": "^4.28.1",
48
+ "pkg-types": "^1.3.0",
49
+ "rolldown": "^1.0.0-beta.1",
50
+ "rollup": "^4.29.1",
51
51
  "rollup-plugin-dts": "^6.1.1",
52
52
  "tinyglobby": "^0.2.10",
53
53
  "unconfig": "^0.6.0",
54
- "unplugin-isolated-decl": "^0.10.0",
55
- "unplugin-unused": "^0.2.3"
54
+ "unplugin-isolated-decl": "^0.10.3",
55
+ "unplugin-unused": "^0.3.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@sxzz/eslint-config": "^4.5.1",
59
59
  "@sxzz/prettier-config": "^2.0.2",
60
60
  "@sxzz/test-utils": "^0.3.11",
61
61
  "@types/debug": "^4.1.12",
62
- "@types/node": "^22.10.1",
63
- "bumpp": "^9.9.0",
64
- "eslint": "^9.16.0",
65
- "oxc-transform": "^0.39.0",
62
+ "@types/node": "^22.10.2",
63
+ "bumpp": "^9.9.2",
64
+ "eslint": "^9.17.0",
65
+ "oxc-transform": "^0.44.0",
66
66
  "prettier": "^3.4.2",
67
- "tinyexec": "^0.3.1",
67
+ "tinyexec": "^0.3.2",
68
68
  "tsup": "^8.3.5",
69
69
  "tsx": "^4.19.2",
70
70
  "typescript": "~5.7.2",
71
71
  "unplugin-ast": "^0.13.1",
72
- "vitest": "^2.2.0-beta.2"
72
+ "vitest": "^3.0.0-beta.3"
73
73
  },
74
74
  "engines": {
75
75
  "node": ">=18.0.0"