tsdown 0.9.6 → 0.9.8
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/{config-yiJy1jd0.js → config-CpIe1Ud_.js} +0 -3
- package/dist/config.d-DI49UQhk.d.ts +11 -0
- package/dist/config.d.ts +3 -3
- package/dist/config.js +1 -1
- package/dist/general-C06aMSSY.js +38 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +37 -20
- package/dist/{migrate-B7KTdsUd.js → migrate-fONPr2zj.js} +1 -1
- package/dist/{options.d-VgsCNgLk.d.ts → options.d-BXikSiux.d.ts} +19 -2
- package/dist/package-BBoT5Sps.js +5 -0
- package/dist/{plugins-DU1CCXkW.js → plugins-BcuTSrGE.js} +13 -36
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +2 -2
- package/dist/run.js +18 -4
- package/package.json +3 -3
- package/dist/config.d-DOpadTUl.d.ts +0 -10
- package/dist/logger-Dt3D6T-U.js +0 -16
- package/dist/package-B1O-I_4B.js +0 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./options.d-BXikSiux.js";
|
|
2
|
+
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Defines the configuration for tsdown.
|
|
6
|
+
*/
|
|
7
|
+
declare function defineConfig(options: UserConfig): UserConfig;
|
|
8
|
+
declare function defineConfig(options: UserConfigFn): UserConfigFn;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { defineConfig as defineConfig$1 };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./options.d-
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config.d-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./options.d-BXikSiux.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-DI49UQhk.js";
|
|
3
3
|
|
|
4
|
-
export { defineConfig };
|
|
4
|
+
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/config.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { consola } from "consola";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/logger.ts
|
|
5
|
+
/**
|
|
6
|
+
* Logger instance
|
|
7
|
+
*/
|
|
8
|
+
const logger = consola.withTag("tsdown");
|
|
9
|
+
function setSilent(silent) {
|
|
10
|
+
if (!("CONSOLA_LEVEL" in process.env)) logger.level = silent ? 0 : 3;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/utils/general.ts
|
|
15
|
+
function toArray(val, defaultValue) {
|
|
16
|
+
if (Array.isArray(val)) return val;
|
|
17
|
+
else if (val == null) {
|
|
18
|
+
if (defaultValue) return [defaultValue];
|
|
19
|
+
return [];
|
|
20
|
+
} else return [val];
|
|
21
|
+
}
|
|
22
|
+
function resolveComma(arr) {
|
|
23
|
+
return arr.flatMap((format) => format.split(","));
|
|
24
|
+
}
|
|
25
|
+
function debounce(fn, wait) {
|
|
26
|
+
let timeout;
|
|
27
|
+
return function(...args) {
|
|
28
|
+
if (timeout) clearTimeout(timeout);
|
|
29
|
+
timeout = setTimeout(() => {
|
|
30
|
+
timeout = void 0;
|
|
31
|
+
fn.apply(this, args);
|
|
32
|
+
}, wait);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const noop = (v) => v;
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { debounce, logger, noop, resolveComma, setSilent, toArray };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig } from "./options.d-
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config.d-
|
|
3
|
-
import Debug from "debug";
|
|
1
|
+
import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig } from "./options.d-BXikSiux.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-DI49UQhk.js";
|
|
4
3
|
import { ConsolaInstance } from "consola";
|
|
5
4
|
|
|
6
5
|
//#region src/utils/logger.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { defineConfig } from "./config-
|
|
2
|
-
import { ExternalPlugin, ReportPlugin, ShebangPlugin,
|
|
3
|
-
import {
|
|
1
|
+
import { defineConfig } from "./config-CpIe1Ud_.js";
|
|
2
|
+
import { ExternalPlugin, ReportPlugin, ShebangPlugin, fsExists, fsRemove, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson } from "./plugins-BcuTSrGE.js";
|
|
3
|
+
import { debounce, logger, resolveComma, setSilent, toArray } from "./general-C06aMSSY.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import { blue, bold, dim, green, underline } from "ansis";
|
|
8
|
+
import Debug from "debug";
|
|
8
9
|
import { build as build$1 } from "rolldown";
|
|
9
10
|
import { transformPlugin } from "rolldown/experimental";
|
|
10
11
|
import { exec } from "tinyexec";
|
|
11
12
|
import { readdir, stat } from "node:fs/promises";
|
|
12
|
-
import Debug from "debug";
|
|
13
13
|
import { glob } from "tinyglobby";
|
|
14
14
|
import { createHooks } from "hookable";
|
|
15
|
-
import { findUp } from "find-up-simple";
|
|
16
15
|
import readline from "node:readline";
|
|
17
16
|
import { loadConfig } from "unconfig";
|
|
17
|
+
import { up } from "empathic/find";
|
|
18
18
|
|
|
19
19
|
//#region src/features/clean.ts
|
|
20
20
|
const debug$2 = Debug("tsdown:clean");
|
|
@@ -175,11 +175,13 @@ function shortcuts(restart) {
|
|
|
175
175
|
//#region src/features/watch.ts
|
|
176
176
|
const endsWithPackageJson = /[\\/]package\.json$/;
|
|
177
177
|
async function watchBuild(options, configFile, rebuild, restart) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const files = toArray(typeof options.watch === "boolean" ?
|
|
178
|
+
const cwd = process.cwd();
|
|
179
|
+
if (typeof options.watch === "boolean" && options.outDir === cwd) throw new Error("Watch is enabled, but output directory is the same as the current working directory.Please specify a different watch directory using `watch` option,or set `outDir` to a different directory.");
|
|
180
|
+
const files = toArray(typeof options.watch === "boolean" ? cwd : options.watch);
|
|
181
181
|
logger.info(`Watching for changes in ${files.join(", ")}`);
|
|
182
182
|
if (configFile) files.push(configFile);
|
|
183
|
+
const { watch } = await import("chokidar");
|
|
184
|
+
const debouncedRebuild = debounce(rebuild, 100);
|
|
183
185
|
const watcher = watch(files, {
|
|
184
186
|
ignoreInitial: true,
|
|
185
187
|
ignorePermissionErrors: true,
|
|
@@ -224,8 +226,8 @@ async function toObjectEntry(entry, cwd) {
|
|
|
224
226
|
|
|
225
227
|
//#endregion
|
|
226
228
|
//#region src/utils/tsconfig.ts
|
|
227
|
-
|
|
228
|
-
return
|
|
229
|
+
function findTsconfig(cwd, name = "tsconfig.json") {
|
|
230
|
+
return up(name, { cwd }) || false;
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
//#endregion
|
|
@@ -238,14 +240,14 @@ async function resolveOptions(options) {
|
|
|
238
240
|
...subConfig,
|
|
239
241
|
...options
|
|
240
242
|
};
|
|
241
|
-
let { entry, format = ["es"], plugins = [], clean = false, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts = false, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias, tsconfig, report = true, target } = subOptions;
|
|
243
|
+
let { entry, format = ["es"], plugins = [], clean = false, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts = false, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias, tsconfig, report = true, target, env = {} } = subOptions;
|
|
242
244
|
entry = await resolveEntry(entry, cwd);
|
|
243
245
|
if (clean === true) clean = [];
|
|
244
246
|
if (publint$1 === true) publint$1 = {};
|
|
245
247
|
if (tsconfig !== false) {
|
|
246
248
|
if (tsconfig === true || tsconfig == null) {
|
|
247
249
|
const isSet = tsconfig;
|
|
248
|
-
tsconfig =
|
|
250
|
+
tsconfig = findTsconfig(cwd);
|
|
249
251
|
if (isSet && !tsconfig) logger.warn(`No tsconfig found in \`${cwd}\``);
|
|
250
252
|
} else {
|
|
251
253
|
const tsconfigPath = path.resolve(cwd, tsconfig);
|
|
@@ -254,7 +256,7 @@ async function resolveOptions(options) {
|
|
|
254
256
|
logger.warn(`tsconfig \`${tsconfig}\` doesn't exist`);
|
|
255
257
|
tsconfig = false;
|
|
256
258
|
} else {
|
|
257
|
-
tsconfig =
|
|
259
|
+
tsconfig = findTsconfig(cwd, tsconfig);
|
|
258
260
|
if (!tsconfig) logger.warn(`No \`${tsconfig}\` found in \`${cwd}\``);
|
|
259
261
|
}
|
|
260
262
|
}
|
|
@@ -290,7 +292,8 @@ async function resolveOptions(options) {
|
|
|
290
292
|
publint: publint$1,
|
|
291
293
|
alias,
|
|
292
294
|
tsconfig,
|
|
293
|
-
cwd
|
|
295
|
+
cwd,
|
|
296
|
+
env
|
|
294
297
|
};
|
|
295
298
|
return config;
|
|
296
299
|
}));
|
|
@@ -320,7 +323,7 @@ async function loadConfigFile(options) {
|
|
|
320
323
|
}
|
|
321
324
|
}
|
|
322
325
|
const nativeTS = process.features.typescript || process.versions.bun || process.versions.deno;
|
|
323
|
-
|
|
326
|
+
let { config, sources } = await loadConfig.async({
|
|
324
327
|
sources: overrideConfig ? [{
|
|
325
328
|
files: filePath,
|
|
326
329
|
extensions: []
|
|
@@ -349,8 +352,9 @@ async function loadConfigFile(options) {
|
|
|
349
352
|
cwd,
|
|
350
353
|
defaults: {}
|
|
351
354
|
}).finally(() => loaded = true);
|
|
352
|
-
if (sources.length > 0) logger.info(`Using tsdown config: ${underline(sources.join(", "))}`);
|
|
353
355
|
const file = sources[0];
|
|
356
|
+
if (file) logger.info(`Using tsdown config: ${underline(file)}`);
|
|
357
|
+
if (typeof config === "function") config = await config(options);
|
|
354
358
|
return {
|
|
355
359
|
configs: toArray(config),
|
|
356
360
|
file,
|
|
@@ -394,6 +398,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
394
398
|
|
|
395
399
|
//#endregion
|
|
396
400
|
//#region src/index.ts
|
|
401
|
+
const debug = Debug("tsdown:config");
|
|
397
402
|
/**
|
|
398
403
|
* Build with tsdown.
|
|
399
404
|
*/
|
|
@@ -401,8 +406,12 @@ async function build(userOptions = {}) {
|
|
|
401
406
|
if (typeof userOptions.silent === "boolean") setSilent(userOptions.silent);
|
|
402
407
|
debug("Loading config");
|
|
403
408
|
const { configs, file: configFile } = await resolveOptions(userOptions);
|
|
404
|
-
if (configFile)
|
|
405
|
-
|
|
409
|
+
if (configFile) {
|
|
410
|
+
debug("Loaded config:", configFile);
|
|
411
|
+
configs.forEach((config) => {
|
|
412
|
+
debug("using resolved config: %O", config);
|
|
413
|
+
});
|
|
414
|
+
} else debug("No config file found");
|
|
406
415
|
const rebuilds = await Promise.all(configs.map(buildSingle));
|
|
407
416
|
const cleanCbs = [];
|
|
408
417
|
for (const [i, config] of configs.entries()) {
|
|
@@ -475,7 +484,7 @@ async function buildSingle(config) {
|
|
|
475
484
|
}
|
|
476
485
|
}
|
|
477
486
|
async function getBuildOptions(config, pkg, format, cjsDts) {
|
|
478
|
-
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report } = config;
|
|
487
|
+
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env } = config;
|
|
479
488
|
const plugins = [];
|
|
480
489
|
if (pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config, pkg));
|
|
481
490
|
if (dts) {
|
|
@@ -514,7 +523,15 @@ async function getBuildOptions(config, pkg, format, cjsDts) {
|
|
|
514
523
|
},
|
|
515
524
|
treeshake,
|
|
516
525
|
platform,
|
|
517
|
-
define
|
|
526
|
+
define: {
|
|
527
|
+
...define,
|
|
528
|
+
...Object.keys(env).reduce((acc, key) => {
|
|
529
|
+
const value = JSON.stringify(env[key]);
|
|
530
|
+
acc[`process.env.${key}`] = value;
|
|
531
|
+
acc[`import.meta.env.${key}`] = value;
|
|
532
|
+
return acc;
|
|
533
|
+
}, Object.create(null))
|
|
534
|
+
},
|
|
518
535
|
plugins,
|
|
519
536
|
inject: { ...shims && !cjsDts && getShimsInject(format, platform) }
|
|
520
537
|
}, config.inputOptions, [format]);
|
|
@@ -90,6 +90,11 @@ type Arrayable<T> = T | T[];
|
|
|
90
90
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
91
91
|
type Format = Exclude<ModuleFormat, "experimental-app">;
|
|
92
92
|
type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
|
|
93
|
+
interface MinifyOptions {
|
|
94
|
+
mangle?: boolean;
|
|
95
|
+
compress?: boolean;
|
|
96
|
+
removeWhitespace?: boolean;
|
|
97
|
+
}
|
|
93
98
|
/**
|
|
94
99
|
* Options for tsdown.
|
|
95
100
|
*/
|
|
@@ -110,7 +115,7 @@ interface Options$3 {
|
|
|
110
115
|
sourcemap?: Sourcemap;
|
|
111
116
|
clean?: boolean | string[];
|
|
112
117
|
/** @default false */
|
|
113
|
-
minify?: boolean;
|
|
118
|
+
minify?: boolean | "dce-only" | MinifyOptions;
|
|
114
119
|
target?: string | string[];
|
|
115
120
|
define?: Record<string, string>;
|
|
116
121
|
/** @default false */
|
|
@@ -169,12 +174,24 @@ interface Options$3 {
|
|
|
169
174
|
* @default true
|
|
170
175
|
*/
|
|
171
176
|
report?: boolean | ReportOptions;
|
|
177
|
+
/**
|
|
178
|
+
* Compile-time env variables.
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* {
|
|
182
|
+
* "DEBUG": true,
|
|
183
|
+
* "NODE_ENV": "production"
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
env?: Record<string, any>;
|
|
172
188
|
hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
|
|
173
189
|
}
|
|
174
190
|
/**
|
|
175
191
|
* Options without specifying config file path.
|
|
176
192
|
*/
|
|
177
193
|
type UserConfig = Arrayable<Omit<Options$3, "config">>;
|
|
194
|
+
type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
178
195
|
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks">, {
|
|
179
196
|
format: NormalizedFormat[]
|
|
180
197
|
target?: string[]
|
|
@@ -186,4 +203,4 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inp
|
|
|
186
203
|
}>, "config" | "fromVite">;
|
|
187
204
|
|
|
188
205
|
//#endregion
|
|
189
|
-
export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig };
|
|
206
|
+
export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger, noop, resolveComma, toArray } from "./general-C06aMSSY.js";
|
|
2
2
|
import path, { dirname, normalize, sep } from "node:path";
|
|
3
3
|
import { blue, bold, dim, green, underline, yellow } from "ansis";
|
|
4
|
-
import { access, chmod, readFile, rm } from "node:fs/promises";
|
|
5
4
|
import Debug from "debug";
|
|
6
|
-
import {
|
|
5
|
+
import { access, chmod, readFile, rm } from "node:fs/promises";
|
|
6
|
+
import { up } from "empathic/package";
|
|
7
7
|
import { Buffer } from "node:buffer";
|
|
8
8
|
import { promisify } from "node:util";
|
|
9
9
|
import { brotliCompress, gzip } from "node:zlib";
|
|
@@ -37,30 +37,6 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
37
37
|
return ancestor.length <= 1 && ancestor[0] === "" ? sep + ancestor[0] : ancestor.join(sep);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/utils/general.ts
|
|
42
|
-
function toArray(val, defaultValue) {
|
|
43
|
-
if (Array.isArray(val)) return val;
|
|
44
|
-
else if (val == null) {
|
|
45
|
-
if (defaultValue) return [defaultValue];
|
|
46
|
-
return [];
|
|
47
|
-
} else return [val];
|
|
48
|
-
}
|
|
49
|
-
function resolveComma(arr) {
|
|
50
|
-
return arr.flatMap((format) => format.split(","));
|
|
51
|
-
}
|
|
52
|
-
function debounce(fn, wait) {
|
|
53
|
-
let timeout;
|
|
54
|
-
return function(...args) {
|
|
55
|
-
if (timeout) clearTimeout(timeout);
|
|
56
|
-
timeout = setTimeout(() => {
|
|
57
|
-
timeout = void 0;
|
|
58
|
-
fn.apply(this, args);
|
|
59
|
-
}, wait);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const noop = (v) => v;
|
|
63
|
-
|
|
64
40
|
//#endregion
|
|
65
41
|
//#region src/features/external.ts
|
|
66
42
|
const debug$2 = Debug("tsdown:external");
|
|
@@ -103,10 +79,11 @@ function getProductionDeps(pkg) {
|
|
|
103
79
|
|
|
104
80
|
//#endregion
|
|
105
81
|
//#region src/utils/package.ts
|
|
82
|
+
const debug$1 = Debug("tsdown:package");
|
|
106
83
|
async function readPackageJson(dir) {
|
|
107
|
-
const packageJsonPath =
|
|
84
|
+
const packageJsonPath = up({ cwd: dir });
|
|
108
85
|
if (!packageJsonPath) return;
|
|
109
|
-
debug("Reading package.json:", packageJsonPath);
|
|
86
|
+
debug$1("Reading package.json:", packageJsonPath);
|
|
110
87
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
111
88
|
return JSON.parse(contents);
|
|
112
89
|
}
|
|
@@ -155,7 +132,7 @@ function formatBytes(bytes) {
|
|
|
155
132
|
|
|
156
133
|
//#endregion
|
|
157
134
|
//#region src/features/report.ts
|
|
158
|
-
const debug
|
|
135
|
+
const debug = Debug("tsdown:report");
|
|
159
136
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
160
137
|
const gzipAsync = promisify(gzip);
|
|
161
138
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -196,19 +173,19 @@ function ReportPlugin(options, cwd, cjsDts) {
|
|
|
196
173
|
};
|
|
197
174
|
}
|
|
198
175
|
async function calcSize(options, chunk) {
|
|
199
|
-
debug
|
|
176
|
+
debug(`Calculating size for`, chunk.fileName);
|
|
200
177
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
201
178
|
const raw = Buffer.byteLength(content, "utf8");
|
|
202
|
-
debug
|
|
179
|
+
debug("[size]", chunk.fileName, raw);
|
|
203
180
|
let gzip$1 = Infinity;
|
|
204
181
|
let brotli = Infinity;
|
|
205
|
-
if (raw > (options.maxCompressSize ?? 1e6)) debug
|
|
182
|
+
if (raw > (options.maxCompressSize ?? 1e6)) debug(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
206
183
|
else {
|
|
207
184
|
gzip$1 = (await gzipAsync(content)).length;
|
|
208
|
-
debug
|
|
185
|
+
debug("[gzip]", chunk.fileName, gzip$1);
|
|
209
186
|
if (options.brotli) {
|
|
210
187
|
brotli = (await brotliCompressAsync(content)).length;
|
|
211
|
-
debug
|
|
188
|
+
debug("[brotli]", chunk.fileName, brotli);
|
|
212
189
|
}
|
|
213
190
|
}
|
|
214
191
|
return {
|
|
@@ -245,4 +222,4 @@ function ShebangPlugin(cwd) {
|
|
|
245
222
|
}
|
|
246
223
|
|
|
247
224
|
//#endregion
|
|
248
|
-
export { ExternalPlugin, ReportPlugin, ShebangPlugin,
|
|
225
|
+
export { ExternalPlugin, ReportPlugin, ShebangPlugin, fsExists, fsRemove, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson };
|
package/dist/plugins.d.ts
CHANGED
package/dist/plugins.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExternalPlugin, ReportPlugin, ShebangPlugin } from "./plugins-
|
|
2
|
-
import "./
|
|
1
|
+
import { ExternalPlugin, ReportPlugin, ShebangPlugin } from "./plugins-BcuTSrGE.js";
|
|
2
|
+
import "./general-C06aMSSY.js";
|
|
3
3
|
|
|
4
4
|
export { ExternalPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { logger, setSilent } from "./
|
|
3
|
-
import { version } from "./package-
|
|
2
|
+
import { logger, resolveComma, setSilent, toArray } from "./general-C06aMSSY.js";
|
|
3
|
+
import { version } from "./package-BBoT5Sps.js";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { dim } from "ansis";
|
|
6
|
+
import Debug from "debug";
|
|
6
7
|
import { VERSION } from "rolldown";
|
|
8
|
+
import module from "node:module";
|
|
7
9
|
import { cac } from "cac";
|
|
8
10
|
|
|
9
11
|
//#region src/cli.ts
|
|
10
12
|
const cli = cac("tsdown");
|
|
11
13
|
cli.help().version(version);
|
|
12
|
-
cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").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", { default: false }).option("--publint", "Enable publint", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).action(async (input, flags) => {
|
|
14
|
+
cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [scope]", "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", { default: false }).option("--publint", "Enable publint", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "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").action(async (input, flags) => {
|
|
13
15
|
setSilent(!!flags.silent);
|
|
14
16
|
logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
15
17
|
const { build: build$1 } = await import("./index.js");
|
|
@@ -17,11 +19,20 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
|
|
|
17
19
|
await build$1(flags);
|
|
18
20
|
});
|
|
19
21
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
20
|
-
const { migrate } = await import("./migrate-
|
|
22
|
+
const { migrate } = await import("./migrate-fONPr2zj.js");
|
|
21
23
|
await migrate(args);
|
|
22
24
|
});
|
|
23
25
|
async function runCLI() {
|
|
24
26
|
cli.parse(process.argv, { run: false });
|
|
27
|
+
if (cli.options.debug) {
|
|
28
|
+
let namespace;
|
|
29
|
+
if (cli.options.debug === true) namespace = "tsdown:*";
|
|
30
|
+
else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
|
|
31
|
+
const enabled = Debug.disable();
|
|
32
|
+
if (enabled) namespace += `,${enabled}`;
|
|
33
|
+
Debug.enable(namespace);
|
|
34
|
+
Debug("tsdown:debug")("Debugging enabled", namespace);
|
|
35
|
+
}
|
|
25
36
|
try {
|
|
26
37
|
await cli.runMatchedCommand();
|
|
27
38
|
} catch (error) {
|
|
@@ -32,6 +43,9 @@ async function runCLI() {
|
|
|
32
43
|
|
|
33
44
|
//#endregion
|
|
34
45
|
//#region src/run.ts
|
|
46
|
+
try {
|
|
47
|
+
module.enableCompileCache?.();
|
|
48
|
+
} catch {}
|
|
35
49
|
runCLI();
|
|
36
50
|
|
|
37
51
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"consola": "^3.4.2",
|
|
61
61
|
"debug": "^4.4.0",
|
|
62
62
|
"diff": "^7.0.0",
|
|
63
|
-
"
|
|
63
|
+
"empathic": "^1.0.0",
|
|
64
64
|
"hookable": "^5.5.3",
|
|
65
|
-
"rolldown": "1.0.0-beta.8-commit.
|
|
65
|
+
"rolldown": "1.0.0-beta.8-commit.151352b",
|
|
66
66
|
"rolldown-plugin-dts": "^0.8.3",
|
|
67
67
|
"tinyexec": "^1.0.1",
|
|
68
68
|
"tinyglobby": "^0.2.13",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { UserConfig } from "./options.d-VgsCNgLk.js";
|
|
2
|
-
|
|
3
|
-
//#region src/config.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Defines the configuration for tsdown.
|
|
6
|
-
*/
|
|
7
|
-
declare function defineConfig(options: UserConfig): UserConfig;
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { defineConfig as defineConfig$1 };
|
package/dist/logger-Dt3D6T-U.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import Debug from "debug";
|
|
3
|
-
import { consola } from "consola";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/logger.ts
|
|
6
|
-
/**
|
|
7
|
-
* Logger instance
|
|
8
|
-
*/
|
|
9
|
-
const logger = consola.withTag("tsdown");
|
|
10
|
-
const debug = Debug("tsdown");
|
|
11
|
-
function setSilent(silent) {
|
|
12
|
-
if (!("CONSOLA_LEVEL" in process.env)) logger.level = silent ? 0 : 3;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { debug, logger, setSilent };
|