tsdown 0.15.9 → 0.15.11
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-CNqtanO8.d.mts → config-CqBC_jjD.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{migrate-Bh_d_JVL.mjs → migrate-De95qtTc.mjs} +1 -1
- package/dist/{package--bDJO_eC.mjs → package-BzY0XlO4.mjs} +1 -1
- package/dist/plugins.d.mts +1 -1
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +6 -6
- package/dist/{src-BE9Pi-HH.mjs → src-D6aJlyPX.mjs} +66 -51
- package/dist/{types-B42d6pGf.d.mts → types-BquFAfMw.d.mts} +1 -1
- package/package.json +11 -11
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { d as UserConfig, f as UserConfigFn } from "./types-
|
|
2
|
-
import { t as defineConfig } from "./config-
|
|
1
|
+
import { d as UserConfig, f as UserConfigFn } from "./types-BquFAfMw.mjs";
|
|
2
|
+
import { t as defineConfig } from "./config-CqBC_jjD.mjs";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as CopyEntry, C as OutExtensionObject, D as TsdownHooks, E as RolldownContext, M as CopyOptionsFn, N as AttwOptions, O as ExportsOptions, S as OutExtensionFactory, T as BuildContext, _ as globalLogger, a as NormalizedUserConfig, b as ChunkAddonObject, c as ResolvedOptions, d as UserConfig, f as UserConfigFn, g as Logger, i as NormalizedFormat, j as CopyOptions, k as TsdownChunks, l as Sourcemap, m as ReportOptions, n as Format, o as Options, p as Workspace, r as NoExternalFn, s as PublintOptions, t as DtsOptions, u as UnusedOptions, v as ChunkAddon, w as PackageType, x as OutExtensionContext, y as ChunkAddonFunction } from "./types-
|
|
2
|
-
import { t as defineConfig } from "./config-
|
|
1
|
+
import { A as CopyEntry, C as OutExtensionObject, D as TsdownHooks, E as RolldownContext, M as CopyOptionsFn, N as AttwOptions, O as ExportsOptions, S as OutExtensionFactory, T as BuildContext, _ as globalLogger, a as NormalizedUserConfig, b as ChunkAddonObject, c as ResolvedOptions, d as UserConfig, f as UserConfigFn, g as Logger, i as NormalizedFormat, j as CopyOptions, k as TsdownChunks, l as Sourcemap, m as ReportOptions, n as Format, o as Options, p as Workspace, r as NoExternalFn, s as PublintOptions, t as DtsOptions, u as UnusedOptions, v as ChunkAddon, w as PackageType, x as OutExtensionContext, y as ChunkAddonFunction } from "./types-BquFAfMw.mjs";
|
|
2
|
+
import { t as defineConfig } from "./config-CqBC_jjD.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
|
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-D6aJlyPX.mjs";
|
|
3
|
+
import { a as globalLogger } from "./package-BzY0XlO4.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-BzY0XlO4.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";
|
|
@@ -146,7 +146,7 @@ function hue2rgb(p, q, t) {
|
|
|
146
146
|
|
|
147
147
|
//#endregion
|
|
148
148
|
//#region package.json
|
|
149
|
-
var version = "0.15.
|
|
149
|
+
var version = "0.15.11";
|
|
150
150
|
|
|
151
151
|
//#endregion
|
|
152
152
|
export { globalLogger as a, debounce as c, resolveComma as d, resolveRegex as f, generateColor as i, matchPattern as l, toArray as m, LogLevels as n, prettyFormat as o, slash as p, createLogger as r, prettyName as s, version as t, noop as u };
|
package/dist/plugins.d.mts
CHANGED
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-D6aJlyPX.mjs";
|
|
3
|
+
import "./package-BzY0XlO4.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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, d as resolveComma, m as toArray, t as version } from "./package
|
|
4
|
+
import { a as globalLogger, d as resolveComma, m as toArray, t as version } from "./package-BzY0XlO4.mjs";
|
|
5
5
|
import module from "node:module";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { dim } from "ansis";
|
|
8
8
|
import { VERSION } from "rolldown";
|
|
9
|
-
const
|
|
9
|
+
const debug = __cjs_require("debug");
|
|
10
10
|
import { cac } from "cac";
|
|
11
11
|
|
|
12
12
|
//#region src/cli.ts
|
|
@@ -23,7 +23,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
23
23
|
await build$1(flags);
|
|
24
24
|
});
|
|
25
25
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
26
|
-
const { migrate } = await import("./migrate-
|
|
26
|
+
const { migrate } = await import("./migrate-De95qtTc.mjs");
|
|
27
27
|
await migrate(args);
|
|
28
28
|
});
|
|
29
29
|
async function runCLI() {
|
|
@@ -32,10 +32,10 @@ async function runCLI() {
|
|
|
32
32
|
let namespace;
|
|
33
33
|
if (cli.options.debug === true) namespace = "tsdown:*";
|
|
34
34
|
else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
|
|
35
|
-
const enabled =
|
|
35
|
+
const enabled = debug.disable();
|
|
36
36
|
if (enabled) namespace += `,${enabled}`;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
debug.enable(namespace);
|
|
38
|
+
debug("tsdown:debug")("Debugging enabled", namespace);
|
|
39
39
|
}
|
|
40
40
|
try {
|
|
41
41
|
await cli.runMatchedCommand();
|
|
@@ -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 resolveComma, f as resolveRegex, i as generateColor, l as matchPattern, m as toArray, n as LogLevels, o as prettyFormat, p as slash, r as createLogger, s as prettyName, t as version, u as noop } from "./package
|
|
3
|
+
import { a as globalLogger, c as debounce, d as resolveComma, f as resolveRegex, i as generateColor, l as matchPattern, m as toArray, n as LogLevels, o as prettyFormat, p as slash, r as createLogger, s as prettyName, t as version, u as noop } from "./package-BzY0XlO4.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";
|
|
@@ -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 util, { promisify } from "node:util";
|
|
16
|
-
const
|
|
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";
|
|
@@ -24,6 +24,7 @@ const minVersion = __cjs_require("semver/ranges/min-version.js");
|
|
|
24
24
|
import { up } from "empathic/find";
|
|
25
25
|
import { up as up$1 } from "empathic/package";
|
|
26
26
|
import { loadConfig } from "unconfig";
|
|
27
|
+
import { unrun } from "unrun";
|
|
27
28
|
import { Buffer } from "node:buffer";
|
|
28
29
|
import { brotliCompress, gzip } from "node:zlib";
|
|
29
30
|
import readline from "node:readline";
|
|
@@ -69,7 +70,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
69
70
|
|
|
70
71
|
//#endregion
|
|
71
72
|
//#region src/features/attw.ts
|
|
72
|
-
const debug$
|
|
73
|
+
const debug$8 = debug("tsdown:attw");
|
|
73
74
|
const exec$1 = promisify(child_process.exec);
|
|
74
75
|
/**
|
|
75
76
|
* ATTW profiles.
|
|
@@ -115,7 +116,7 @@ async function attw(options) {
|
|
|
115
116
|
}
|
|
116
117
|
const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
|
|
117
118
|
const t = performance.now();
|
|
118
|
-
debug$
|
|
119
|
+
debug$8("Running attw check");
|
|
119
120
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
120
121
|
let attwCore;
|
|
121
122
|
try {
|
|
@@ -147,7 +148,7 @@ async function attw(options) {
|
|
|
147
148
|
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
148
149
|
} catch (error) {
|
|
149
150
|
options.logger.error("ATTW check failed:", error);
|
|
150
|
-
debug$
|
|
151
|
+
debug$8("Found errors, setting exit code to 1");
|
|
151
152
|
process.exitCode = 1;
|
|
152
153
|
} finally {
|
|
153
154
|
await fsRemove(tempDir);
|
|
@@ -171,7 +172,7 @@ function warnLegacyCJS(config) {
|
|
|
171
172
|
|
|
172
173
|
//#endregion
|
|
173
174
|
//#region src/features/clean.ts
|
|
174
|
-
const debug$
|
|
175
|
+
const debug$7 = debug("tsdown:clean");
|
|
175
176
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
176
177
|
async function cleanOutDir(configs) {
|
|
177
178
|
const removes = /* @__PURE__ */ new Set();
|
|
@@ -188,10 +189,10 @@ async function cleanOutDir(configs) {
|
|
|
188
189
|
if (!removes.size) return;
|
|
189
190
|
globalLogger.info(`Cleaning ${removes.size} files`);
|
|
190
191
|
await Promise.all([...removes].map(async (file) => {
|
|
191
|
-
debug$
|
|
192
|
+
debug$7("Removing", file);
|
|
192
193
|
await fsRemove(file);
|
|
193
194
|
}));
|
|
194
|
-
debug$
|
|
195
|
+
debug$7("Removed %d files", removes.size);
|
|
195
196
|
}
|
|
196
197
|
function resolveClean(clean, outDir, cwd) {
|
|
197
198
|
if (clean === true) clean = [slash(outDir)];
|
|
@@ -247,19 +248,21 @@ async function generateExports(pkg, outDir, chunks, { devExports, all, customExp
|
|
|
247
248
|
const onlyOneEntry = chunksByFormat.filter((chunk) => chunk.type === "chunk" && chunk.isEntry && !RE_DTS.test(chunk.fileName)).length === 1;
|
|
248
249
|
for (const chunk of chunksByFormat) {
|
|
249
250
|
if (chunk.type !== "chunk" || !chunk.isEntry) continue;
|
|
251
|
+
const normalizedName = slash(chunk.fileName);
|
|
250
252
|
const ext = path.extname(chunk.fileName);
|
|
251
|
-
let name =
|
|
253
|
+
let name = normalizedName.slice(0, -ext.length);
|
|
252
254
|
const isDts = name.endsWith(".d");
|
|
253
255
|
if (isDts) name = name.slice(0, -2);
|
|
254
256
|
const isIndex = onlyOneEntry || name === "index";
|
|
255
|
-
const distFile = `${outDirRelative ? `./${outDirRelative}` : "."}/${
|
|
257
|
+
const distFile = `${outDirRelative ? `./${outDirRelative}` : "."}/${normalizedName}`;
|
|
256
258
|
if (isIndex) {
|
|
257
259
|
name = ".";
|
|
258
260
|
if (format === "cjs") if (isDts) cjsTypes = distFile;
|
|
259
261
|
else main = distFile;
|
|
260
262
|
else if (format === "es") if (isDts) esmTypes = distFile;
|
|
261
263
|
else module$1 = distFile;
|
|
262
|
-
} else
|
|
264
|
+
} else if (name.endsWith("/index")) name = `./${name.slice(0, -6)}`;
|
|
265
|
+
else name = `./${name}`;
|
|
263
266
|
let subExport = exportsMap.get(name);
|
|
264
267
|
if (!subExport) {
|
|
265
268
|
subExport = {};
|
|
@@ -349,7 +352,7 @@ async function createHooks$1(options) {
|
|
|
349
352
|
|
|
350
353
|
//#endregion
|
|
351
354
|
//#region src/features/publint.ts
|
|
352
|
-
const debug$
|
|
355
|
+
const debug$6 = debug("tsdown:publint");
|
|
353
356
|
async function publint(options) {
|
|
354
357
|
if (!options.publint) return;
|
|
355
358
|
if (!options.pkg) {
|
|
@@ -357,14 +360,14 @@ async function publint(options) {
|
|
|
357
360
|
return;
|
|
358
361
|
}
|
|
359
362
|
const t = performance.now();
|
|
360
|
-
debug$
|
|
363
|
+
debug$6("Running publint");
|
|
361
364
|
const { publint: publint$1 } = await import("publint");
|
|
362
365
|
const { formatMessage } = await import("publint/utils");
|
|
363
366
|
const { messages } = await publint$1({
|
|
364
367
|
...options.publint === true ? {} : options.publint,
|
|
365
368
|
pkgDir: path.dirname(options.pkg.packageJsonPath)
|
|
366
369
|
});
|
|
367
|
-
debug$
|
|
370
|
+
debug$6("Found %d issues", messages.length);
|
|
368
371
|
if (!messages.length) options.logger.success(prettyName(options.name), `No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
369
372
|
let hasError = false;
|
|
370
373
|
for (const message of messages) {
|
|
@@ -378,7 +381,7 @@ async function publint(options) {
|
|
|
378
381
|
options.logger[logType](prettyName(options.name), formattedMessage);
|
|
379
382
|
}
|
|
380
383
|
if (hasError) {
|
|
381
|
-
debug$
|
|
384
|
+
debug$6("Found errors, setting exit code to 1");
|
|
382
385
|
process.exitCode = 1;
|
|
383
386
|
}
|
|
384
387
|
}
|
|
@@ -465,11 +468,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
|
|
|
465
468
|
|
|
466
469
|
//#endregion
|
|
467
470
|
//#region src/utils/package.ts
|
|
468
|
-
const debug$
|
|
471
|
+
const debug$5 = debug("tsdown:package");
|
|
469
472
|
async function readPackageJson(dir) {
|
|
470
473
|
const packageJsonPath = up$1({ cwd: dir });
|
|
471
474
|
if (!packageJsonPath) return;
|
|
472
|
-
debug$
|
|
475
|
+
debug$5("Reading package.json:", packageJsonPath);
|
|
473
476
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
474
477
|
return {
|
|
475
478
|
...JSON.parse(contents),
|
|
@@ -562,7 +565,7 @@ async function loadConfigFile(options, workspace) {
|
|
|
562
565
|
"json",
|
|
563
566
|
""
|
|
564
567
|
],
|
|
565
|
-
parser: isNative ? nativeImport : "auto"
|
|
568
|
+
parser: options.configLoader === "unrun" ? unrunImport : isNative ? nativeImport : "auto"
|
|
566
569
|
}, {
|
|
567
570
|
files: "package.json",
|
|
568
571
|
extensions: [],
|
|
@@ -592,10 +595,20 @@ async function nativeImport(id) {
|
|
|
592
595
|
});
|
|
593
596
|
return mod.default || mod;
|
|
594
597
|
}
|
|
598
|
+
async function unrunImport(id) {
|
|
599
|
+
const { module: module$1 } = await unrun({ path: pathToFileURL(id).href }).catch((error) => {
|
|
600
|
+
if (error?.message?.includes?.("Cannot find module")) {
|
|
601
|
+
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}`);
|
|
602
|
+
configError.cause = error;
|
|
603
|
+
throw configError;
|
|
604
|
+
} else throw error;
|
|
605
|
+
});
|
|
606
|
+
return module$1;
|
|
607
|
+
}
|
|
595
608
|
|
|
596
609
|
//#endregion
|
|
597
610
|
//#region src/options/index.ts
|
|
598
|
-
const debug$
|
|
611
|
+
const debug$4 = debug("tsdown:options");
|
|
599
612
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
600
613
|
"**/node_modules/**",
|
|
601
614
|
"**/dist/**",
|
|
@@ -603,20 +616,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
603
616
|
"**/t?(e)mp/**"
|
|
604
617
|
];
|
|
605
618
|
async function resolveOptions(options) {
|
|
606
|
-
debug$
|
|
619
|
+
debug$4("options %O", options);
|
|
607
620
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
608
621
|
const files = [];
|
|
609
622
|
if (file) {
|
|
610
623
|
files.push(file);
|
|
611
|
-
debug$
|
|
612
|
-
debug$
|
|
613
|
-
} else debug$
|
|
624
|
+
debug$4("loaded root config file %s", file);
|
|
625
|
+
debug$4("root configs %O", rootConfigs);
|
|
626
|
+
} else debug$4("no root config file found");
|
|
614
627
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
615
628
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
616
629
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
617
630
|
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
|
|
618
631
|
}))).flat();
|
|
619
|
-
debug$
|
|
632
|
+
debug$4("resolved configs %O", configs);
|
|
620
633
|
return {
|
|
621
634
|
configs,
|
|
622
635
|
files
|
|
@@ -659,16 +672,16 @@ async function resolveWorkspace(config, options) {
|
|
|
659
672
|
const files = [];
|
|
660
673
|
return {
|
|
661
674
|
configs: (await Promise.all(packages.map(async (cwd) => {
|
|
662
|
-
debug$
|
|
675
|
+
debug$4("loading workspace config %s", cwd);
|
|
663
676
|
const { configs, file } = await loadConfigFile({
|
|
664
677
|
...options,
|
|
665
678
|
config: workspaceConfig,
|
|
666
679
|
cwd
|
|
667
680
|
}, cwd);
|
|
668
681
|
if (file) {
|
|
669
|
-
debug$
|
|
682
|
+
debug$4("loaded workspace config file %s", file);
|
|
670
683
|
files.push(file);
|
|
671
|
-
} else debug$
|
|
684
|
+
} else debug$4("no workspace config file found in %s", cwd);
|
|
672
685
|
return configs.map((config$1) => ({
|
|
673
686
|
...normalized,
|
|
674
687
|
cwd,
|
|
@@ -773,7 +786,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
773
786
|
|
|
774
787
|
//#endregion
|
|
775
788
|
//#region src/features/external.ts
|
|
776
|
-
const debug$
|
|
789
|
+
const debug$3 = debug("tsdown:external");
|
|
777
790
|
function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle }) {
|
|
778
791
|
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
779
792
|
return {
|
|
@@ -782,7 +795,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
|
|
|
782
795
|
if (extraOptions.isEntry || !importer) return;
|
|
783
796
|
const shouldExternal = await externalStrategy(this, id, importer, extraOptions);
|
|
784
797
|
const nodeBuiltinModule = isBuiltin(id);
|
|
785
|
-
debug$
|
|
798
|
+
debug$3("shouldExternal: %s = %s", id, shouldExternal);
|
|
786
799
|
if (shouldExternal === true || shouldExternal === "absolute") return {
|
|
787
800
|
id,
|
|
788
801
|
external: shouldExternal,
|
|
@@ -790,7 +803,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
|
|
|
790
803
|
};
|
|
791
804
|
if (inlineOnly && !RE_DTS.test(importer) && !nodeBuiltinModule && id[0] !== "." && !path.isAbsolute(id)) {
|
|
792
805
|
const shouldInline = shouldExternal === "no-external" || matchPattern(id, inlineOnly);
|
|
793
|
-
debug$
|
|
806
|
+
debug$3("shouldInline: %s = %s", id, shouldInline);
|
|
794
807
|
if (shouldInline) return;
|
|
795
808
|
const resolved = await this.resolve(id, importer, extraOptions);
|
|
796
809
|
if (!resolved) return;
|
|
@@ -968,7 +981,7 @@ function formatBytes(bytes) {
|
|
|
968
981
|
|
|
969
982
|
//#endregion
|
|
970
983
|
//#region src/features/report.ts
|
|
971
|
-
const debug$
|
|
984
|
+
const debug$2 = debug("tsdown:report");
|
|
972
985
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
973
986
|
const gzipAsync = promisify(gzip);
|
|
974
987
|
const defaultOptions = {
|
|
@@ -1018,21 +1031,21 @@ function ReportPlugin(userOptions, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
|
1018
1031
|
};
|
|
1019
1032
|
}
|
|
1020
1033
|
async function calcSize(options, chunk) {
|
|
1021
|
-
debug$
|
|
1034
|
+
debug$2(`Calculating size for`, chunk.fileName);
|
|
1022
1035
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
1023
1036
|
const raw = Buffer.byteLength(content, "utf8");
|
|
1024
|
-
debug$
|
|
1037
|
+
debug$2("[size]", chunk.fileName, raw);
|
|
1025
1038
|
let gzip$1 = Infinity;
|
|
1026
1039
|
let brotli = Infinity;
|
|
1027
|
-
if (raw > options.maxCompressSize) debug$
|
|
1040
|
+
if (raw > options.maxCompressSize) debug$2(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
1028
1041
|
else {
|
|
1029
1042
|
if (options.gzip) {
|
|
1030
1043
|
gzip$1 = (await gzipAsync(content)).length;
|
|
1031
|
-
debug$
|
|
1044
|
+
debug$2("[gzip]", chunk.fileName, gzip$1);
|
|
1032
1045
|
}
|
|
1033
1046
|
if (options.brotli) {
|
|
1034
1047
|
brotli = (await brotliCompressAsync(content)).length;
|
|
1035
|
-
debug$
|
|
1048
|
+
debug$2("[brotli]", chunk.fileName, brotli);
|
|
1036
1049
|
}
|
|
1037
1050
|
}
|
|
1038
1051
|
return {
|
|
@@ -1079,7 +1092,7 @@ function getShimsInject(format, platform) {
|
|
|
1079
1092
|
|
|
1080
1093
|
//#endregion
|
|
1081
1094
|
//#region src/features/rolldown.ts
|
|
1082
|
-
const debug =
|
|
1095
|
+
const debug$1 = debug("tsdown:rolldown");
|
|
1083
1096
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
1084
1097
|
const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
|
|
1085
1098
|
const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
|
|
@@ -1087,11 +1100,11 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
|
1087
1100
|
...inputOptions,
|
|
1088
1101
|
output: outputOptions
|
|
1089
1102
|
};
|
|
1090
|
-
debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1103
|
+
debug$1("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1091
1104
|
return rolldownConfig;
|
|
1092
1105
|
}
|
|
1093
1106
|
async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
1094
|
-
const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target,
|
|
1107
|
+
const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer, globImport } = config;
|
|
1095
1108
|
const plugins = [];
|
|
1096
1109
|
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
1097
1110
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
@@ -1121,6 +1134,16 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
1121
1134
|
}
|
|
1122
1135
|
if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(report, logger, cwd, cjsDts, name, isMultiFormat));
|
|
1123
1136
|
if (!cjsDts) plugins.push(userPlugins);
|
|
1137
|
+
const define = {
|
|
1138
|
+
...config.define,
|
|
1139
|
+
...Object.keys(env).reduce((acc, key) => {
|
|
1140
|
+
const value = JSON.stringify(env[key]);
|
|
1141
|
+
acc[`process.env.${key}`] = value;
|
|
1142
|
+
acc[`import.meta.env.${key}`] = value;
|
|
1143
|
+
return acc;
|
|
1144
|
+
}, Object.create(null))
|
|
1145
|
+
};
|
|
1146
|
+
const inject = shims && !cjsDts ? getShimsInject(format, platform) : void 0;
|
|
1124
1147
|
return await mergeUserOptions({
|
|
1125
1148
|
input: entry,
|
|
1126
1149
|
cwd,
|
|
@@ -1131,16 +1154,8 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
1131
1154
|
platform: cjsDts || format === "cjs" ? "node" : platform,
|
|
1132
1155
|
transform: {
|
|
1133
1156
|
target,
|
|
1134
|
-
define
|
|
1135
|
-
|
|
1136
|
-
...Object.keys(env).reduce((acc, key) => {
|
|
1137
|
-
const value = JSON.stringify(env[key]);
|
|
1138
|
-
acc[`process.env.${key}`] = value;
|
|
1139
|
-
acc[`import.meta.env.${key}`] = value;
|
|
1140
|
-
return acc;
|
|
1141
|
-
}, Object.create(null))
|
|
1142
|
-
},
|
|
1143
|
-
inject: { ...shims && !cjsDts && getShimsInject(format, platform) }
|
|
1157
|
+
define,
|
|
1158
|
+
inject
|
|
1144
1159
|
},
|
|
1145
1160
|
plugins,
|
|
1146
1161
|
moduleTypes: loader,
|
|
@@ -1170,7 +1185,7 @@ async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
|
1170
1185
|
}, config.outputOptions, [format, { cjsDts }]);
|
|
1171
1186
|
}
|
|
1172
1187
|
async function getDebugRolldownDir() {
|
|
1173
|
-
if (!debug.enabled) return;
|
|
1188
|
+
if (!debug$1.enabled) return;
|
|
1174
1189
|
return await mkdtemp(join(tmpdir(), "tsdown-config-"));
|
|
1175
1190
|
}
|
|
1176
1191
|
async function debugBuildOptions(dir, name, format, buildOptions) {
|
|
@@ -1189,7 +1204,7 @@ Package name: ${name || "not specified"}
|
|
|
1189
1204
|
*/
|
|
1190
1205
|
|
|
1191
1206
|
export default ${serialized}\n`);
|
|
1192
|
-
debug("Wrote debug rolldown config for \"%s\" (%s) -> %s", name || "default name", format, outFile);
|
|
1207
|
+
debug$1("Wrote debug rolldown config for \"%s\" (%s) -> %s", name || "default name", format, outFile);
|
|
1193
1208
|
}
|
|
1194
1209
|
function handlePluginInspect(plugins) {
|
|
1195
1210
|
if (Array.isArray(plugins)) for (const plugin of plugins) handlePluginInspect(plugin);
|
|
@@ -416,7 +416,7 @@ interface Options {
|
|
|
416
416
|
* Config loader to use. It can only be set via CLI or API.
|
|
417
417
|
* @default 'auto'
|
|
418
418
|
*/
|
|
419
|
-
configLoader?: "auto" | "native" | "unconfig";
|
|
419
|
+
configLoader?: "auto" | "native" | "unconfig" | "unrun";
|
|
420
420
|
/**
|
|
421
421
|
* Reuse config from Vite or Vitest (experimental)
|
|
422
422
|
* @default false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.11",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,24 +76,25 @@
|
|
|
76
76
|
"diff": "^8.0.2",
|
|
77
77
|
"empathic": "^2.0.0",
|
|
78
78
|
"hookable": "^5.5.3",
|
|
79
|
-
"rolldown": "1.0.0-beta.
|
|
80
|
-
"rolldown-plugin-dts": "^0.
|
|
79
|
+
"rolldown": "1.0.0-beta.45",
|
|
80
|
+
"rolldown-plugin-dts": "^0.17.1",
|
|
81
81
|
"semver": "^7.7.3",
|
|
82
82
|
"tinyexec": "^1.0.1",
|
|
83
83
|
"tinyglobby": "^0.2.15",
|
|
84
84
|
"tree-kill": "^1.2.2",
|
|
85
|
-
"unconfig": "^7.3.3"
|
|
85
|
+
"unconfig": "^7.3.3",
|
|
86
|
+
"unrun": "^0.2.0"
|
|
86
87
|
},
|
|
87
88
|
"devDependencies": {
|
|
88
89
|
"@arethetypeswrong/core": "^0.18.2",
|
|
89
90
|
"@sxzz/eslint-config": "^7.2.7",
|
|
90
91
|
"@sxzz/prettier-config": "^2.2.4",
|
|
91
|
-
"@sxzz/test-utils": "^0.5.
|
|
92
|
+
"@sxzz/test-utils": "^0.5.12",
|
|
92
93
|
"@types/debug": "^4.1.12",
|
|
93
|
-
"@types/node": "^24.
|
|
94
|
+
"@types/node": "^24.9.1",
|
|
94
95
|
"@types/semver": "^7.7.1",
|
|
95
96
|
"@unocss/eslint-plugin": "^66.5.4",
|
|
96
|
-
"@vueuse/core": "^
|
|
97
|
+
"@vueuse/core": "^14.0.0",
|
|
97
98
|
"bumpp": "^10.3.1",
|
|
98
99
|
"eslint": "^9.38.0",
|
|
99
100
|
"lightningcss": "^1.30.2",
|
|
@@ -101,13 +102,12 @@
|
|
|
101
102
|
"prettier": "^3.6.2",
|
|
102
103
|
"publint": "^0.3.15",
|
|
103
104
|
"rolldown-plugin-require-cjs": "^0.3.1",
|
|
104
|
-
"tsx": "^4.20.6",
|
|
105
105
|
"typescript": "~5.9.3",
|
|
106
106
|
"unocss": "^66.5.4",
|
|
107
107
|
"unplugin-lightningcss": "^0.4.3",
|
|
108
108
|
"unplugin-unused": "^0.5.4",
|
|
109
109
|
"vite": "npm:rolldown-vite@latest",
|
|
110
|
-
"vitest": "^
|
|
110
|
+
"vitest": "^4.0.3"
|
|
111
111
|
},
|
|
112
112
|
"engines": {
|
|
113
113
|
"node": ">=20.19.0"
|
|
@@ -116,8 +116,8 @@
|
|
|
116
116
|
"scripts": {
|
|
117
117
|
"lint": "eslint --cache --max-warnings 0 .",
|
|
118
118
|
"lint:fix": "pnpm run lint --fix",
|
|
119
|
-
"build": "
|
|
120
|
-
"dev": "
|
|
119
|
+
"build": "unrun ./src/run.ts",
|
|
120
|
+
"dev": "unrun ./src/run.ts",
|
|
121
121
|
"test": "vitest",
|
|
122
122
|
"typecheck": "tsc --noEmit",
|
|
123
123
|
"format": "prettier --cache --write .",
|