tsdown 0.21.1 → 0.21.2
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/build-B1oBkI4C.mjs +2 -0
- package/dist/{build-BG-XbM6V.mjs → build-CpOl_krN.mjs} +8 -8
- package/dist/{config-B9iARaO_.d.mts → config-Cz86PxVM.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/{format-CEIo9KZy.mjs → format-DPVBd8E4.mjs} +17 -12
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{options-CQzuh3xe.mjs → options--36H_-x3.mjs} +27 -15
- package/dist/{package-9LGtt4SC.mjs → package-B0nLlt00.mjs} +1 -1
- package/dist/plugins.d.mts +1 -1
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +3 -3
- package/dist/{types-CuHu3Iaq.d.mts → types-DUxKwUmX.d.mts} +23 -4
- package/dist/{watch-yZCV-ZeB.mjs → watch-seL2bosb.mjs} +1 -1
- package/package.json +13 -13
- package/dist/build-DHPfiKA-.mjs +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
2
|
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
3
3
|
import { a as pkgExists, l as slash, n as importWithError, o as promiseWithResolvers, t as debounce, u as toArray } from "./general-CRszZCrY.mjs";
|
|
4
|
-
import { a as getPackageType, c as isGlobEntry, d as cleanOutDir, i as loadConfigFile, l as toObjectEntry, n as mergeUserOptions, o as writeExports, r as resolveUserConfig, s as buildExe, u as cleanChunks } from "./options-
|
|
5
|
-
import {
|
|
4
|
+
import { a as getPackageType, c as isGlobEntry, d as cleanOutDir, i as loadConfigFile, l as toObjectEntry, n as mergeUserOptions, o as writeExports, r as resolveUserConfig, s as buildExe, u as cleanChunks } from "./options--36H_-x3.mjs";
|
|
5
|
+
import { r as fsRemove, t as fsCopy } from "./fs-Dd6Htx2P.mjs";
|
|
6
6
|
import { a as globalLogger, t as LogLevels } from "./logger-BU0v7CAk.mjs";
|
|
7
|
-
import { a as getShimsInject, r as DepPlugin } from "./format-
|
|
8
|
-
import { t as version } from "./package-
|
|
9
|
-
import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, t as WatchPlugin } from "./watch-
|
|
7
|
+
import { a as getShimsInject, r as DepPlugin } from "./format-DPVBd8E4.mjs";
|
|
8
|
+
import { t as version } from "./package-B0nLlt00.mjs";
|
|
9
|
+
import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, t as WatchPlugin } from "./watch-seL2bosb.mjs";
|
|
10
10
|
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import process from "node:process";
|
|
@@ -547,7 +547,7 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
547
547
|
}, config.inputOptions, [format, { cjsDts }]);
|
|
548
548
|
}
|
|
549
549
|
async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
550
|
-
const { banner, cjsDefault,
|
|
550
|
+
const { banner, cjsDefault, footer, minify, outDir, sourcemap, unbundle } = config;
|
|
551
551
|
const [entryFileNames, chunkFileNames] = resolveChunkFilename(config, inputOptions, format);
|
|
552
552
|
return await mergeUserOptions({
|
|
553
553
|
format: cjsDts ? "es" : format,
|
|
@@ -559,7 +559,7 @@ async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
|
559
559
|
entryFileNames,
|
|
560
560
|
chunkFileNames,
|
|
561
561
|
preserveModules: unbundle,
|
|
562
|
-
preserveModulesRoot: unbundle ?
|
|
562
|
+
preserveModulesRoot: unbundle ? config.root : void 0,
|
|
563
563
|
postBanner: resolveChunkAddon(banner, format),
|
|
564
564
|
postFooter: resolveChunkAddon(footer, format),
|
|
565
565
|
codeSplitting: config.exe ? false : void 0
|
|
@@ -763,7 +763,7 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
|
|
|
763
763
|
restart();
|
|
764
764
|
}
|
|
765
765
|
if ((event.event === "create" || event.event === "delete") && config.rawEntry && isGlobEntry(config.rawEntry)) {
|
|
766
|
-
const newEntry = await toObjectEntry(config.rawEntry, config.cwd);
|
|
766
|
+
const [newEntry] = await toObjectEntry(config.rawEntry, config.cwd);
|
|
767
767
|
if (Object.keys(config.entry).toSorted().join("\0") !== Object.keys(newEntry).toSorted().join("\0")) {
|
|
768
768
|
globalLogger.info("Entry files changed, restarting...");
|
|
769
769
|
restart();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as ResolvedConfig, p as UserConfigFn } from "./types-
|
|
1
|
+
import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as ResolvedConfig, p as UserConfigFn } from "./types-DUxKwUmX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/config/options.d.ts
|
|
4
4
|
/**
|
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./types-
|
|
2
|
-
import { n as mergeConfig, t as defineConfig } from "./config-
|
|
1
|
+
import { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./types-DUxKwUmX.mjs";
|
|
2
|
+
import { n as mergeConfig, t as defineConfig } from "./config-Cz86PxVM.mjs";
|
|
3
3
|
export { UserConfig, UserConfigExport, UserConfigFn, defineConfig, mergeConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -18,7 +18,7 @@ function getShimsInject(format, platform) {
|
|
|
18
18
|
//#region src/features/deps.ts
|
|
19
19
|
const debug = createDebug("tsdown:dep");
|
|
20
20
|
function resolveDepsConfig(config, logger) {
|
|
21
|
-
let { neverBundle, alwaysBundle,
|
|
21
|
+
let { neverBundle, alwaysBundle, onlyBundle, skipNodeModulesBundle = false } = config.deps || {};
|
|
22
22
|
if (config.external != null) {
|
|
23
23
|
if (neverBundle != null) throw new TypeError("`external` is deprecated. Cannot be used with `deps.neverBundle`.");
|
|
24
24
|
logger?.warn("`external` is deprecated. Use `deps.neverBundle` instead.");
|
|
@@ -29,10 +29,15 @@ function resolveDepsConfig(config, logger) {
|
|
|
29
29
|
logger?.warn("`noExternal` is deprecated. Use `deps.alwaysBundle` instead.");
|
|
30
30
|
alwaysBundle = config.noExternal;
|
|
31
31
|
}
|
|
32
|
+
if (config.deps?.onlyAllowBundle != null) {
|
|
33
|
+
if (onlyBundle != null) throw new TypeError("`deps.onlyAllowBundle` is deprecated. Cannot be used with `deps.onlyBundle`.");
|
|
34
|
+
logger?.warn("`deps.onlyAllowBundle` is deprecated. Use `deps.onlyBundle` instead.");
|
|
35
|
+
onlyBundle = config.deps.onlyAllowBundle;
|
|
36
|
+
}
|
|
32
37
|
if (config.inlineOnly != null) {
|
|
33
|
-
if (
|
|
34
|
-
logger?.warn("`inlineOnly` is deprecated. Use `deps.
|
|
35
|
-
|
|
38
|
+
if (onlyBundle != null) throw new TypeError("`inlineOnly` is deprecated. Cannot be used with `deps.onlyBundle`.");
|
|
39
|
+
logger?.warn("`inlineOnly` is deprecated. Use `deps.onlyBundle` instead.");
|
|
40
|
+
onlyBundle = config.inlineOnly;
|
|
36
41
|
}
|
|
37
42
|
if (config.skipNodeModulesBundle != null) {
|
|
38
43
|
if (config.deps?.skipNodeModulesBundle != null) throw new TypeError("`skipNodeModulesBundle` is deprecated. Cannot be used with `deps.skipNodeModulesBundle`.");
|
|
@@ -46,11 +51,11 @@ function resolveDepsConfig(config, logger) {
|
|
|
46
51
|
alwaysBundle = (id) => matchPattern(id, alwaysBundlePatterns);
|
|
47
52
|
}
|
|
48
53
|
if (skipNodeModulesBundle && alwaysBundle != null) throw new TypeError("`deps.skipNodeModulesBundle` and `deps.alwaysBundle` are mutually exclusive options and cannot be used together.");
|
|
49
|
-
if (
|
|
54
|
+
if (onlyBundle != null && onlyBundle !== false) onlyBundle = toArray(onlyBundle);
|
|
50
55
|
return {
|
|
51
56
|
neverBundle,
|
|
52
57
|
alwaysBundle,
|
|
53
|
-
|
|
58
|
+
onlyBundle,
|
|
54
59
|
skipNodeModulesBundle
|
|
55
60
|
};
|
|
56
61
|
}
|
|
@@ -72,7 +77,7 @@ async function parseBundledDep(moduleId) {
|
|
|
72
77
|
};
|
|
73
78
|
} catch {}
|
|
74
79
|
}
|
|
75
|
-
function DepPlugin({ pkg, deps: { alwaysBundle,
|
|
80
|
+
function DepPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBundle }, logger, nameLabel }, tsdownBundle) {
|
|
76
81
|
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
77
82
|
return {
|
|
78
83
|
name: "tsdown:external",
|
|
@@ -108,12 +113,12 @@ function DepPlugin({ pkg, deps: { alwaysBundle, onlyAllowBundle, skipNodeModules
|
|
|
108
113
|
}
|
|
109
114
|
}
|
|
110
115
|
debug("found deps in bundle: %o", deps);
|
|
111
|
-
if (
|
|
112
|
-
const errors = Array.from(deps).filter((dep) => !matchPattern(dep,
|
|
116
|
+
if (onlyBundle) {
|
|
117
|
+
const errors = Array.from(deps).filter((dep) => !matchPattern(dep, onlyBundle)).map((dep) => `${yellow(dep)} is located in ${blue`node_modules`} but is not included in ${blue`deps.onlyBundle`} option.\nTo fix this, either add it to ${blue`deps.onlyBundle`}, declare it as a production or peer dependency in your package.json, or externalize it manually.\nImported by\n${[...importers.get(dep) || []].map((s) => `- ${underline(s)}`).join("\n")}`);
|
|
113
118
|
if (errors.length) this.error(errors.join("\n\n"));
|
|
114
|
-
const unusedPatterns =
|
|
115
|
-
if (unusedPatterns.length) logger.info(nameLabel, `The following entries in ${blue`deps.
|
|
116
|
-
} else if (
|
|
119
|
+
const unusedPatterns = onlyBundle.filter((pattern) => !Array.from(deps).some((dep) => matchPattern(dep, [pattern])));
|
|
120
|
+
if (unusedPatterns.length) logger.info(nameLabel, `The following entries in ${blue`deps.onlyBundle`} are not used in the bundle:\n${unusedPatterns.map((pattern) => `- ${yellow(pattern)}`).join("\n")}\nConsider removing them to keep your configuration clean.`);
|
|
121
|
+
} else if (onlyBundle == null && deps.size) logger.info(nameLabel, `Hint: consider adding ${blue`deps.onlyBundle`} option to avoid unintended bundling of dependencies, or set ${blue`deps.onlyBundle: false`} to disable this hint.\nSee more at ${underline`https://tsdown.dev/options/dependencies#deps-onlybundle`}\nDetected dependencies in bundle:\n${Array.from(deps).map((dep) => `- ${blue(dep)}`).join("\n")}`);
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as Arrayable, n as Logger, r as globalLogger } from "./logger-BUKd5OJy.mjs";
|
|
2
|
-
import { A as RolldownContext, B as TsdownBundle, C as ChunkAddonObject, D as PackageJsonWithPath, E as OutExtensionObject, H as CopyOptions, I as DepsConfig, L as NoExternalFn, M as ExeOptions, N as SeaConfig, O as PackageType, P as DevtoolsOptions, R as ResolvedDepsConfig, S as ChunkAddonFunction, T as OutExtensionFactory, U as CopyOptionsFn, V as CopyEntry, a as NormalizedFormat, b as AttwOptions, c as TreeshakingOptions, d as UserConfig, f as UserConfigExport, g as ReportOptions, h as Workspace, i as InlineConfig, j as TsdownHooks, k as BuildContext, l as TsdownInputOption, m as WithEnabled, n as DtsOptions, o as ResolvedConfig, p as UserConfigFn, r as Format, s as Sourcemap, t as CIOption, u as UnusedOptions, v as PublintOptions, w as OutExtensionContext, x as ChunkAddon, y as ExportsOptions, z as RolldownChunk } from "./types-
|
|
3
|
-
import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-
|
|
2
|
+
import { A as RolldownContext, B as TsdownBundle, C as ChunkAddonObject, D as PackageJsonWithPath, E as OutExtensionObject, H as CopyOptions, I as DepsConfig, L as NoExternalFn, M as ExeOptions, N as SeaConfig, O as PackageType, P as DevtoolsOptions, R as ResolvedDepsConfig, S as ChunkAddonFunction, T as OutExtensionFactory, U as CopyOptionsFn, V as CopyEntry, a as NormalizedFormat, b as AttwOptions, c as TreeshakingOptions, d as UserConfig, f as UserConfigExport, g as ReportOptions, h as Workspace, i as InlineConfig, j as TsdownHooks, k as BuildContext, l as TsdownInputOption, m as WithEnabled, n as DtsOptions, o as ResolvedConfig, p as UserConfigFn, r as Format, s as Sourcemap, t as CIOption, u as UnusedOptions, v as PublintOptions, w as OutExtensionContext, x as ChunkAddon, y as ExportsOptions, z as RolldownChunk } from "./types-DUxKwUmX.mjs";
|
|
3
|
+
import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-Cz86PxVM.mjs";
|
|
4
4
|
import * as Rolldown from "rolldown";
|
|
5
5
|
|
|
6
6
|
//#region src/build.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as resolveUserConfig, t as mergeConfig } from "./options-
|
|
1
|
+
import { r as resolveUserConfig, t as mergeConfig } from "./options--36H_-x3.mjs";
|
|
2
2
|
import { a as globalLogger } from "./logger-BU0v7CAk.mjs";
|
|
3
3
|
import { defineConfig } from "./config.mjs";
|
|
4
|
-
import { n as buildWithConfigs, t as build } from "./build-
|
|
4
|
+
import { n as buildWithConfigs, t as build } from "./build-CpOl_krN.mjs";
|
|
5
5
|
import { t as enableDebug } from "./debug-C4FmgzkJ.mjs";
|
|
6
6
|
import * as Rolldown from "rolldown";
|
|
7
7
|
export { Rolldown, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
|
|
@@ -3,8 +3,8 @@ const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
|
3
3
|
import { a as pkgExists, c as resolveRegex, l as slash, n as importWithError, r as matchPattern, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
|
|
4
4
|
import { a as lowestCommonAncestor, i as fsStat, n as fsExists, o as stripExtname, r as fsRemove } from "./fs-Dd6Htx2P.mjs";
|
|
5
5
|
import { a as globalLogger, i as getNameLabel, n as createLogger, r as generateColor } from "./logger-BU0v7CAk.mjs";
|
|
6
|
-
import { i as resolveDepsConfig, n as formatBytes, t as detectIndentation } from "./format-
|
|
7
|
-
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
import { i as resolveDepsConfig, n as formatBytes, t as detectIndentation } from "./format-DPVBd8E4.mjs";
|
|
7
|
+
import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import process, { env } from "node:process";
|
|
10
10
|
import { blue, bold, dim, red, underline } from "ansis";
|
|
@@ -34,6 +34,10 @@ async function cleanOutDir(configs) {
|
|
|
34
34
|
const removes = /* @__PURE__ */ new Set();
|
|
35
35
|
for (const config of configs) {
|
|
36
36
|
if (config.devtools && (config.devtools.clean ?? true)) config.clean.push("node_modules/.rolldown");
|
|
37
|
+
if (config.exe) {
|
|
38
|
+
const exeOutDir = path.resolve(config.cwd, config.exe.outDir || "build");
|
|
39
|
+
config.clean.push(exeOutDir);
|
|
40
|
+
}
|
|
37
41
|
if (!config.clean.length) continue;
|
|
38
42
|
const files = await glob(config.clean, {
|
|
39
43
|
cwd: config.cwd,
|
|
@@ -67,22 +71,22 @@ async function cleanChunks(outDir, chunks) {
|
|
|
67
71
|
}
|
|
68
72
|
//#endregion
|
|
69
73
|
//#region src/features/entry.ts
|
|
70
|
-
async function resolveEntry(logger, entry, cwd, color, nameLabel) {
|
|
74
|
+
async function resolveEntry(logger, entry, cwd, color, nameLabel, root) {
|
|
71
75
|
if (!entry || Object.keys(entry).length === 0) {
|
|
72
76
|
const defaultEntry = path.resolve(cwd, "src/index.ts");
|
|
73
77
|
if (await fsExists(defaultEntry)) entry = { index: defaultEntry };
|
|
74
78
|
else throw new Error(`${nameLabel} No input files, try "tsdown <your-file>" or create src/index.ts`);
|
|
75
79
|
}
|
|
76
|
-
const entryMap = await toObjectEntry(entry, cwd);
|
|
80
|
+
const [entryMap, computedRoot] = await toObjectEntry(entry, cwd, root);
|
|
77
81
|
const entries = Object.values(entryMap);
|
|
78
82
|
if (entries.length === 0) throw new Error(`${nameLabel} Cannot find entry: ${JSON.stringify(entry)}`);
|
|
79
83
|
logger.info(nameLabel, `entry: ${color(entries.map((entry) => path.relative(cwd, entry)).join(", "))}`);
|
|
80
|
-
return entryMap;
|
|
84
|
+
return [entryMap, computedRoot];
|
|
81
85
|
}
|
|
82
|
-
function toObjectEntry(entry, cwd) {
|
|
86
|
+
function toObjectEntry(entry, cwd, root) {
|
|
83
87
|
if (typeof entry === "string") entry = [entry];
|
|
84
88
|
if (!Array.isArray(entry)) return resolveObjectEntry(entry, cwd);
|
|
85
|
-
return resolveArrayEntry(entry, cwd);
|
|
89
|
+
return resolveArrayEntry(entry, cwd, root);
|
|
86
90
|
}
|
|
87
91
|
function isGlobEntry(entry) {
|
|
88
92
|
if (!entry) return false;
|
|
@@ -91,7 +95,7 @@ function isGlobEntry(entry) {
|
|
|
91
95
|
return Object.keys(entry).some((key) => key.includes("*"));
|
|
92
96
|
}
|
|
93
97
|
async function resolveObjectEntry(entries, cwd) {
|
|
94
|
-
return Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
|
|
98
|
+
return [Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
|
|
95
99
|
if (!key.includes("*")) {
|
|
96
100
|
if (Array.isArray(value)) throw new TypeError(`Object entry "${key}" cannot have an array value when the key is not a glob pattern.`);
|
|
97
101
|
return [[key, value]];
|
|
@@ -111,9 +115,9 @@ async function resolveObjectEntry(entries, cwd) {
|
|
|
111
115
|
}
|
|
112
116
|
if (valueGlobBase === void 0) throw new Error(`Cannot determine base directory for value glob patterns of key "${key}".`);
|
|
113
117
|
return files.map((file) => [slash(key.replaceAll("*", stripExtname(path.relative(valueGlobBase, file)))), path.resolve(cwd, file)]);
|
|
114
|
-
}))).flat());
|
|
118
|
+
}))).flat()), cwd];
|
|
115
119
|
}
|
|
116
|
-
async function resolveArrayEntry(entries, cwd) {
|
|
120
|
+
async function resolveArrayEntry(entries, cwd, root) {
|
|
117
121
|
const stringEntries = [];
|
|
118
122
|
const objectEntries = [];
|
|
119
123
|
for (const e of entries) if (typeof e === "string") stringEntries.push(e);
|
|
@@ -126,11 +130,16 @@ async function resolveArrayEntry(entries, cwd) {
|
|
|
126
130
|
absolute: true
|
|
127
131
|
})).map((file) => path.resolve(file));
|
|
128
132
|
else resolvedEntries = stringEntries;
|
|
129
|
-
const
|
|
133
|
+
const computedRoot = root || lowestCommonAncestor(...resolvedEntries);
|
|
134
|
+
const base = root && !isGlob ? path.relative(cwd, root) || "." : computedRoot;
|
|
130
135
|
const arrayEntryMap = Object.fromEntries(resolvedEntries.map((file) => {
|
|
131
136
|
return [slash(stripExtname(path.relative(base, file))), file];
|
|
132
137
|
}));
|
|
133
|
-
|
|
138
|
+
const resolvedObjectEntries = await Promise.all(objectEntries.map(async (entry) => {
|
|
139
|
+
const [entryMap] = await resolveObjectEntry(entry, cwd);
|
|
140
|
+
return entryMap;
|
|
141
|
+
}));
|
|
142
|
+
return [Object.assign({}, arrayEntryMap, ...resolvedObjectEntries), computedRoot];
|
|
134
143
|
}
|
|
135
144
|
//#endregion
|
|
136
145
|
//#region src/features/exe.ts
|
|
@@ -170,7 +179,9 @@ function resolveOutputFileName(exe, chunk, bundledFile, target, suffix) {
|
|
|
170
179
|
}
|
|
171
180
|
async function buildSingleExe(config, bundledFile, outputFile, executable, target) {
|
|
172
181
|
const exe = config.exe;
|
|
173
|
-
const
|
|
182
|
+
const exeOutDir = path.resolve(config.cwd, exe.outDir || "build");
|
|
183
|
+
await mkdir(exeOutDir, { recursive: true });
|
|
184
|
+
const outputPath = path.join(exeOutDir, outputFile);
|
|
174
185
|
debug$3("Building SEA executable: %s -> %s", bundledFile, outputPath);
|
|
175
186
|
const t = performance.now();
|
|
176
187
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-sea-"));
|
|
@@ -601,7 +612,7 @@ const parseEnv = process.getBuiltinModule("node:util").parseEnv;
|
|
|
601
612
|
* @private
|
|
602
613
|
*/
|
|
603
614
|
async function resolveUserConfig(userConfig, inlineConfig) {
|
|
604
|
-
let { entry, format, plugins = [], clean = true, logLevel = "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, publint = false, attw = false, fromVite, alias, tsconfig, report = true, target, env = {}, envFile, envPrefix = "TSDOWN_", copy, publicDir, hash = true, cwd = process.cwd(), name, workspace, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, css, injectStyle, fixedExtension = platform === "node", devtools = false, write = true, exe = false } = userConfig;
|
|
615
|
+
let { entry, format, plugins = [], clean = true, logLevel = "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, publint = false, attw = false, fromVite, alias, tsconfig, report = true, target, env = {}, envFile, envPrefix = "TSDOWN_", copy, publicDir, hash = true, cwd = process.cwd(), name, workspace, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, root, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, css, injectStyle, fixedExtension = platform === "node", devtools = false, write = true, exe = false } = userConfig;
|
|
605
616
|
const pkg = await readPackageJson(cwd);
|
|
606
617
|
if (workspace) name ||= pkg?.name;
|
|
607
618
|
const color = generateColor(name);
|
|
@@ -623,7 +634,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
|
|
|
623
634
|
outDir = path.resolve(cwd, outDir);
|
|
624
635
|
clean = resolveClean(clean, outDir, cwd);
|
|
625
636
|
const rawEntry = entry;
|
|
626
|
-
const resolvedEntry = await resolveEntry(logger, entry, cwd, color, nameLabel);
|
|
637
|
+
const [resolvedEntry, resolvedRoot] = await resolveEntry(logger, entry, cwd, color, nameLabel, root ? path.resolve(cwd, root) : void 0);
|
|
627
638
|
target = resolveTarget(logger, target, color, pkg, nameLabel);
|
|
628
639
|
tsconfig = await resolveTsconfig(logger, tsconfig, cwd, color, nameLabel);
|
|
629
640
|
publint = resolveFeatureOption(publint, {});
|
|
@@ -719,6 +730,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
|
|
|
719
730
|
publint,
|
|
720
731
|
rawEntry,
|
|
721
732
|
report,
|
|
733
|
+
root: resolvedRoot,
|
|
722
734
|
shims,
|
|
723
735
|
sourcemap,
|
|
724
736
|
target,
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as Logger } from "./logger-BUKd5OJy.mjs";
|
|
2
|
-
import { B as TsdownBundle, F as DepPlugin, _ as ReportPlugin } from "./types-
|
|
2
|
+
import { B as TsdownBundle, F as DepPlugin, _ as ReportPlugin } from "./types-DUxKwUmX.mjs";
|
|
3
3
|
import { Plugin } from "rolldown";
|
|
4
4
|
|
|
5
5
|
//#region src/features/node-protocol.d.ts
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as DepPlugin } from "./format-
|
|
2
|
-
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-
|
|
1
|
+
import { r as DepPlugin } from "./format-DPVBd8E4.mjs";
|
|
2
|
+
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-seL2bosb.mjs";
|
|
3
3
|
export { DepPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire as __cjs_createRequire } from "node:module";
|
|
3
3
|
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
4
|
import { a as globalLogger } from "./logger-BU0v7CAk.mjs";
|
|
5
|
-
import { t as version } from "./package-
|
|
5
|
+
import { t as version } from "./package-B0nLlt00.mjs";
|
|
6
6
|
import { t as enableDebug } from "./debug-C4FmgzkJ.mjs";
|
|
7
7
|
import module from "node:module";
|
|
8
8
|
import process from "node:process";
|
|
@@ -17,10 +17,10 @@ cli.help().version(version);
|
|
|
17
17
|
cli.command("[...files]", "Bundle files", {
|
|
18
18
|
ignoreOptionDefaultValue: true,
|
|
19
19
|
allowUnknownOptions: true
|
|
20
|
-
}).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("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [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("--no-write", "Disable writing files to disk, incompatible with watch mode").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("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).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("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
|
|
20
|
+
}).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("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [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("--no-write", "Disable writing files to disk, incompatible with watch mode").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("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).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("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
|
|
21
21
|
globalLogger.level = flags.logLevel || "info";
|
|
22
22
|
globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
23
|
-
const { build } = await import("./build-
|
|
23
|
+
const { build } = await import("./build-B1oBkI4C.mjs");
|
|
24
24
|
if (input.length > 0) flags.entry = input;
|
|
25
25
|
await build(flags);
|
|
26
26
|
});
|
|
@@ -72,6 +72,10 @@ interface DepsConfig {
|
|
|
72
72
|
*
|
|
73
73
|
* Note: Be sure to include all required sub-dependencies as well.
|
|
74
74
|
*/
|
|
75
|
+
onlyBundle?: Arrayable<string | RegExp> | false;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use {@link onlyBundle} instead.
|
|
78
|
+
*/
|
|
75
79
|
onlyAllowBundle?: Arrayable<string | RegExp> | false;
|
|
76
80
|
/**
|
|
77
81
|
* Skip bundling all `node_modules` dependencies.
|
|
@@ -85,14 +89,14 @@ interface DepsConfig {
|
|
|
85
89
|
interface ResolvedDepsConfig {
|
|
86
90
|
neverBundle?: ExternalOption;
|
|
87
91
|
alwaysBundle?: NoExternalFn;
|
|
88
|
-
|
|
92
|
+
onlyBundle?: Array<string | RegExp> | false;
|
|
89
93
|
skipNodeModulesBundle: boolean;
|
|
90
94
|
}
|
|
91
95
|
declare function DepPlugin({
|
|
92
96
|
pkg,
|
|
93
97
|
deps: {
|
|
94
98
|
alwaysBundle,
|
|
95
|
-
|
|
99
|
+
onlyBundle,
|
|
96
100
|
skipNodeModulesBundle
|
|
97
101
|
},
|
|
98
102
|
logger,
|
|
@@ -123,6 +127,11 @@ interface ExeOptions extends ExeExtensionOptions {
|
|
|
123
127
|
* For example, do not include `.exe`, platform suffixes, or architecture suffixes.
|
|
124
128
|
*/
|
|
125
129
|
fileName?: string | ((chunk: RolldownChunk) => string);
|
|
130
|
+
/**
|
|
131
|
+
* Output directory for executables.
|
|
132
|
+
* @default 'build'
|
|
133
|
+
*/
|
|
134
|
+
outDir?: string;
|
|
126
135
|
}
|
|
127
136
|
/**
|
|
128
137
|
* See also [Node.js SEA Documentation](https://nodejs.org/api/single-executable-applications.html#generating-single-executable-applications-with---build-sea)
|
|
@@ -730,7 +739,7 @@ interface UserConfig {
|
|
|
730
739
|
*/
|
|
731
740
|
noExternal?: Arrayable<string | RegExp> | NoExternalFn;
|
|
732
741
|
/**
|
|
733
|
-
* @deprecated Use `deps.
|
|
742
|
+
* @deprecated Use `deps.onlyBundle` instead.
|
|
734
743
|
*/
|
|
735
744
|
inlineOnly?: Arrayable<string | RegExp> | false;
|
|
736
745
|
/**
|
|
@@ -920,6 +929,15 @@ interface UserConfig {
|
|
|
920
929
|
*/
|
|
921
930
|
unbundle?: boolean;
|
|
922
931
|
/**
|
|
932
|
+
* Specifies the root directory of input files, similar to TypeScript's `rootDir`.
|
|
933
|
+
* This determines the output directory structure.
|
|
934
|
+
*
|
|
935
|
+
* By default, the root is computed as the common base directory of all entry files.
|
|
936
|
+
*
|
|
937
|
+
* @see https://www.typescriptlang.org/tsconfig/#rootDir
|
|
938
|
+
*/
|
|
939
|
+
root?: string;
|
|
940
|
+
/**
|
|
923
941
|
* @deprecated Use `unbundle` instead.
|
|
924
942
|
* @default true
|
|
925
943
|
*/
|
|
@@ -1123,7 +1141,8 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
|
|
|
1123
1141
|
nodeProtocol: "strip" | boolean;
|
|
1124
1142
|
logger: Logger;
|
|
1125
1143
|
ignoreWatch: Array<string | RegExp>;
|
|
1126
|
-
deps: ResolvedDepsConfig;
|
|
1144
|
+
deps: ResolvedDepsConfig; /** Resolved root directory of input files */
|
|
1145
|
+
root: string;
|
|
1127
1146
|
dts: false | DtsOptions;
|
|
1128
1147
|
report: false | ReportOptions;
|
|
1129
1148
|
tsconfig: false | string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as noop, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
|
|
2
2
|
import { n as fsExists } from "./fs-Dd6Htx2P.mjs";
|
|
3
3
|
import { o as prettyFormat } from "./logger-BU0v7CAk.mjs";
|
|
4
|
-
import { n as formatBytes } from "./format-
|
|
4
|
+
import { n as formatBytes } from "./format-DPVBd8E4.mjs";
|
|
5
5
|
import { builtinModules } from "node:module";
|
|
6
6
|
import { chmod } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.2",
|
|
5
5
|
"description": "The Elegant Bundler for Libraries",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"publint": "^0.3.0",
|
|
53
53
|
"typescript": "^5.0.0",
|
|
54
54
|
"unplugin-unused": "^0.5.0",
|
|
55
|
-
"@tsdown/css": "0.21.
|
|
56
|
-
"@tsdown/exe": "0.21.
|
|
55
|
+
"@tsdown/css": "0.21.2",
|
|
56
|
+
"@tsdown/exe": "0.21.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@arethetypeswrong/core": {
|
|
@@ -87,14 +87,14 @@
|
|
|
87
87
|
"import-without-cache": "^0.2.5",
|
|
88
88
|
"obug": "^2.1.1",
|
|
89
89
|
"picomatch": "^4.0.3",
|
|
90
|
-
"rolldown": "1.0.0-rc.
|
|
91
|
-
"rolldown-plugin-dts": "^0.22.
|
|
90
|
+
"rolldown": "1.0.0-rc.9",
|
|
91
|
+
"rolldown-plugin-dts": "^0.22.5",
|
|
92
92
|
"semver": "^7.7.4",
|
|
93
93
|
"tinyexec": "^1.0.2",
|
|
94
94
|
"tinyglobby": "^0.2.15",
|
|
95
95
|
"tree-kill": "^1.2.2",
|
|
96
96
|
"unconfig-core": "^7.5.0",
|
|
97
|
-
"unrun": "^0.2.
|
|
97
|
+
"unrun": "^0.2.32"
|
|
98
98
|
},
|
|
99
99
|
"inlinedDependencies": {
|
|
100
100
|
"package-manager-detector": "1.6.0",
|
|
@@ -108,10 +108,10 @@
|
|
|
108
108
|
"@sxzz/eslint-config": "^7.8.3",
|
|
109
109
|
"@sxzz/prettier-config": "^2.3.1",
|
|
110
110
|
"@sxzz/test-utils": "^0.5.15",
|
|
111
|
-
"@types/node": "^25.
|
|
111
|
+
"@types/node": "^25.4.0",
|
|
112
112
|
"@types/picomatch": "^4.0.2",
|
|
113
113
|
"@types/semver": "^7.7.1",
|
|
114
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
114
|
+
"@typescript/native-preview": "7.0.0-dev.20260311.1",
|
|
115
115
|
"@unocss/eslint-plugin": "^66.6.6",
|
|
116
116
|
"@vitejs/devtools": "^0.0.0-alpha.33",
|
|
117
117
|
"@vitest/coverage-v8": "^4.0.18",
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
"prettier": "^3.8.1",
|
|
130
130
|
"publint": "^0.3.18",
|
|
131
131
|
"rolldown-plugin-dts-snapshot": "^0.4.0",
|
|
132
|
-
"rolldown-plugin-require-cjs": "^0.
|
|
133
|
-
"sass": "^1.
|
|
132
|
+
"rolldown-plugin-require-cjs": "^0.4.0",
|
|
133
|
+
"sass": "^1.98.0",
|
|
134
134
|
"typescript": "~5.9.3",
|
|
135
135
|
"unocss": "^66.6.6",
|
|
136
136
|
"unplugin-ast": "^0.16.0",
|
|
@@ -139,9 +139,9 @@
|
|
|
139
139
|
"unplugin-vue": "^7.1.1",
|
|
140
140
|
"vite": "^8.0.0-beta.18",
|
|
141
141
|
"vitest": "^4.0.18",
|
|
142
|
-
"vue": "^3.5.
|
|
143
|
-
"@tsdown/css": "0.21.
|
|
144
|
-
"@tsdown/exe": "0.21.
|
|
142
|
+
"vue": "^3.5.30",
|
|
143
|
+
"@tsdown/css": "0.21.2",
|
|
144
|
+
"@tsdown/exe": "0.21.2"
|
|
145
145
|
},
|
|
146
146
|
"prettier": "@sxzz/prettier-config",
|
|
147
147
|
"scripts": {
|
package/dist/build-DHPfiKA-.mjs
DELETED