tsdown 0.15.7 → 0.15.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-BkpjlM2q.d.mts → config-Ck33bdQw.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-DrxQXJvd.mjs → migrate-DWAdCBXo.mjs} +1 -2
- package/dist/{logger-BdsX4_1k.mjs → package-BPB-NGqU.mjs} +5 -1
- package/dist/plugins.d.mts +1 -1
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +6 -7
- package/dist/{src-C51C732j.mjs → src-DjVGuMse.mjs} +78 -43
- package/package.json +6 -6
- package/dist/package-BbXTWj2q.mjs +0 -5
- /package/dist/{types-BBYDPehL.d.mts → types-CAr6Dndf.d.mts} +0 -0
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./types-
|
|
2
|
-
import { defineConfig } from "./config-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./types-CAr6Dndf.mjs";
|
|
2
|
+
import { defineConfig } from "./config-Ck33bdQw.mjs";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, NoExternalFn, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-
|
|
2
|
-
import { defineConfig } from "./config-
|
|
1
|
+
import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, NoExternalFn, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-CAr6Dndf.mjs";
|
|
2
|
+
import { defineConfig } from "./config-Ck33bdQw.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CCGWF4al.mjs";
|
|
2
|
-
import { build, buildSingle, shimFile } from "./src-
|
|
3
|
-
import { globalLogger } from "./
|
|
2
|
+
import { build, buildSingle, shimFile } from "./src-DjVGuMse.mjs";
|
|
3
|
+
import { globalLogger } from "./package-BPB-NGqU.mjs";
|
|
4
4
|
|
|
5
5
|
export { build, buildSingle, defineConfig, globalLogger, shimFile };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { globalLogger } from "./
|
|
2
|
-
import { version } from "./package-BbXTWj2q.mjs";
|
|
1
|
+
import { globalLogger, version } from "./package-BPB-NGqU.mjs";
|
|
3
2
|
import process from "node:process";
|
|
4
3
|
import { bold, green, underline } from "ansis";
|
|
5
4
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
@@ -145,4 +145,8 @@ function hue2rgb(p, q, t) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
//#endregion
|
|
148
|
-
|
|
148
|
+
//#region package.json
|
|
149
|
+
var version = "0.15.8";
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
export { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray, version };
|
package/dist/plugins.d.mts
CHANGED
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./config-CCGWF4al.mjs";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-
|
|
3
|
-
import "./
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-DjVGuMse.mjs";
|
|
3
|
+
import "./package-BPB-NGqU.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,13 +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 { globalLogger, resolveComma, toArray } from "./
|
|
5
|
-
import { version } from "./package-BbXTWj2q.mjs";
|
|
4
|
+
import { globalLogger, resolveComma, toArray, version } from "./package-BPB-NGqU.mjs";
|
|
6
5
|
import module from "node:module";
|
|
7
6
|
import process from "node:process";
|
|
8
7
|
import { dim } from "ansis";
|
|
9
8
|
import { VERSION } from "rolldown";
|
|
10
|
-
const
|
|
9
|
+
const Debug = __cjs_require("debug");
|
|
11
10
|
import { cac } from "cac";
|
|
12
11
|
|
|
13
12
|
//#region src/cli.ts
|
|
@@ -24,7 +23,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
24
23
|
await build$1(flags);
|
|
25
24
|
});
|
|
26
25
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
27
|
-
const { migrate } = await import("./migrate-
|
|
26
|
+
const { migrate } = await import("./migrate-DWAdCBXo.mjs");
|
|
28
27
|
await migrate(args);
|
|
29
28
|
});
|
|
30
29
|
async function runCLI() {
|
|
@@ -33,10 +32,10 @@ async function runCLI() {
|
|
|
33
32
|
let namespace;
|
|
34
33
|
if (cli.options.debug === true) namespace = "tsdown:*";
|
|
35
34
|
else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
|
|
36
|
-
const enabled =
|
|
35
|
+
const enabled = Debug.disable();
|
|
37
36
|
if (enabled) namespace += `,${enabled}`;
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
Debug.enable(namespace);
|
|
38
|
+
Debug("tsdown:debug")("Debugging enabled", namespace);
|
|
40
39
|
}
|
|
41
40
|
try {
|
|
42
41
|
await cli.runMatchedCommand();
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
2
|
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
3
|
-
import { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray } from "./
|
|
3
|
+
import { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray, version } from "./package-BPB-NGqU.mjs";
|
|
4
4
|
import { builtinModules, isBuiltin } from "node:module";
|
|
5
|
-
import path, { dirname, normalize, sep } from "node:path";
|
|
5
|
+
import path, { dirname, join, normalize, sep } from "node:path";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
8
|
import { blue, bold, dim, green, underline } from "ansis";
|
|
9
|
-
import { build } from "rolldown";
|
|
9
|
+
import { VERSION, build } from "rolldown";
|
|
10
10
|
import { exec } from "tinyexec";
|
|
11
11
|
const treeKill = __cjs_require("tree-kill");
|
|
12
12
|
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
|
-
import { promisify } from "node:util";
|
|
16
|
-
const
|
|
15
|
+
import util, { promisify } from "node:util";
|
|
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";
|
|
@@ -69,7 +69,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
69
69
|
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/features/attw.ts
|
|
72
|
-
const debug$
|
|
72
|
+
const debug$7 = Debug("tsdown:attw");
|
|
73
73
|
const exec$1 = promisify(child_process.exec);
|
|
74
74
|
/**
|
|
75
75
|
* ATTW profiles.
|
|
@@ -115,7 +115,7 @@ async function attw(options) {
|
|
|
115
115
|
}
|
|
116
116
|
const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
|
|
117
117
|
const t = performance.now();
|
|
118
|
-
debug$
|
|
118
|
+
debug$7("Running attw check");
|
|
119
119
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
120
120
|
let attwCore;
|
|
121
121
|
try {
|
|
@@ -147,7 +147,7 @@ async function attw(options) {
|
|
|
147
147
|
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
148
148
|
} catch (error) {
|
|
149
149
|
options.logger.error("ATTW check failed:", error);
|
|
150
|
-
debug$
|
|
150
|
+
debug$7("Found errors, setting exit code to 1");
|
|
151
151
|
process.exitCode = 1;
|
|
152
152
|
} finally {
|
|
153
153
|
await fsRemove(tempDir);
|
|
@@ -164,14 +164,14 @@ async function attw(options) {
|
|
|
164
164
|
function warnLegacyCJS(config) {
|
|
165
165
|
if (!config.format.includes("cjs") || !config.target) return;
|
|
166
166
|
if (config.target.some((t) => {
|
|
167
|
-
const version = coerce(t.split("node")[1]);
|
|
168
|
-
return version && satisfies(version, ">=23.0.0 || >=22.12.0");
|
|
167
|
+
const version$1 = coerce(t.split("node")[1]);
|
|
168
|
+
return version$1 && satisfies(version$1, ">=23.0.0 || >=22.12.0");
|
|
169
169
|
})) config.logger.warnOnce("We recommend using the ESM format instead of CommonJS.\nThe ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.\nLearn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here");
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
//#endregion
|
|
173
173
|
//#region src/features/clean.ts
|
|
174
|
-
const debug$
|
|
174
|
+
const debug$6 = Debug("tsdown:clean");
|
|
175
175
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
176
176
|
async function cleanOutDir(configs) {
|
|
177
177
|
const removes = /* @__PURE__ */ new Set();
|
|
@@ -188,10 +188,10 @@ async function cleanOutDir(configs) {
|
|
|
188
188
|
if (!removes.size) return;
|
|
189
189
|
globalLogger.info(`Cleaning ${removes.size} files`);
|
|
190
190
|
await Promise.all([...removes].map(async (file) => {
|
|
191
|
-
debug$
|
|
191
|
+
debug$6("Removing", file);
|
|
192
192
|
await fsRemove(file);
|
|
193
193
|
}));
|
|
194
|
-
debug$
|
|
194
|
+
debug$6("Removed %d files", removes.size);
|
|
195
195
|
}
|
|
196
196
|
function resolveClean(clean, outDir, cwd) {
|
|
197
197
|
if (clean === true) clean = [slash(outDir)];
|
|
@@ -349,7 +349,7 @@ async function createHooks$1(options) {
|
|
|
349
349
|
|
|
350
350
|
//#endregion
|
|
351
351
|
//#region src/features/publint.ts
|
|
352
|
-
const debug$
|
|
352
|
+
const debug$5 = Debug("tsdown:publint");
|
|
353
353
|
async function publint(options) {
|
|
354
354
|
if (!options.publint) return;
|
|
355
355
|
if (!options.pkg) {
|
|
@@ -357,14 +357,14 @@ async function publint(options) {
|
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
359
|
const t = performance.now();
|
|
360
|
-
debug$
|
|
360
|
+
debug$5("Running publint");
|
|
361
361
|
const { publint: publint$1 } = await import("publint");
|
|
362
362
|
const { formatMessage } = await import("publint/utils");
|
|
363
363
|
const { messages } = await publint$1({
|
|
364
364
|
...options.publint === true ? {} : options.publint,
|
|
365
365
|
pkgDir: path.dirname(options.pkg.packageJsonPath)
|
|
366
366
|
});
|
|
367
|
-
debug$
|
|
367
|
+
debug$5("Found %d issues", messages.length);
|
|
368
368
|
if (!messages.length) options.logger.success(prettyName(options.name), `No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
369
369
|
let hasError = false;
|
|
370
370
|
for (const message of messages) {
|
|
@@ -378,7 +378,7 @@ async function publint(options) {
|
|
|
378
378
|
options.logger[logType](prettyName(options.name), formattedMessage);
|
|
379
379
|
}
|
|
380
380
|
if (hasError) {
|
|
381
|
-
debug$
|
|
381
|
+
debug$5("Found errors, setting exit code to 1");
|
|
382
382
|
process.exitCode = 1;
|
|
383
383
|
}
|
|
384
384
|
}
|
|
@@ -421,6 +421,7 @@ function resolveTarget(logger, target, pkg, name) {
|
|
|
421
421
|
if (pkgTarget) target = pkgTarget;
|
|
422
422
|
else return;
|
|
423
423
|
}
|
|
424
|
+
if (typeof target === "number") throw new TypeError(`Invalid target: ${target}`);
|
|
424
425
|
const targets = resolveComma(toArray(target));
|
|
425
426
|
if (targets.length) logger.info(prettyName(name), `target${targets.length > 1 ? "s" : ""}: ${generateColor(name)(targets.join(", "))}`);
|
|
426
427
|
return targets;
|
|
@@ -464,11 +465,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
|
|
|
464
465
|
|
|
465
466
|
//#endregion
|
|
466
467
|
//#region src/utils/package.ts
|
|
467
|
-
const debug$
|
|
468
|
+
const debug$4 = Debug("tsdown:package");
|
|
468
469
|
async function readPackageJson(dir) {
|
|
469
470
|
const packageJsonPath = up$1({ cwd: dir });
|
|
470
471
|
if (!packageJsonPath) return;
|
|
471
|
-
debug$
|
|
472
|
+
debug$4("Reading package.json:", packageJsonPath);
|
|
472
473
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
473
474
|
return {
|
|
474
475
|
...JSON.parse(contents),
|
|
@@ -594,7 +595,7 @@ async function nativeImport(id) {
|
|
|
594
595
|
|
|
595
596
|
//#endregion
|
|
596
597
|
//#region src/options/index.ts
|
|
597
|
-
const debug$
|
|
598
|
+
const debug$3 = Debug("tsdown:options");
|
|
598
599
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
599
600
|
"**/node_modules/**",
|
|
600
601
|
"**/dist/**",
|
|
@@ -602,20 +603,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
602
603
|
"**/t?(e)mp/**"
|
|
603
604
|
];
|
|
604
605
|
async function resolveOptions(options) {
|
|
605
|
-
debug$
|
|
606
|
+
debug$3("options %O", options);
|
|
606
607
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
607
608
|
const files = [];
|
|
608
609
|
if (file) {
|
|
609
610
|
files.push(file);
|
|
610
|
-
debug$
|
|
611
|
-
debug$
|
|
612
|
-
} else debug$
|
|
611
|
+
debug$3("loaded root config file %s", file);
|
|
612
|
+
debug$3("root configs %O", rootConfigs);
|
|
613
|
+
} else debug$3("no root config file found");
|
|
613
614
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
614
615
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
615
616
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
616
617
|
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
|
|
617
618
|
}))).flat();
|
|
618
|
-
debug$
|
|
619
|
+
debug$3("resolved configs %O", configs);
|
|
619
620
|
return {
|
|
620
621
|
configs,
|
|
621
622
|
files
|
|
@@ -658,16 +659,16 @@ async function resolveWorkspace(config, options) {
|
|
|
658
659
|
const files = [];
|
|
659
660
|
return {
|
|
660
661
|
configs: (await Promise.all(packages.map(async (cwd) => {
|
|
661
|
-
debug$
|
|
662
|
+
debug$3("loading workspace config %s", cwd);
|
|
662
663
|
const { configs, file } = await loadConfigFile({
|
|
663
664
|
...options,
|
|
664
665
|
config: workspaceConfig,
|
|
665
666
|
cwd
|
|
666
667
|
}, cwd);
|
|
667
668
|
if (file) {
|
|
668
|
-
debug$
|
|
669
|
+
debug$3("loaded workspace config file %s", file);
|
|
669
670
|
files.push(file);
|
|
670
|
-
} else debug$
|
|
671
|
+
} else debug$3("no workspace config file found in %s", cwd);
|
|
671
672
|
return configs.map((config$1) => ({
|
|
672
673
|
...normalized,
|
|
673
674
|
cwd,
|
|
@@ -772,7 +773,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
772
773
|
|
|
773
774
|
//#endregion
|
|
774
775
|
//#region src/features/external.ts
|
|
775
|
-
const debug$
|
|
776
|
+
const debug$2 = Debug("tsdown:external");
|
|
776
777
|
function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle }) {
|
|
777
778
|
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
778
779
|
return {
|
|
@@ -781,7 +782,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
|
|
|
781
782
|
if (extraOptions.isEntry || !importer) return;
|
|
782
783
|
const shouldExternal = await externalStrategy(this, id, importer, extraOptions);
|
|
783
784
|
const nodeBuiltinModule = isBuiltin(id);
|
|
784
|
-
debug$
|
|
785
|
+
debug$2("shouldExternal: %s = %s", id, shouldExternal);
|
|
785
786
|
if (shouldExternal === true || shouldExternal === "absolute") return {
|
|
786
787
|
id,
|
|
787
788
|
external: shouldExternal,
|
|
@@ -789,7 +790,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
|
|
|
789
790
|
};
|
|
790
791
|
if (inlineOnly && !RE_DTS.test(importer) && !nodeBuiltinModule && id[0] !== "." && !path.isAbsolute(id)) {
|
|
791
792
|
const shouldInline = shouldExternal === "no-external" || matchPattern(id, inlineOnly);
|
|
792
|
-
debug$
|
|
793
|
+
debug$2("shouldInline: %s = %s", id, shouldInline);
|
|
793
794
|
if (shouldInline) return;
|
|
794
795
|
const resolved = await this.resolve(id, importer, extraOptions);
|
|
795
796
|
if (!resolved) return;
|
|
@@ -836,8 +837,8 @@ function esbuildTargetToLightningCSS(target) {
|
|
|
836
837
|
for (const match of matches) {
|
|
837
838
|
const browser = ESBUILD_LIGHTNINGCSS_MAPPING[match[1]];
|
|
838
839
|
if (!browser) continue;
|
|
839
|
-
const version = match[2];
|
|
840
|
-
const versionInt = parseVersion(version);
|
|
840
|
+
const version$1 = match[2];
|
|
841
|
+
const versionInt = parseVersion(version$1);
|
|
841
842
|
if (versionInt == null) continue;
|
|
842
843
|
targets = targets || {};
|
|
843
844
|
targets[browser] = versionInt;
|
|
@@ -854,8 +855,8 @@ const ESBUILD_LIGHTNINGCSS_MAPPING = {
|
|
|
854
855
|
opera: "opera",
|
|
855
856
|
safari: "safari"
|
|
856
857
|
};
|
|
857
|
-
function parseVersion(version) {
|
|
858
|
-
const [major, minor = 0, patch = 0] = version.split("-")[0].split(".").map((v) => Number.parseInt(v, 10));
|
|
858
|
+
function parseVersion(version$1) {
|
|
859
|
+
const [major, minor = 0, patch = 0] = version$1.split("-")[0].split(".").map((v) => Number.parseInt(v, 10));
|
|
859
860
|
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) return null;
|
|
860
861
|
return major << 16 | minor << 8 | patch;
|
|
861
862
|
}
|
|
@@ -967,7 +968,7 @@ function formatBytes(bytes) {
|
|
|
967
968
|
|
|
968
969
|
//#endregion
|
|
969
970
|
//#region src/features/report.ts
|
|
970
|
-
const debug$
|
|
971
|
+
const debug$1 = Debug("tsdown:report");
|
|
971
972
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
972
973
|
const gzipAsync = promisify(gzip);
|
|
973
974
|
const defaultOptions = {
|
|
@@ -1017,21 +1018,21 @@ function ReportPlugin(userOptions, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
|
1017
1018
|
};
|
|
1018
1019
|
}
|
|
1019
1020
|
async function calcSize(options, chunk) {
|
|
1020
|
-
debug$
|
|
1021
|
+
debug$1(`Calculating size for`, chunk.fileName);
|
|
1021
1022
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
1022
1023
|
const raw = Buffer.byteLength(content, "utf8");
|
|
1023
|
-
debug$
|
|
1024
|
+
debug$1("[size]", chunk.fileName, raw);
|
|
1024
1025
|
let gzip$1 = Infinity;
|
|
1025
1026
|
let brotli = Infinity;
|
|
1026
|
-
if (raw > options.maxCompressSize) debug$
|
|
1027
|
+
if (raw > options.maxCompressSize) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
1027
1028
|
else {
|
|
1028
1029
|
if (options.gzip) {
|
|
1029
1030
|
gzip$1 = (await gzipAsync(content)).length;
|
|
1030
|
-
debug$
|
|
1031
|
+
debug$1("[gzip]", chunk.fileName, gzip$1);
|
|
1031
1032
|
}
|
|
1032
1033
|
if (options.brotli) {
|
|
1033
1034
|
brotli = (await brotliCompressAsync(content)).length;
|
|
1034
|
-
debug$
|
|
1035
|
+
debug$1("[brotli]", chunk.fileName, brotli);
|
|
1035
1036
|
}
|
|
1036
1037
|
}
|
|
1037
1038
|
return {
|
|
@@ -1078,7 +1079,7 @@ function getShimsInject(format, platform) {
|
|
|
1078
1079
|
|
|
1079
1080
|
//#endregion
|
|
1080
1081
|
//#region src/features/rolldown.ts
|
|
1081
|
-
const debug
|
|
1082
|
+
const debug = Debug("tsdown:rolldown");
|
|
1082
1083
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
1083
1084
|
const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
|
|
1084
1085
|
const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
|
|
@@ -1086,7 +1087,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
|
1086
1087
|
...inputOptions,
|
|
1087
1088
|
output: outputOptions
|
|
1088
1089
|
};
|
|
1089
|
-
debug
|
|
1090
|
+
debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1090
1091
|
return rolldownConfig;
|
|
1091
1092
|
}
|
|
1092
1093
|
async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
@@ -1166,6 +1167,38 @@ async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
|
1166
1167
|
footer: resolveChunkAddon(footer, format)
|
|
1167
1168
|
}, config.outputOptions, [format, { cjsDts }]);
|
|
1168
1169
|
}
|
|
1170
|
+
async function getDebugRolldownDir() {
|
|
1171
|
+
if (!debug.enabled) return;
|
|
1172
|
+
return await mkdtemp(join(tmpdir(), "tsdown-config-"));
|
|
1173
|
+
}
|
|
1174
|
+
async function debugBuildOptions(dir, name, format, buildOptions) {
|
|
1175
|
+
const outFile = join(dir, `tsdown.config.${format}.js`);
|
|
1176
|
+
handlePluginInspect(buildOptions.plugins);
|
|
1177
|
+
const serialized = util.formatWithOptions({
|
|
1178
|
+
depth: null,
|
|
1179
|
+
maxArrayLength: null,
|
|
1180
|
+
maxStringLength: null
|
|
1181
|
+
}, buildOptions);
|
|
1182
|
+
await writeFile(outFile, `/*
|
|
1183
|
+
Auto-generated rolldown config for tsdown debug purposes
|
|
1184
|
+
tsdown v${version}, rolldown v${VERSION}
|
|
1185
|
+
Generated on ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
1186
|
+
Package name: ${name || "not specified"}
|
|
1187
|
+
*/
|
|
1188
|
+
|
|
1189
|
+
export default ${serialized}\n`);
|
|
1190
|
+
debug("Wrote debug rolldown config for \"%s\" (%s) -> %s", name || "default name", format, outFile);
|
|
1191
|
+
}
|
|
1192
|
+
function handlePluginInspect(plugins) {
|
|
1193
|
+
if (Array.isArray(plugins)) for (const plugin of plugins) handlePluginInspect(plugin);
|
|
1194
|
+
else if (typeof plugins === "object" && plugins !== null && "name" in plugins) plugins[util.inspect.custom] = function(depth, options, inspect) {
|
|
1195
|
+
if ("_options" in plugins) return inspect({
|
|
1196
|
+
name: plugins.name,
|
|
1197
|
+
options: plugins._options
|
|
1198
|
+
}, options);
|
|
1199
|
+
else return `"rolldown plugin: ${plugins.name}"`;
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1169
1202
|
|
|
1170
1203
|
//#endregion
|
|
1171
1204
|
//#region src/features/shortcuts.ts
|
|
@@ -1318,6 +1351,7 @@ async function buildSingle(config, clean) {
|
|
|
1318
1351
|
let hasErrors = false;
|
|
1319
1352
|
const isMultiFormat = formats.length > 1;
|
|
1320
1353
|
const chunks = {};
|
|
1354
|
+
const debugRolldownDir = await getDebugRolldownDir();
|
|
1321
1355
|
await Promise.all(formats.map(async (format) => {
|
|
1322
1356
|
try {
|
|
1323
1357
|
const buildOptions = await getBuildOptions(config, format, isMultiFormat, false);
|
|
@@ -1325,6 +1359,7 @@ async function buildSingle(config, clean) {
|
|
|
1325
1359
|
...context,
|
|
1326
1360
|
buildOptions
|
|
1327
1361
|
});
|
|
1362
|
+
if (debugRolldownDir) await debugBuildOptions(debugRolldownDir, config.name, format, buildOptions);
|
|
1328
1363
|
const { output } = await build(buildOptions);
|
|
1329
1364
|
chunks[format] = output;
|
|
1330
1365
|
if (format === "cjs" && dts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.8",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"empathic": "^2.0.0",
|
|
78
78
|
"hookable": "^5.5.3",
|
|
79
79
|
"rolldown": "latest",
|
|
80
|
-
"rolldown-plugin-dts": "^0.16.
|
|
80
|
+
"rolldown-plugin-dts": "^0.16.12",
|
|
81
81
|
"semver": "^7.7.3",
|
|
82
82
|
"tinyexec": "^1.0.1",
|
|
83
83
|
"tinyglobby": "^0.2.15",
|
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
"@sxzz/prettier-config": "^2.2.4",
|
|
91
91
|
"@sxzz/test-utils": "^0.5.11",
|
|
92
92
|
"@types/debug": "^4.1.12",
|
|
93
|
-
"@types/node": "^24.
|
|
93
|
+
"@types/node": "^24.8.1",
|
|
94
94
|
"@types/semver": "^7.7.1",
|
|
95
|
-
"@unocss/eslint-plugin": "^66.5.
|
|
95
|
+
"@unocss/eslint-plugin": "^66.5.4",
|
|
96
96
|
"@vueuse/core": "^13.9.0",
|
|
97
97
|
"bumpp": "^10.3.1",
|
|
98
|
-
"eslint": "^9.
|
|
98
|
+
"eslint": "^9.38.0",
|
|
99
99
|
"lightningcss": "^1.30.2",
|
|
100
100
|
"pkg-types": "^2.3.0",
|
|
101
101
|
"prettier": "^3.6.2",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"rolldown-plugin-require-cjs": "^0.3.1",
|
|
104
104
|
"tsx": "^4.20.6",
|
|
105
105
|
"typescript": "~5.9.3",
|
|
106
|
-
"unocss": "^66.5.
|
|
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",
|
|
File without changes
|