tsdown 0.16.0 → 0.16.1
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 +2 -2
- package/dist/{migrate-C8f4tEcE.mjs → migrate-Dzz7E7av.mjs} +1 -1
- package/dist/{package-CTfVaX9t.mjs → package-BEpC3UYZ.mjs} +2 -4
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +3 -3
- package/dist/{src-B9FIpS_R.mjs → src-BJnxnJLO.mjs} +162 -141
- package/package.json +10 -14
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as defineConfig } from "./config-BPLXnzPK.mjs";
|
|
2
|
-
import { n as buildSingle, r as shimFile, t as build } from "./src-
|
|
3
|
-
import { a as globalLogger } from "./package-
|
|
2
|
+
import { n as buildSingle, r as shimFile, t as build } from "./src-BJnxnJLO.mjs";
|
|
3
|
+
import { a as globalLogger } from "./package-BEpC3UYZ.mjs";
|
|
4
4
|
|
|
5
5
|
export { build, buildSingle, defineConfig, globalLogger, shimFile };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as globalLogger, t as version } from "./package-
|
|
1
|
+
import { a as globalLogger, t as version } from "./package-BEpC3UYZ.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { bold, green, underline } from "ansis";
|
|
4
4
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
@@ -49,9 +49,7 @@ async function importWithError(moduleName) {
|
|
|
49
49
|
try {
|
|
50
50
|
return await import(moduleName);
|
|
51
51
|
} catch (error) {
|
|
52
|
-
|
|
53
|
-
final.cause = error;
|
|
54
|
-
throw final;
|
|
52
|
+
throw new Error(`Failed to import module "${moduleName}". Please ensure it is installed.`, { cause: error });
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
|
|
@@ -162,7 +160,7 @@ function hue2rgb(p, q, t) {
|
|
|
162
160
|
|
|
163
161
|
//#endregion
|
|
164
162
|
//#region package.json
|
|
165
|
-
var version = "0.16.
|
|
163
|
+
var version = "0.16.1";
|
|
166
164
|
|
|
167
165
|
//#endregion
|
|
168
166
|
export { globalLogger as a, debounce as c, noop as d, pkgExists as f, toArray as g, slash as h, generateColor as i, importWithError as l, resolveRegex as m, LogLevels as n, prettyFormat as o, resolveComma as p, createLogger as r, prettyName as s, version as t, matchPattern as u };
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./config-BPLXnzPK.mjs";
|
|
2
|
-
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, s as ExternalPlugin } from "./src-
|
|
3
|
-
import "./package-
|
|
2
|
+
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, s as ExternalPlugin } from "./src-BJnxnJLO.mjs";
|
|
3
|
+
import "./package-BEpC3UYZ.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cjs_createRequire } from "node:module";
|
|
3
3
|
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
import { a as globalLogger, g as toArray, p as resolveComma, t as version } from "./package-
|
|
4
|
+
import { a as globalLogger, g as toArray, p as resolveComma, t as version } from "./package-BEpC3UYZ.mjs";
|
|
5
5
|
import module from "node:module";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { dim } from "ansis";
|
|
@@ -30,7 +30,7 @@ cli.help().version(version);
|
|
|
30
30
|
cli.command("[...files]", "Bundle files", {
|
|
31
31
|
ignoreOptionDefaultValue: true,
|
|
32
32
|
allowUnknownOptions: true
|
|
33
|
-
}).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native,
|
|
33
|
+
}).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug", "Enable debug mode").option("--debug-logs [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).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("--attw", "Enable Are the types wrong integration", { 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) => {
|
|
34
34
|
globalLogger.level = flags.logLevel || (flags.silent ? "error" : "info");
|
|
35
35
|
globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
36
36
|
const { build: build$1 } = await import("./index.mjs");
|
|
@@ -38,7 +38,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
38
38
|
await build$1(flags);
|
|
39
39
|
});
|
|
40
40
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
41
|
-
const { migrate } = await import("./migrate-
|
|
41
|
+
const { migrate } = await import("./migrate-Dzz7E7av.mjs");
|
|
42
42
|
await migrate(args);
|
|
43
43
|
});
|
|
44
44
|
async function runCLI() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
2
|
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
3
|
-
import { a as globalLogger, c as debounce, d as noop, f as pkgExists, g as toArray, h as slash, i as generateColor, l as importWithError, m as resolveRegex, n as LogLevels, o as prettyFormat, p as resolveComma, r as createLogger, s as prettyName, t as version, u as matchPattern } from "./package-
|
|
3
|
+
import { a as globalLogger, c as debounce, d as noop, f as pkgExists, g as toArray, h as slash, i as generateColor, l as importWithError, m as resolveRegex, n as LogLevels, o as prettyFormat, p as resolveComma, r as createLogger, s as prettyName, t as version, u as matchPattern } from "./package-BEpC3UYZ.mjs";
|
|
4
4
|
import { builtinModules, isBuiltin } from "node:module";
|
|
5
5
|
import path, { dirname, join, normalize, sep } from "node:path";
|
|
6
6
|
import process from "node:process";
|
|
@@ -9,20 +9,19 @@ import { blue, bold, dim, green, underline } from "ansis";
|
|
|
9
9
|
import { VERSION, build } from "rolldown";
|
|
10
10
|
import { exec } from "tinyexec";
|
|
11
11
|
const treeKill = __cjs_require("tree-kill");
|
|
12
|
+
import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
12
13
|
const Debug = __cjs_require("debug");
|
|
14
|
+
import { createConfigCoreLoader } from "unconfig-core";
|
|
13
15
|
import { glob } from "tinyglobby";
|
|
14
|
-
import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
15
16
|
import { RE_CSS, RE_DTS, RE_JS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
|
|
16
17
|
const minVersion = __cjs_require("semver/ranges/min-version.js");
|
|
17
18
|
import { up } from "empathic/find";
|
|
18
19
|
import { up as up$1 } from "empathic/package";
|
|
19
|
-
import { loadConfig } from "unconfig";
|
|
20
|
-
import child_process from "node:child_process";
|
|
21
20
|
import { tmpdir } from "node:os";
|
|
22
|
-
import util, { promisify } from "node:util";
|
|
23
21
|
const coerce = __cjs_require("semver/functions/coerce.js");
|
|
24
22
|
const satisfies = __cjs_require("semver/functions/satisfies.js");
|
|
25
23
|
import { createHooks } from "hookable";
|
|
24
|
+
import util, { promisify } from "node:util";
|
|
26
25
|
import { importGlobPlugin } from "rolldown/experimental";
|
|
27
26
|
import { Buffer } from "node:buffer";
|
|
28
27
|
import { brotliCompress, gzip } from "node:zlib";
|
|
@@ -67,6 +66,136 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
67
66
|
return ancestor.length <= 1 && ancestor[0] === "" ? sep + ancestor[0] : ancestor.join(sep);
|
|
68
67
|
}
|
|
69
68
|
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/config/config.ts
|
|
71
|
+
const debug$8 = Debug("tsdown:config");
|
|
72
|
+
async function loadViteConfig(prefix, cwd, configLoader) {
|
|
73
|
+
const loader = resolveConfigLoader(configLoader);
|
|
74
|
+
debug$8("Loading Vite config via loader: ", loader);
|
|
75
|
+
const parser = createParser(loader);
|
|
76
|
+
const [result] = await createConfigCoreLoader({
|
|
77
|
+
sources: [{
|
|
78
|
+
files: [`${prefix}.config`],
|
|
79
|
+
extensions: [
|
|
80
|
+
"ts",
|
|
81
|
+
"mts",
|
|
82
|
+
"cts",
|
|
83
|
+
"js",
|
|
84
|
+
"mjs",
|
|
85
|
+
"cjs",
|
|
86
|
+
"json",
|
|
87
|
+
""
|
|
88
|
+
],
|
|
89
|
+
parser
|
|
90
|
+
}],
|
|
91
|
+
cwd
|
|
92
|
+
}).load();
|
|
93
|
+
if (!result) return;
|
|
94
|
+
const { config, source } = result;
|
|
95
|
+
globalLogger.info(`Using Vite config: ${underline(source)}`);
|
|
96
|
+
const resolved = await config;
|
|
97
|
+
if (typeof resolved === "function") return resolved({
|
|
98
|
+
command: "build",
|
|
99
|
+
mode: "production"
|
|
100
|
+
});
|
|
101
|
+
return resolved;
|
|
102
|
+
}
|
|
103
|
+
const configPrefix = "tsdown.config";
|
|
104
|
+
let isWatch = false;
|
|
105
|
+
function setWatch() {
|
|
106
|
+
isWatch = true;
|
|
107
|
+
}
|
|
108
|
+
async function loadConfigFile(inlineConfig, workspace) {
|
|
109
|
+
let cwd = inlineConfig.cwd || process.cwd();
|
|
110
|
+
let overrideConfig = false;
|
|
111
|
+
let { config: filePath } = inlineConfig;
|
|
112
|
+
if (filePath === false) return { configs: [{}] };
|
|
113
|
+
if (typeof filePath === "string") {
|
|
114
|
+
const stats = await fsStat(filePath);
|
|
115
|
+
if (stats) {
|
|
116
|
+
const resolved = path.resolve(filePath);
|
|
117
|
+
if (stats.isFile()) {
|
|
118
|
+
overrideConfig = true;
|
|
119
|
+
filePath = resolved;
|
|
120
|
+
cwd = path.dirname(filePath);
|
|
121
|
+
} else if (stats.isDirectory()) cwd = resolved;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const loader = resolveConfigLoader(inlineConfig.configLoader);
|
|
125
|
+
debug$8("Using config loader:", loader);
|
|
126
|
+
const parser = createParser(loader);
|
|
127
|
+
const [result] = await createConfigCoreLoader({
|
|
128
|
+
sources: overrideConfig ? [{
|
|
129
|
+
files: [filePath],
|
|
130
|
+
extensions: [],
|
|
131
|
+
parser
|
|
132
|
+
}] : [{
|
|
133
|
+
files: [configPrefix],
|
|
134
|
+
extensions: [
|
|
135
|
+
"ts",
|
|
136
|
+
"mts",
|
|
137
|
+
"cts",
|
|
138
|
+
"js",
|
|
139
|
+
"mjs",
|
|
140
|
+
"cjs",
|
|
141
|
+
"json",
|
|
142
|
+
""
|
|
143
|
+
],
|
|
144
|
+
parser
|
|
145
|
+
}, {
|
|
146
|
+
files: ["package.json"],
|
|
147
|
+
parser
|
|
148
|
+
}],
|
|
149
|
+
cwd,
|
|
150
|
+
stopAt: workspace && path.dirname(workspace)
|
|
151
|
+
}).load(isWatch);
|
|
152
|
+
let exported = [];
|
|
153
|
+
let file;
|
|
154
|
+
if (result) {
|
|
155
|
+
({config: exported, source: file} = result);
|
|
156
|
+
globalLogger.info(`Using tsdown config: ${underline(file)}`);
|
|
157
|
+
exported = await exported;
|
|
158
|
+
if (typeof exported === "function") exported = await exported(inlineConfig);
|
|
159
|
+
}
|
|
160
|
+
exported = toArray(exported);
|
|
161
|
+
if (exported.length === 0) exported.push({});
|
|
162
|
+
return {
|
|
163
|
+
configs: exported,
|
|
164
|
+
file
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function resolveConfigLoader(configLoader = "auto") {
|
|
168
|
+
if (isWatch) return "unrun";
|
|
169
|
+
else if (configLoader === "auto") return !!(process.features.typescript || process.versions.bun || process.versions.deno) ? "native" : "unrun";
|
|
170
|
+
else return configLoader === "native" ? "native" : "unrun";
|
|
171
|
+
}
|
|
172
|
+
function createParser(loader) {
|
|
173
|
+
return async (filepath) => {
|
|
174
|
+
const basename = path.basename(filepath);
|
|
175
|
+
const isPkgJson = basename === "package.json";
|
|
176
|
+
if (basename === configPrefix || isPkgJson || basename.endsWith(".json")) {
|
|
177
|
+
const contents = await readFile(filepath, "utf8");
|
|
178
|
+
const parsed = JSON.parse(contents);
|
|
179
|
+
if (isPkgJson) return parsed?.tsdown;
|
|
180
|
+
return parsed;
|
|
181
|
+
}
|
|
182
|
+
if (loader === "native") return nativeImport(filepath);
|
|
183
|
+
return unrunImport(filepath);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async function nativeImport(id) {
|
|
187
|
+
const mod = await import(pathToFileURL(id).href).catch((error) => {
|
|
188
|
+
if (error?.message?.includes?.("Cannot find module")) throw new Error(`Failed to load the config file. Try setting the --config-loader CLI flag to \`unrun\`.\n\n${error.message}`, { cause: error });
|
|
189
|
+
else throw error;
|
|
190
|
+
});
|
|
191
|
+
return mod.default || mod;
|
|
192
|
+
}
|
|
193
|
+
async function unrunImport(id) {
|
|
194
|
+
const { unrun } = await import("unrun");
|
|
195
|
+
const { module: module$1 } = await unrun({ path: pathToFileURL(id).href });
|
|
196
|
+
return module$1;
|
|
197
|
+
}
|
|
198
|
+
|
|
70
199
|
//#endregion
|
|
71
200
|
//#region src/features/clean.ts
|
|
72
201
|
const debug$7 = Debug("tsdown:clean");
|
|
@@ -330,116 +459,6 @@ function normalizeFormat(format) {
|
|
|
330
459
|
});
|
|
331
460
|
}
|
|
332
461
|
|
|
333
|
-
//#endregion
|
|
334
|
-
//#region src/config/config.ts
|
|
335
|
-
async function loadViteConfig(prefix, cwd) {
|
|
336
|
-
const { config, sources: [source] } = await loadConfig({
|
|
337
|
-
sources: [{
|
|
338
|
-
files: `${prefix}.config`,
|
|
339
|
-
extensions: [
|
|
340
|
-
"ts",
|
|
341
|
-
"mts",
|
|
342
|
-
"cts",
|
|
343
|
-
"js",
|
|
344
|
-
"mjs",
|
|
345
|
-
"cjs",
|
|
346
|
-
"json",
|
|
347
|
-
""
|
|
348
|
-
]
|
|
349
|
-
}],
|
|
350
|
-
cwd,
|
|
351
|
-
defaults: {}
|
|
352
|
-
});
|
|
353
|
-
if (!source) return;
|
|
354
|
-
globalLogger.info(`Using Vite config: ${underline(source)}`);
|
|
355
|
-
const resolved = await config;
|
|
356
|
-
if (typeof resolved === "function") return resolved({
|
|
357
|
-
command: "build",
|
|
358
|
-
mode: "production"
|
|
359
|
-
});
|
|
360
|
-
return resolved;
|
|
361
|
-
}
|
|
362
|
-
let loaded = false;
|
|
363
|
-
async function loadConfigFile(inlineConfig, workspace) {
|
|
364
|
-
let cwd = inlineConfig.cwd || process.cwd();
|
|
365
|
-
let overrideConfig = false;
|
|
366
|
-
let { config: filePath } = inlineConfig;
|
|
367
|
-
if (filePath === false) return { configs: [{}] };
|
|
368
|
-
if (typeof filePath === "string") {
|
|
369
|
-
const stats = await fsStat(filePath);
|
|
370
|
-
if (stats) {
|
|
371
|
-
const resolved = path.resolve(filePath);
|
|
372
|
-
if (stats.isFile()) {
|
|
373
|
-
overrideConfig = true;
|
|
374
|
-
filePath = resolved;
|
|
375
|
-
cwd = path.dirname(filePath);
|
|
376
|
-
} else if (stats.isDirectory()) cwd = resolved;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
let isNative = false;
|
|
380
|
-
if (!loaded) {
|
|
381
|
-
if (!inlineConfig.configLoader || inlineConfig.configLoader === "auto") isNative = !!(process.features.typescript || process.versions.bun || process.versions.deno);
|
|
382
|
-
else if (inlineConfig.configLoader === "native") isNative = true;
|
|
383
|
-
}
|
|
384
|
-
let { config, sources } = await loadConfig.async({
|
|
385
|
-
sources: overrideConfig ? [{
|
|
386
|
-
files: filePath,
|
|
387
|
-
extensions: []
|
|
388
|
-
}] : [{
|
|
389
|
-
files: "tsdown.config",
|
|
390
|
-
extensions: [
|
|
391
|
-
"ts",
|
|
392
|
-
"mts",
|
|
393
|
-
"cts",
|
|
394
|
-
"js",
|
|
395
|
-
"mjs",
|
|
396
|
-
"cjs",
|
|
397
|
-
"json",
|
|
398
|
-
""
|
|
399
|
-
],
|
|
400
|
-
parser: inlineConfig.configLoader === "unrun" ? unrunImport : isNative ? nativeImport : "auto"
|
|
401
|
-
}, {
|
|
402
|
-
files: "package.json",
|
|
403
|
-
extensions: [],
|
|
404
|
-
rewrite: (config$1) => config$1?.tsdown
|
|
405
|
-
}],
|
|
406
|
-
cwd,
|
|
407
|
-
stopAt: workspace && path.dirname(workspace),
|
|
408
|
-
defaults: {}
|
|
409
|
-
}).finally(() => loaded = true);
|
|
410
|
-
config = await config;
|
|
411
|
-
if (typeof config === "function") config = await config(inlineConfig);
|
|
412
|
-
config = toArray(config);
|
|
413
|
-
if (config.length === 0) config.push({});
|
|
414
|
-
const file = sources[0];
|
|
415
|
-
if (file) globalLogger.info(`Using tsdown config: ${underline(file)}`);
|
|
416
|
-
return {
|
|
417
|
-
configs: config,
|
|
418
|
-
file
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
async function nativeImport(id) {
|
|
422
|
-
const mod = await import(pathToFileURL(id).href).catch((error) => {
|
|
423
|
-
if (error?.message?.includes?.("Cannot find module")) {
|
|
424
|
-
const configError = /* @__PURE__ */ new Error(`Failed to load the config file. Try setting the --config-loader CLI flag to \`unconfig\`.\n\n${error.message}`);
|
|
425
|
-
configError.cause = error;
|
|
426
|
-
throw configError;
|
|
427
|
-
} else throw error;
|
|
428
|
-
});
|
|
429
|
-
return mod.default || mod;
|
|
430
|
-
}
|
|
431
|
-
async function unrunImport(id) {
|
|
432
|
-
const { unrun } = await importWithError("unrun");
|
|
433
|
-
const { module: module$1 } = await unrun({ path: pathToFileURL(id).href }).catch((error) => {
|
|
434
|
-
if (error?.message?.includes?.("Cannot find module")) {
|
|
435
|
-
const configError = /* @__PURE__ */ new Error(`Failed to load the config file. \`unrun\` is experimental; try setting the --config-loader CLI flag to \`unconfig\` instead.\n\n${error.message}`);
|
|
436
|
-
configError.cause = error;
|
|
437
|
-
throw configError;
|
|
438
|
-
} else throw error;
|
|
439
|
-
});
|
|
440
|
-
return module$1;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
462
|
//#endregion
|
|
444
463
|
//#region src/config/index.ts
|
|
445
464
|
const debug$5 = Debug("tsdown:options");
|
|
@@ -461,7 +480,7 @@ async function resolveConfig(inlineConfig) {
|
|
|
461
480
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
462
481
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, inlineConfig);
|
|
463
482
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
464
|
-
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveUserConfig(config)));
|
|
483
|
+
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveUserConfig(config, inlineConfig)));
|
|
465
484
|
}))).flat();
|
|
466
485
|
debug$5("resolved configs %O", configs);
|
|
467
486
|
return {
|
|
@@ -525,8 +544,8 @@ async function resolveWorkspace(config, inlineConfig) {
|
|
|
525
544
|
files
|
|
526
545
|
};
|
|
527
546
|
}
|
|
528
|
-
async function resolveUserConfig(userConfig) {
|
|
529
|
-
let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, fixedExtension = platform === "node", debug: debug$
|
|
547
|
+
async function resolveUserConfig(userConfig, inlineConfig) {
|
|
548
|
+
let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, fixedExtension = platform === "node", debug: debug$9 = false } = userConfig;
|
|
530
549
|
const logger = createLogger(logLevel, {
|
|
531
550
|
customLogger,
|
|
532
551
|
failOnWarn
|
|
@@ -550,7 +569,7 @@ async function resolveUserConfig(userConfig) {
|
|
|
550
569
|
if (publicDir) if (copy$1) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
|
|
551
570
|
else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
|
|
552
571
|
if (fromVite) {
|
|
553
|
-
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd);
|
|
572
|
+
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd, inlineConfig.configLoader);
|
|
554
573
|
if (viteUserConfig) {
|
|
555
574
|
const viteAlias = viteUserConfig.resolve?.alias;
|
|
556
575
|
if (Array.isArray(viteAlias)) throw new TypeError("Unsupported resolve.alias in Vite config. Use object instead of array");
|
|
@@ -571,9 +590,9 @@ async function resolveUserConfig(userConfig) {
|
|
|
571
590
|
noExternal = (id) => matchPattern(id, noExternalPatterns);
|
|
572
591
|
}
|
|
573
592
|
if (inlineOnly != null) inlineOnly = toArray(inlineOnly);
|
|
574
|
-
if (debug$
|
|
575
|
-
if (debug$
|
|
576
|
-
debug$
|
|
593
|
+
if (debug$9) {
|
|
594
|
+
if (debug$9 === true) debug$9 = {};
|
|
595
|
+
debug$9.devtools ??= !!pkgExists("@vitejs/devtools/cli");
|
|
577
596
|
}
|
|
578
597
|
return {
|
|
579
598
|
...userConfig,
|
|
@@ -613,7 +632,7 @@ async function resolveUserConfig(userConfig) {
|
|
|
613
632
|
globImport,
|
|
614
633
|
inlineOnly,
|
|
615
634
|
fixedExtension,
|
|
616
|
-
debug: debug$
|
|
635
|
+
debug: debug$9
|
|
617
636
|
};
|
|
618
637
|
}
|
|
619
638
|
async function mergeUserOptions(defaults, user, args) {
|
|
@@ -627,7 +646,6 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
627
646
|
//#endregion
|
|
628
647
|
//#region src/features/attw.ts
|
|
629
648
|
const debug$4 = Debug("tsdown:attw");
|
|
630
|
-
const exec$1 = promisify(child_process.exec);
|
|
631
649
|
/**
|
|
632
650
|
* ATTW profiles.
|
|
633
651
|
* Defines the resolution modes to ignore for each profile.
|
|
@@ -674,18 +692,14 @@ async function attw(options) {
|
|
|
674
692
|
const t = performance.now();
|
|
675
693
|
debug$4("Running attw check");
|
|
676
694
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
677
|
-
|
|
678
|
-
try {
|
|
679
|
-
attwCore = await importWithError("@arethetypeswrong/core");
|
|
680
|
-
} catch {
|
|
681
|
-
options.logger.error(`ATTW check requires ${blue`@arethetypeswrong/core`} to be installed.`);
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
695
|
+
const attwCore = await importWithError("@arethetypeswrong/core");
|
|
684
696
|
try {
|
|
685
|
-
const { stdout: tarballInfo } = await exec
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
697
|
+
const { stdout: tarballInfo } = await exec("npm", [
|
|
698
|
+
"pack",
|
|
699
|
+
"--json",
|
|
700
|
+
"--pack-destination",
|
|
701
|
+
tempDir
|
|
702
|
+
], { nodeOptions: { cwd: options.cwd } });
|
|
689
703
|
const parsed = JSON.parse(tarballInfo);
|
|
690
704
|
if (!Array.isArray(parsed) || !parsed[0]?.filename) throw new Error("Invalid npm pack output format");
|
|
691
705
|
const tarball = await readFile(path.join(tempDir, parsed[0].filename));
|
|
@@ -699,9 +713,9 @@ async function attw(options) {
|
|
|
699
713
|
if (problems.length) {
|
|
700
714
|
const problemMessage = `Are the types wrong problems found:\n${problems.map(formatProblem).join("\n")}`;
|
|
701
715
|
if (level === "error") throw new Error(problemMessage);
|
|
702
|
-
options.logger.warn(problemMessage);
|
|
716
|
+
options.logger.warn(prettyName(options.name), problemMessage);
|
|
703
717
|
}
|
|
704
|
-
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
718
|
+
} else options.logger.success(prettyName(options.name), `No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
705
719
|
} catch (error) {
|
|
706
720
|
options.logger.error("ATTW check failed:", error);
|
|
707
721
|
debug$4("Found errors, setting exit code to 1");
|
|
@@ -774,7 +788,10 @@ async function publint(options) {
|
|
|
774
788
|
pkgDir: path.dirname(options.pkg.packageJsonPath)
|
|
775
789
|
});
|
|
776
790
|
debug$3("Found %d issues", messages.length);
|
|
777
|
-
if (!messages.length)
|
|
791
|
+
if (!messages.length) {
|
|
792
|
+
options.logger.success(prettyName(options.name), `No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
778
795
|
let hasError = false;
|
|
779
796
|
for (const message of messages) {
|
|
780
797
|
hasError ||= message.type === "error";
|
|
@@ -1112,7 +1129,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
|
1112
1129
|
return rolldownConfig;
|
|
1113
1130
|
}
|
|
1114
1131
|
async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
1115
|
-
const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer, globImport, debug: debug$
|
|
1132
|
+
const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer, globImport, debug: debug$9 } = config;
|
|
1116
1133
|
const plugins = [];
|
|
1117
1134
|
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
1118
1135
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
@@ -1134,7 +1151,10 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
1134
1151
|
if (!cjsDts) {
|
|
1135
1152
|
if (unused) {
|
|
1136
1153
|
const { Unused } = await importWithError("unplugin-unused");
|
|
1137
|
-
plugins.push(Unused.rolldown(
|
|
1154
|
+
plugins.push(Unused.rolldown({
|
|
1155
|
+
root: cwd,
|
|
1156
|
+
...unused === true ? {} : unused
|
|
1157
|
+
}));
|
|
1138
1158
|
}
|
|
1139
1159
|
if (target) plugins.push(await LightningCSSPlugin({ target }));
|
|
1140
1160
|
plugins.push(ShebangPlugin(logger, cwd, name, isMultiFormat));
|
|
@@ -1172,7 +1192,7 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
1172
1192
|
if (log.code === "MIXED_EXPORT") return;
|
|
1173
1193
|
defaultHandler(level, log);
|
|
1174
1194
|
} : void 0,
|
|
1175
|
-
debug: debug$
|
|
1195
|
+
debug: debug$9 || void 0
|
|
1176
1196
|
}, config.inputOptions, [format, { cjsDts }]);
|
|
1177
1197
|
}
|
|
1178
1198
|
async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
@@ -1340,6 +1360,7 @@ async function build$1(userOptions = {}) {
|
|
|
1340
1360
|
for (const [i, config] of configs.entries()) {
|
|
1341
1361
|
const rebuild = rebuilds[i];
|
|
1342
1362
|
if (!rebuild) continue;
|
|
1363
|
+
setWatch();
|
|
1343
1364
|
const watcher = await watchBuild(config, configFiles, rebuild, restart);
|
|
1344
1365
|
disposeCbs.push(() => watcher.close());
|
|
1345
1366
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,8 +50,7 @@
|
|
|
50
50
|
"publint": "^0.3.0",
|
|
51
51
|
"typescript": "^5.0.0",
|
|
52
52
|
"unplugin-lightningcss": "^0.4.0",
|
|
53
|
-
"unplugin-unused": "^0.5.0"
|
|
54
|
-
"unrun": "^0.2.1"
|
|
53
|
+
"unplugin-unused": "^0.5.0"
|
|
55
54
|
},
|
|
56
55
|
"peerDependenciesMeta": {
|
|
57
56
|
"@arethetypeswrong/core": {
|
|
@@ -71,9 +70,6 @@
|
|
|
71
70
|
},
|
|
72
71
|
"unplugin-unused": {
|
|
73
72
|
"optional": true
|
|
74
|
-
},
|
|
75
|
-
"unrun": {
|
|
76
|
-
"optional": true
|
|
77
73
|
}
|
|
78
74
|
},
|
|
79
75
|
"dependencies": {
|
|
@@ -84,13 +80,14 @@
|
|
|
84
80
|
"diff": "^8.0.2",
|
|
85
81
|
"empathic": "^2.0.0",
|
|
86
82
|
"hookable": "^5.5.3",
|
|
87
|
-
"rolldown": "1.0.0-beta.
|
|
83
|
+
"rolldown": "1.0.0-beta.47",
|
|
88
84
|
"rolldown-plugin-dts": "^0.17.3",
|
|
89
85
|
"semver": "^7.7.3",
|
|
90
|
-
"tinyexec": "^1.0.
|
|
86
|
+
"tinyexec": "^1.0.2",
|
|
91
87
|
"tinyglobby": "^0.2.15",
|
|
92
88
|
"tree-kill": "^1.2.2",
|
|
93
|
-
"unconfig": "^7.
|
|
89
|
+
"unconfig-core": "^7.4.0",
|
|
90
|
+
"unrun": "^0.2.5"
|
|
94
91
|
},
|
|
95
92
|
"devDependencies": {
|
|
96
93
|
"@arethetypeswrong/core": "^0.18.2",
|
|
@@ -100,7 +97,7 @@
|
|
|
100
97
|
"@types/debug": "^4.1.12",
|
|
101
98
|
"@types/node": "^24.10.0",
|
|
102
99
|
"@types/semver": "^7.7.1",
|
|
103
|
-
"@unocss/eslint-plugin": "^66.5.
|
|
100
|
+
"@unocss/eslint-plugin": "^66.5.5",
|
|
104
101
|
"@vitejs/devtools": "^0.0.0-alpha.10",
|
|
105
102
|
"@vueuse/core": "^14.0.0",
|
|
106
103
|
"bumpp": "^10.3.1",
|
|
@@ -111,12 +108,11 @@
|
|
|
111
108
|
"publint": "^0.3.15",
|
|
112
109
|
"rolldown-plugin-require-cjs": "^0.3.1",
|
|
113
110
|
"typescript": "~5.9.3",
|
|
114
|
-
"unocss": "^66.5.
|
|
111
|
+
"unocss": "^66.5.5",
|
|
115
112
|
"unplugin-lightningcss": "^0.4.3",
|
|
116
|
-
"unplugin-unused": "^0.5.
|
|
117
|
-
"unrun": "^0.2.2",
|
|
113
|
+
"unplugin-unused": "^0.5.6",
|
|
118
114
|
"vite": "npm:rolldown-vite@latest",
|
|
119
|
-
"vitest": "^4.0.
|
|
115
|
+
"vitest": "^4.0.8"
|
|
120
116
|
},
|
|
121
117
|
"engines": {
|
|
122
118
|
"node": ">=20.19.0"
|