tsdown 0.21.4 → 0.21.6
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-C1dAKhHj.mjs +2 -0
- package/dist/{build-CoLhkNXE.mjs → build-MDnn2xGL.mjs} +35 -18
- package/dist/{config-D9p_BCF3.d.mts → config-CgCV7Kdu.d.mts} +3 -3
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/{format-DPVBd8E4.mjs → format-DXnmiQIy.mjs} +89 -36
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{options-DoRzOC0d.mjs → options-B1Ye5hV8.mjs} +68 -9
- package/dist/{package-BV2VRL7Z.mjs → package-lMx2nkh2.mjs} +1 -1
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +3 -3
- package/dist/run.mjs +4 -4
- package/dist/{types-D2Jnze_i.d.mts → types-qUp2BCEq.d.mts} +38 -4
- package/dist/{watch-CS1xCZMR.mjs → watch-BHPVmWIr.mjs} +2 -2
- package/package.json +22 -23
- package/dist/build-dhDyu66J.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 } 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-
|
|
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, t as mergeConfig, u as cleanChunks } from "./options-B1Ye5hV8.mjs";
|
|
5
5
|
import { r as fsRemove } from "./fs-Dd6Htx2P.mjs";
|
|
6
6
|
import { a as globalLogger, t as LogLevels } from "./logger-BU0v7CAk.mjs";
|
|
7
|
-
import { a as getShimsInject, r as
|
|
8
|
-
import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, s as copy, t as WatchPlugin } from "./watch-
|
|
9
|
-
import { t as version } from "./package-
|
|
7
|
+
import { a as getShimsInject, r as DepsPlugin } from "./format-DXnmiQIy.mjs";
|
|
8
|
+
import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, s as copy, t as WatchPlugin } from "./watch-BHPVmWIr.mjs";
|
|
9
|
+
import { t as version } from "./package-lMx2nkh2.mjs";
|
|
10
10
|
import { mkdtemp, readFile, readdir, writeFile } from "node:fs/promises";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import process from "node:process";
|
|
@@ -14,7 +14,7 @@ import { bold, dim, green } from "ansis";
|
|
|
14
14
|
import { createDebug } from "obug";
|
|
15
15
|
import { glob } from "tinyglobby";
|
|
16
16
|
import readline from "node:readline";
|
|
17
|
-
import { RE_CSS, RE_DTS, RE_JS } from "rolldown-plugin-dts/
|
|
17
|
+
import { RE_CSS, RE_DTS, RE_JS, filename_js_to_dts } from "rolldown-plugin-dts/internal";
|
|
18
18
|
import { tmpdir } from "node:os";
|
|
19
19
|
const satisfies = __cjs_require("semver/functions/satisfies.js");
|
|
20
20
|
import { exec, x } from "tinyexec";
|
|
@@ -34,10 +34,7 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
34
34
|
"**/t?(e)mp/**"
|
|
35
35
|
];
|
|
36
36
|
async function resolveWorkspace(config, inlineConfig) {
|
|
37
|
-
const normalized =
|
|
38
|
-
...config,
|
|
39
|
-
...inlineConfig
|
|
40
|
-
};
|
|
37
|
+
const normalized = mergeConfig(config, inlineConfig);
|
|
41
38
|
const rootCwd = normalized.cwd || process.cwd();
|
|
42
39
|
let { workspace } = normalized;
|
|
43
40
|
if (!workspace) return {
|
|
@@ -68,15 +65,12 @@ async function resolveWorkspace(config, inlineConfig) {
|
|
|
68
65
|
...inlineConfig,
|
|
69
66
|
config: workspaceConfig,
|
|
70
67
|
cwd
|
|
71
|
-
}, cwd);
|
|
68
|
+
}, cwd, normalized);
|
|
72
69
|
if (file) {
|
|
73
70
|
debug$4("loaded workspace config file %s", file);
|
|
74
71
|
files.push(file);
|
|
75
72
|
} else debug$4("no workspace config file found in %s", cwd);
|
|
76
|
-
return configs.map((config) => (
|
|
77
|
-
...normalized,
|
|
78
|
-
...config
|
|
79
|
-
}));
|
|
73
|
+
return configs.map((config) => mergeConfig(normalized, config));
|
|
80
74
|
}))).flat(),
|
|
81
75
|
files
|
|
82
76
|
};
|
|
@@ -466,12 +460,13 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
466
460
|
const { alias, checks: { legacyCjs, ...checks } = {}, cjsDefault, cwd, deps: { neverBundle }, devtools, dts, entry, env, globImport, loader, logger, nameLabel, nodeProtocol, platform, plugins: userPlugins, report, shims, target, treeshake, tsconfig, unused, watch } = config;
|
|
467
461
|
const plugins = [];
|
|
468
462
|
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
469
|
-
if (config.pkg || config.deps.skipNodeModulesBundle) plugins.push(
|
|
463
|
+
if (config.pkg || config.deps.skipNodeModulesBundle) plugins.push(DepsPlugin(config, bundle));
|
|
470
464
|
if (dts) {
|
|
471
465
|
const { dts: dtsPlugin } = await import("rolldown-plugin-dts");
|
|
466
|
+
const { cjsReexport: _, ...dtsPluginOptions } = dts;
|
|
472
467
|
const options = {
|
|
473
468
|
tsconfig,
|
|
474
|
-
...
|
|
469
|
+
...dtsPluginOptions
|
|
475
470
|
};
|
|
476
471
|
if (format === "es") plugins.push(dtsPlugin(options));
|
|
477
472
|
else if (cjsDts) plugins.push(dtsPlugin({
|
|
@@ -479,7 +474,9 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
479
474
|
emitDtsOnly: true,
|
|
480
475
|
cjsDefault
|
|
481
476
|
}));
|
|
477
|
+
else if (dts.cjsReexport && isDualFormat) plugins.push(CjsDtsReexportPlugin());
|
|
482
478
|
}
|
|
479
|
+
let cssPostPlugins;
|
|
483
480
|
if (!cjsDts) {
|
|
484
481
|
if (unused) {
|
|
485
482
|
const { Unused } = await importWithError("unplugin-unused");
|
|
@@ -490,7 +487,9 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
490
487
|
}
|
|
491
488
|
if (pkgExists("@tsdown/css")) {
|
|
492
489
|
const { CssPlugin } = await import("@tsdown/css");
|
|
493
|
-
|
|
490
|
+
const cssPlugins = CssPlugin(config, { logger });
|
|
491
|
+
plugins.push(...cssPlugins.pre);
|
|
492
|
+
cssPostPlugins = cssPlugins.post;
|
|
494
493
|
} else plugins.push(CssGuardPlugin());
|
|
495
494
|
plugins.push(ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
|
|
496
495
|
if (globImport) plugins.push(importGlobPlugin({ root: cwd }));
|
|
@@ -498,6 +497,7 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
498
497
|
if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(config, cjsDts, isDualFormat));
|
|
499
498
|
if (watch) plugins.push(WatchPlugin(configFiles, bundle));
|
|
500
499
|
if (!cjsDts) plugins.push(userPlugins);
|
|
500
|
+
if (cssPostPlugins) plugins.push(...cssPostPlugins);
|
|
501
501
|
const define = {
|
|
502
502
|
...config.define,
|
|
503
503
|
...Object.keys(env).reduce((acc, key) => {
|
|
@@ -587,6 +587,23 @@ function handlePluginInspect(plugins) {
|
|
|
587
587
|
else return `"rolldown plugin: ${plugins.name}"`;
|
|
588
588
|
};
|
|
589
589
|
}
|
|
590
|
+
function CjsDtsReexportPlugin() {
|
|
591
|
+
return {
|
|
592
|
+
name: "tsdown:cjs-dts-reexport",
|
|
593
|
+
generateBundle(_options, bundle) {
|
|
594
|
+
for (const chunk of Object.values(bundle)) {
|
|
595
|
+
if (chunk.type !== "chunk") continue;
|
|
596
|
+
if (!chunk.fileName.endsWith(".cjs") && !chunk.fileName.endsWith(".js")) continue;
|
|
597
|
+
const content = `export * from './${path.basename(chunk.fileName.replace(RE_JS, ".d.mts"))}'\n`;
|
|
598
|
+
this.emitFile({
|
|
599
|
+
type: "prebuilt-chunk",
|
|
600
|
+
fileName: filename_js_to_dts(chunk.fileName),
|
|
601
|
+
code: content
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
}
|
|
590
607
|
function CssGuardPlugin() {
|
|
591
608
|
return {
|
|
592
609
|
name: "tsdown:css-guard",
|
|
@@ -798,7 +815,7 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
|
|
|
798
815
|
});
|
|
799
816
|
if (debugRolldownConfigDir) await debugBuildOptions(debugRolldownConfigDir, config.name, format, buildOptions);
|
|
800
817
|
const configs = [buildOptions];
|
|
801
|
-
if (format === "cjs" && dts) configs.push(await getBuildOptions(config, format, configFiles, bundle, true, isDualFormat));
|
|
818
|
+
if (format === "cjs" && dts && (!isDualFormat || !dts.cjsReexport)) configs.push(await getBuildOptions(config, format, configFiles, bundle, true, isDualFormat));
|
|
802
819
|
return configs;
|
|
803
820
|
}
|
|
804
821
|
async function postBuild() {
|
|
@@ -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-qUp2BCEq.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/config/options.d.ts
|
|
4
4
|
/**
|
|
@@ -8,8 +8,8 @@ import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as Resolve
|
|
|
8
8
|
* @private
|
|
9
9
|
*/
|
|
10
10
|
declare function resolveUserConfig(userConfig: UserConfig, inlineConfig: InlineConfig): Promise<ResolvedConfig[]>;
|
|
11
|
-
declare function mergeConfig(defaults: UserConfig, overrides: UserConfig): UserConfig;
|
|
12
|
-
declare function mergeConfig(defaults: InlineConfig, overrides: InlineConfig): InlineConfig;
|
|
11
|
+
declare function mergeConfig(defaults: UserConfig, ...overrides: UserConfig[]): UserConfig;
|
|
12
|
+
declare function mergeConfig(defaults: InlineConfig, ...overrides: InlineConfig[]): InlineConfig;
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/config.d.ts
|
|
15
15
|
/**
|
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-qUp2BCEq.mjs";
|
|
2
|
+
import { n as mergeConfig, t as defineConfig } from "./config-CgCV7Kdu.mjs";
|
|
3
3
|
export { UserConfig, UserConfigExport, UserConfigFn, defineConfig, mergeConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { readFile } from "node:fs/promises";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { blue, underline, yellow } from "ansis";
|
|
6
6
|
import { createDebug } from "obug";
|
|
7
|
-
import { RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/
|
|
7
|
+
import { RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/internal";
|
|
8
8
|
import { and, id, importerId, include } from "rolldown/filter";
|
|
9
9
|
//#region src/features/shims.ts
|
|
10
10
|
const shimFile = path.resolve(import.meta.dirname, "..", "esm-shims.js");
|
|
@@ -16,7 +16,7 @@ function getShimsInject(format, platform) {
|
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/features/deps.ts
|
|
19
|
-
const debug = createDebug("tsdown:
|
|
19
|
+
const debug = createDebug("tsdown:deps");
|
|
20
20
|
function resolveDepsConfig(config, logger) {
|
|
21
21
|
let { neverBundle, alwaysBundle, onlyBundle, skipNodeModulesBundle = false } = config.deps || {};
|
|
22
22
|
if (config.external != null) {
|
|
@@ -59,39 +59,34 @@ function resolveDepsConfig(config, logger) {
|
|
|
59
59
|
skipNodeModulesBundle
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
const slashed = slash(moduleId);
|
|
64
|
-
const lastNmIdx = slashed.lastIndexOf("/node_modules/");
|
|
65
|
-
if (lastNmIdx === -1) return;
|
|
66
|
-
const parts = slashed.slice(lastNmIdx + 14).split("/");
|
|
67
|
-
let name;
|
|
68
|
-
if (parts[0][0] === "@") name = `${parts[0]}/${parts[1]}`;
|
|
69
|
-
else name = parts[0];
|
|
70
|
-
const root = slashed.slice(0, lastNmIdx + 14 + name.length);
|
|
71
|
-
try {
|
|
72
|
-
const json = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
|
73
|
-
return {
|
|
74
|
-
name,
|
|
75
|
-
pkgName: json.name,
|
|
76
|
-
version: json.version
|
|
77
|
-
};
|
|
78
|
-
} catch {}
|
|
79
|
-
}
|
|
80
|
-
function DepPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBundle }, logger, nameLabel }, tsdownBundle) {
|
|
62
|
+
function DepsPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBundle }, logger, nameLabel }, tsdownBundle) {
|
|
81
63
|
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
82
64
|
return {
|
|
83
|
-
name: "tsdown:
|
|
65
|
+
name: "tsdown:deps",
|
|
84
66
|
resolveId: {
|
|
85
67
|
filter: [include(and(id(/^[^.]/), importerId(/./)))],
|
|
86
68
|
async handler(id, importer, extraOptions) {
|
|
87
69
|
if (extraOptions.isEntry) return;
|
|
88
|
-
const
|
|
89
|
-
|
|
70
|
+
const resolved = await this.resolve(id, importer, {
|
|
71
|
+
...extraOptions,
|
|
72
|
+
skipSelf: true
|
|
73
|
+
});
|
|
74
|
+
let shouldExternal = await externalStrategy(id, importer, resolved);
|
|
75
|
+
if (Array.isArray(shouldExternal)) {
|
|
76
|
+
debug("custom resolved id for %o -> %o", id, shouldExternal[1]);
|
|
77
|
+
id = shouldExternal[1];
|
|
78
|
+
shouldExternal = shouldExternal[0];
|
|
79
|
+
}
|
|
80
|
+
const moduleSideEffects = isBuiltin(id) ? false : void 0;
|
|
90
81
|
debug("shouldExternal: %o = %o", id, shouldExternal);
|
|
91
82
|
if (shouldExternal === true || shouldExternal === "absolute") return {
|
|
92
83
|
id,
|
|
93
84
|
external: shouldExternal,
|
|
94
|
-
moduleSideEffects
|
|
85
|
+
moduleSideEffects
|
|
86
|
+
};
|
|
87
|
+
if (resolved) return {
|
|
88
|
+
...resolved,
|
|
89
|
+
moduleSideEffects
|
|
95
90
|
};
|
|
96
91
|
}
|
|
97
92
|
},
|
|
@@ -103,7 +98,7 @@ function DepPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBundl
|
|
|
103
98
|
for (const chunk of Object.values(bundle)) {
|
|
104
99
|
if (chunk.type === "asset") continue;
|
|
105
100
|
for (const id of chunk.moduleIds) {
|
|
106
|
-
const parsed = await
|
|
101
|
+
const parsed = await readBundledDepInfo(id);
|
|
107
102
|
if (!parsed) continue;
|
|
108
103
|
deps.add(parsed.name);
|
|
109
104
|
if (!tsdownBundle.inlinedDeps.has(parsed.pkgName)) tsdownBundle.inlinedDeps.set(parsed.pkgName, /* @__PURE__ */ new Set());
|
|
@@ -124,29 +119,87 @@ function DepPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBundl
|
|
|
124
119
|
};
|
|
125
120
|
/**
|
|
126
121
|
* - `true`: always external
|
|
122
|
+
* - `[true, resolvedId]`: external with custom resolved ID
|
|
127
123
|
* - `false`: skip, let other plugins handle it
|
|
128
124
|
* - `'absolute'`: external as absolute path
|
|
129
125
|
* - `'no-external'`: skip, but mark as non-external for inlineOnly check
|
|
130
126
|
*/
|
|
131
|
-
async function externalStrategy(
|
|
127
|
+
async function externalStrategy(id, importer, resolved) {
|
|
132
128
|
if (id === shimFile) return false;
|
|
133
129
|
if (alwaysBundle?.(id, importer)) return "no-external";
|
|
134
|
-
if (skipNodeModulesBundle)
|
|
135
|
-
const resolved = await context.resolve(id, importer, extraOptions);
|
|
136
|
-
if (resolved && (resolved.external || RE_NODE_MODULES.test(resolved.id))) return true;
|
|
137
|
-
}
|
|
130
|
+
if (skipNodeModulesBundle && resolved && (resolved.external || RE_NODE_MODULES.test(resolved.id))) return true;
|
|
138
131
|
if (deps) {
|
|
139
|
-
if (deps.includes(id) || deps.some((dep) => id.startsWith(`${dep}/`)))
|
|
132
|
+
if (deps.includes(id) || deps.some((dep) => id.startsWith(`${dep}/`))) {
|
|
133
|
+
const resolvedDep = await resolveDepSubpath(id, resolved);
|
|
134
|
+
return resolvedDep ? [true, resolvedDep] : true;
|
|
135
|
+
}
|
|
140
136
|
if (importer && RE_DTS.test(importer) && !id.startsWith("@types/")) {
|
|
141
|
-
const typesName =
|
|
142
|
-
if (deps.includes(typesName)) return true;
|
|
137
|
+
const typesName = getTypesPackageName(id);
|
|
138
|
+
if (typesName && deps.includes(typesName)) return true;
|
|
143
139
|
}
|
|
144
140
|
}
|
|
145
141
|
return false;
|
|
146
142
|
}
|
|
147
143
|
}
|
|
144
|
+
function parsePackageSpecifier(id) {
|
|
145
|
+
const [first, second] = id.split("/", 3);
|
|
146
|
+
const name = first[0] === "@" && second ? `${first}/${second}` : first;
|
|
147
|
+
return [name, id.slice(name.length)];
|
|
148
|
+
}
|
|
149
|
+
const NODE_MODULES = "/node_modules/";
|
|
150
|
+
function parseNodeModulesPath(id) {
|
|
151
|
+
const slashed = slash(id);
|
|
152
|
+
const lastNmIdx = slashed.lastIndexOf(NODE_MODULES);
|
|
153
|
+
if (lastNmIdx === -1) return;
|
|
154
|
+
const [name, subpath] = parsePackageSpecifier(slashed.slice(lastNmIdx + 14));
|
|
155
|
+
return [
|
|
156
|
+
name,
|
|
157
|
+
subpath,
|
|
158
|
+
slashed.slice(0, lastNmIdx + 14 + name.length)
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
async function readBundledDepInfo(moduleId) {
|
|
162
|
+
const parsed = parseNodeModulesPath(moduleId);
|
|
163
|
+
if (!parsed) return;
|
|
164
|
+
const [name, , root] = parsed;
|
|
165
|
+
try {
|
|
166
|
+
const json = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
|
167
|
+
return {
|
|
168
|
+
name,
|
|
169
|
+
pkgName: json.name,
|
|
170
|
+
version: json.version
|
|
171
|
+
};
|
|
172
|
+
} catch {}
|
|
173
|
+
}
|
|
174
|
+
function getTypesPackageName(id) {
|
|
175
|
+
const name = parsePackageSpecifier(id)[0];
|
|
176
|
+
if (!name) return;
|
|
177
|
+
return `@types/${name.replace(/^@/, "").replace("/", "__")}`;
|
|
178
|
+
}
|
|
179
|
+
async function resolveDepSubpath(id, resolved) {
|
|
180
|
+
if (!resolved?.packageJsonPath) return;
|
|
181
|
+
const parts = id.split("/");
|
|
182
|
+
if (parts[0][0] === "@") parts.shift();
|
|
183
|
+
if (parts.length === 1 || parts.at(-1).includes(".")) return;
|
|
184
|
+
let pkgJson;
|
|
185
|
+
try {
|
|
186
|
+
pkgJson = JSON.parse(await readFile(resolved.packageJsonPath, "utf8"));
|
|
187
|
+
} catch {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (pkgJson.exports) return;
|
|
191
|
+
const parsed = parseNodeModulesPath(resolved.id);
|
|
192
|
+
if (!parsed) return;
|
|
193
|
+
const result = parsed[0] + parsed[1];
|
|
194
|
+
if (result === id) return;
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
148
197
|
function getProductionDeps(pkg) {
|
|
149
|
-
return new Set([
|
|
198
|
+
return new Set([
|
|
199
|
+
...Object.keys(pkg.dependencies || {}),
|
|
200
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
201
|
+
...Object.keys(pkg.optionalDependencies || {})
|
|
202
|
+
]);
|
|
150
203
|
}
|
|
151
204
|
//#endregion
|
|
152
205
|
//#region src/utils/format.ts
|
|
@@ -166,4 +219,4 @@ function detectIndentation(jsonText) {
|
|
|
166
219
|
return 2;
|
|
167
220
|
}
|
|
168
221
|
//#endregion
|
|
169
|
-
export { getShimsInject as a, resolveDepsConfig as i, formatBytes as n,
|
|
222
|
+
export { getShimsInject as a, resolveDepsConfig as i, formatBytes as n, DepsPlugin as r, detectIndentation as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as Arrayable, n as Logger, r as globalLogger } from "./logger-DtCm1ySP.mjs";
|
|
2
|
-
import { A as RolldownContext, B as TsdownBundle, C as ChunkAddonObject, D as PackageJsonWithPath, E as OutExtensionObject,
|
|
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, F as DepsConfig, H as CopyOptions, 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-qUp2BCEq.mjs";
|
|
3
|
+
import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-CgCV7Kdu.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-B1Ye5hV8.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-MDnn2xGL.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,7 +3,7 @@ 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-
|
|
6
|
+
import { i as resolveDepsConfig, n as formatBytes, t as detectIndentation } from "./format-DXnmiQIy.mjs";
|
|
7
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";
|
|
@@ -13,7 +13,7 @@ import { createDebug } from "obug";
|
|
|
13
13
|
import { glob, isDynamicPattern } from "tinyglobby";
|
|
14
14
|
import { pathToFileURL } from "node:url";
|
|
15
15
|
const picomatch = __cjs_require("picomatch");
|
|
16
|
-
import { RE_CSS, RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/
|
|
16
|
+
import { RE_CSS, RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/internal";
|
|
17
17
|
import { tmpdir } from "node:os";
|
|
18
18
|
const satisfies = __cjs_require("semver/functions/satisfies.js");
|
|
19
19
|
import { x } from "tinyexec";
|
|
@@ -80,7 +80,7 @@ async function resolveEntry(logger, entry, cwd, color, nameLabel, root) {
|
|
|
80
80
|
const [entryMap, computedRoot] = await toObjectEntry(entry, cwd, root);
|
|
81
81
|
const entries = Object.values(entryMap);
|
|
82
82
|
if (entries.length === 0) throw new Error(`${nameLabel} Cannot find entry: ${JSON.stringify(entry)}`);
|
|
83
|
-
logger.info(nameLabel, `entry: ${color(entries.map((entry) => path.relative(cwd, entry)).join(", "))}`);
|
|
83
|
+
logger.info(nameLabel, `entry: ${color(entries.map((entry) => path.isAbsolute(entry) ? path.relative(cwd, entry) : entry).join(", "))}`);
|
|
84
84
|
return [entryMap, computedRoot];
|
|
85
85
|
}
|
|
86
86
|
function toObjectEntry(entry, cwd, root) {
|
|
@@ -234,10 +234,11 @@ async function buildSingleExe(config, bundledFile, outputFile, executable, targe
|
|
|
234
234
|
//#region src/features/pkg/exports.ts
|
|
235
235
|
async function writeExports(options, chunks, inlinedDeps) {
|
|
236
236
|
const { pkg } = options;
|
|
237
|
-
const { publishExports, ...generated } = await generateExports(pkg, chunks, options, inlinedDeps);
|
|
237
|
+
const { publishExports, bin, ...generated } = await generateExports(pkg, chunks, options, inlinedDeps);
|
|
238
238
|
const updatedPkg = {
|
|
239
239
|
...pkg,
|
|
240
240
|
...generated,
|
|
241
|
+
...bin === void 0 ? {} : { bin },
|
|
241
242
|
packageJsonPath: void 0
|
|
242
243
|
};
|
|
243
244
|
if (publishExports) {
|
|
@@ -255,7 +256,7 @@ function shouldExclude(fileName, exclude) {
|
|
|
255
256
|
return matchPattern(fileName, exclude);
|
|
256
257
|
}
|
|
257
258
|
async function generateExports(pkg, chunks, options, inlinedDeps) {
|
|
258
|
-
let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy, inlinedDependencies: emitInlinedDeps = true }, css, logger } = options;
|
|
259
|
+
let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy, inlinedDependencies: emitInlinedDeps = true, bin }, css, logger, cwd } = options;
|
|
259
260
|
const pkgRoot = path.dirname(pkg.packageJsonPath);
|
|
260
261
|
let main, module, cjsTypes, esmTypes;
|
|
261
262
|
const exportsMap = /* @__PURE__ */ new Map();
|
|
@@ -334,6 +335,7 @@ async function generateExports(pkg, chunks, options, inlinedDeps) {
|
|
|
334
335
|
module: legacy ? module || pkg.module : void 0,
|
|
335
336
|
types: legacy ? cjsTypes || esmTypes || pkg.types : pkg.types,
|
|
336
337
|
exports,
|
|
338
|
+
bin: generateBin(bin, pkg, chunks, pkgRoot, logger, cwd),
|
|
337
339
|
inlinedDependencies: emitInlinedDeps ? inlinedDeps : void 0,
|
|
338
340
|
publishExports
|
|
339
341
|
};
|
|
@@ -375,6 +377,60 @@ function hasExportsTypes(pkg) {
|
|
|
375
377
|
}
|
|
376
378
|
return false;
|
|
377
379
|
}
|
|
380
|
+
const RE_SHEBANG = /^#!.*/;
|
|
381
|
+
function generateBin(bin, pkg, chunks, pkgRoot, logger, cwd) {
|
|
382
|
+
if (!bin) return;
|
|
383
|
+
if (bin === true || typeof bin === "string") {
|
|
384
|
+
if (!pkg.name) throw new Error("Package name is required when using string form for `bin`");
|
|
385
|
+
const binName = pkg.name[0] === "@" ? pkg.name.split("/", 2)[1] : pkg.name;
|
|
386
|
+
if (bin === true) {
|
|
387
|
+
let detected;
|
|
388
|
+
const seen = /* @__PURE__ */ new Set();
|
|
389
|
+
for (const format of ["es", "cjs"]) {
|
|
390
|
+
const formatChunks = chunks[format];
|
|
391
|
+
if (!formatChunks) continue;
|
|
392
|
+
for (const chunk of formatChunks) {
|
|
393
|
+
if (chunk.type !== "chunk" || !chunk.isEntry || !chunk.facadeModuleId) continue;
|
|
394
|
+
if (!RE_SHEBANG.test(chunk.code)) continue;
|
|
395
|
+
if (seen.has(chunk.facadeModuleId)) continue;
|
|
396
|
+
seen.add(chunk.facadeModuleId);
|
|
397
|
+
if (detected) throw new Error("Multiple entry chunks with shebangs found. Use `exports.bin: { name: \"./src/file.ts\" }` to specify which one to use.");
|
|
398
|
+
detected = join(pkgRoot, chunk.outDir, slash(chunk.fileName));
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (detected == null) {
|
|
402
|
+
logger.warn("`exports.bin` is true but no entry chunks with shebangs were found");
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
return { [binName]: detected };
|
|
406
|
+
}
|
|
407
|
+
if (typeof bin === "string") {
|
|
408
|
+
const match = findChunkBySource(bin);
|
|
409
|
+
if (!match) throw new Error(`Could not find output chunk for bin entry "${bin}"`);
|
|
410
|
+
return { [binName]: match };
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const result = {};
|
|
414
|
+
for (const [cmdName, sourcePath] of Object.entries(bin)) {
|
|
415
|
+
const match = findChunkBySource(sourcePath);
|
|
416
|
+
if (!match) throw new Error(`Could not find output chunk for bin entry "${cmdName}": "${sourcePath}"`);
|
|
417
|
+
result[cmdName] = match;
|
|
418
|
+
}
|
|
419
|
+
return result;
|
|
420
|
+
function findChunkBySource(sourcePath) {
|
|
421
|
+
const resolved = path.resolve(cwd, sourcePath);
|
|
422
|
+
for (const format of ["es", "cjs"]) {
|
|
423
|
+
const formatChunks = chunks[format];
|
|
424
|
+
if (!formatChunks) continue;
|
|
425
|
+
for (const chunk of formatChunks) {
|
|
426
|
+
if (chunk.type !== "chunk" || !chunk.isEntry) continue;
|
|
427
|
+
if (chunk.facadeModuleId !== resolved) continue;
|
|
428
|
+
if (!RE_SHEBANG.test(chunk.code)) logger.warn(`Bin entry "${sourcePath}" does not contain a shebang line`);
|
|
429
|
+
return join(pkgRoot, chunk.outDir, slash(chunk.fileName));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
378
434
|
function getExportName(chunk) {
|
|
379
435
|
const normalizedName = slash(chunk.fileName);
|
|
380
436
|
let name = stripExtname(normalizedName);
|
|
@@ -501,7 +557,7 @@ async function loadViteConfig(prefix, cwd, configLoader) {
|
|
|
501
557
|
return resolved;
|
|
502
558
|
}
|
|
503
559
|
const configPrefix = "tsdown.config";
|
|
504
|
-
async function loadConfigFile(inlineConfig, workspace) {
|
|
560
|
+
async function loadConfigFile(inlineConfig, workspace, rootConfig) {
|
|
505
561
|
let cwd = inlineConfig.cwd || process.cwd();
|
|
506
562
|
let overrideConfig = false;
|
|
507
563
|
let { config: filePath } = inlineConfig;
|
|
@@ -550,7 +606,10 @@ async function loadConfigFile(inlineConfig, workspace) {
|
|
|
550
606
|
({config: exported, source: file} = result);
|
|
551
607
|
globalLogger.info(`config file: ${underline(file)}`, loader === "native" ? "" : `(${loader})`);
|
|
552
608
|
exported = await exported;
|
|
553
|
-
if (typeof exported === "function") exported = await exported(inlineConfig, {
|
|
609
|
+
if (typeof exported === "function") exported = await exported(inlineConfig, {
|
|
610
|
+
ci: isInCi,
|
|
611
|
+
rootConfig
|
|
612
|
+
});
|
|
554
613
|
}
|
|
555
614
|
exported = toArray(exported);
|
|
556
615
|
if (exported.length === 0) exported.push({});
|
|
@@ -769,8 +828,8 @@ const defu = createDefu((obj, key, value) => {
|
|
|
769
828
|
return true;
|
|
770
829
|
}
|
|
771
830
|
});
|
|
772
|
-
function mergeConfig(defaults, overrides) {
|
|
773
|
-
return defu(overrides, defaults);
|
|
831
|
+
function mergeConfig(defaults, ...overrides) {
|
|
832
|
+
return defu(...overrides.toReversed(), defaults);
|
|
774
833
|
}
|
|
775
834
|
async function mergeUserOptions(defaults, user, args) {
|
|
776
835
|
const userOutputOptions = typeof user === "function" ? await user(defaults, ...args) : user;
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as Logger } from "./logger-DtCm1ySP.mjs";
|
|
2
|
-
import { B as TsdownBundle,
|
|
2
|
+
import { B as TsdownBundle, I as DepsPlugin, _ as ReportPlugin } from "./types-qUp2BCEq.mjs";
|
|
3
3
|
import { Plugin } from "rolldown";
|
|
4
4
|
|
|
5
5
|
//#region src/features/node-protocol.d.ts
|
|
@@ -18,4 +18,4 @@ declare function WatchPlugin(configFiles: string[], {
|
|
|
18
18
|
chunks
|
|
19
19
|
}: TsdownBundle): Plugin;
|
|
20
20
|
//#endregion
|
|
21
|
-
export {
|
|
21
|
+
export { DepsPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-
|
|
3
|
-
export {
|
|
1
|
+
import { r as DepsPlugin } from "./format-DXnmiQIy.mjs";
|
|
2
|
+
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-BHPVmWIr.mjs";
|
|
3
|
+
export { DepsPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
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-lMx2nkh2.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";
|
|
9
|
-
import {
|
|
9
|
+
import { blue, hex, yellow } from "ansis";
|
|
10
10
|
import { x } from "tinyexec";
|
|
11
11
|
import { VERSION } from "rolldown";
|
|
12
12
|
const lt = __cjs_require("semver/functions/lt.js");
|
|
@@ -19,8 +19,8 @@ cli.command("[...files]", "Bundle files", {
|
|
|
19
19
|
allowUnknownOptions: true
|
|
20
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
|
-
globalLogger.info(`tsdown
|
|
23
|
-
const { build } = await import("./build-
|
|
22
|
+
globalLogger.info(`${blue`tsdown v${version}`} powered by ${hex("#ff7e17")`rolldown v${VERSION}`}`);
|
|
23
|
+
const { build } = await import("./build-C1dAKhHj.mjs");
|
|
24
24
|
if (input.length > 0) flags.entry = input;
|
|
25
25
|
await build(flags);
|
|
26
26
|
});
|
|
@@ -3,11 +3,11 @@ import { BuildOptions, ChecksOptions, ExternalOption, InputOptions, InternalModu
|
|
|
3
3
|
import { Hookable } from "hookable";
|
|
4
4
|
import { Buffer } from "node:buffer";
|
|
5
5
|
import * as _tsdown_css0 from "@tsdown/css";
|
|
6
|
-
import { Options as DtsOptions } from "rolldown-plugin-dts";
|
|
7
6
|
import { StartOptions } from "@vitejs/devtools/cli-commands";
|
|
8
7
|
import { ExeExtensionOptions } from "@tsdown/exe";
|
|
9
8
|
import { CheckPackageOptions } from "@arethetypeswrong/core";
|
|
10
9
|
import { Options } from "publint";
|
|
10
|
+
import { Options as Options$1 } from "rolldown-plugin-dts";
|
|
11
11
|
import { Options as UnusedOptions } from "unplugin-unused";
|
|
12
12
|
|
|
13
13
|
//#region src/features/copy.d.ts
|
|
@@ -60,7 +60,7 @@ interface DepsConfig {
|
|
|
60
60
|
*/
|
|
61
61
|
neverBundle?: ExternalOption;
|
|
62
62
|
/**
|
|
63
|
-
* Force dependencies to be bundled, even if they are in `dependencies` or `
|
|
63
|
+
* Force dependencies to be bundled, even if they are in `dependencies`, `peerDependencies`, or `optionalDependencies`.
|
|
64
64
|
*/
|
|
65
65
|
alwaysBundle?: Arrayable<string | RegExp> | NoExternalFn;
|
|
66
66
|
/**
|
|
@@ -92,7 +92,7 @@ interface ResolvedDepsConfig {
|
|
|
92
92
|
onlyBundle?: Array<string | RegExp> | false;
|
|
93
93
|
skipNodeModulesBundle: boolean;
|
|
94
94
|
}
|
|
95
|
-
declare function
|
|
95
|
+
declare function DepsPlugin({
|
|
96
96
|
pkg,
|
|
97
97
|
deps: {
|
|
98
98
|
alwaysBundle,
|
|
@@ -638,6 +638,22 @@ interface ExportsOptions {
|
|
|
638
638
|
* @see {@link https://github.com/e18e/ecosystem-issues/issues/237}
|
|
639
639
|
*/
|
|
640
640
|
inlinedDependencies?: boolean;
|
|
641
|
+
/**
|
|
642
|
+
* Auto-generate the `bin` field in package.json.
|
|
643
|
+
*
|
|
644
|
+
* - `true`: Auto-detect entry chunks with shebangs. Uses package name (without scope) as bin name.
|
|
645
|
+
* Errors if multiple shebang entries are found.
|
|
646
|
+
* - `string`: Source file path to use as the bin entry. Bin name defaults to package name (without scope).
|
|
647
|
+
* - `Record<string, string>`: Map of bin command names to source file paths.
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* bin: true
|
|
651
|
+
* @example
|
|
652
|
+
* bin: './src/cli.ts'
|
|
653
|
+
* @example
|
|
654
|
+
* bin: { tool: './src/cli-tool.ts' }
|
|
655
|
+
*/
|
|
656
|
+
bin?: boolean | string | Record<string, string>;
|
|
641
657
|
}
|
|
642
658
|
//#endregion
|
|
643
659
|
//#region src/features/pkg/publint.d.ts
|
|
@@ -668,6 +684,23 @@ interface ReportOptions {
|
|
|
668
684
|
declare function ReportPlugin(config: ResolvedConfig, cjsDts?: boolean, isDualFormat?: boolean): Plugin;
|
|
669
685
|
//#endregion
|
|
670
686
|
//#region src/config/types.d.ts
|
|
687
|
+
interface DtsOptions extends Options$1 {
|
|
688
|
+
/**
|
|
689
|
+
* When building dual ESM+CJS formats, generate a `.d.cts` re-export stub
|
|
690
|
+
* instead of running a full second TypeScript compilation pass.
|
|
691
|
+
*
|
|
692
|
+
* The stub re-exports everything from the corresponding `.d.mts` file,
|
|
693
|
+
* ensuring CJS and ESM consumers share the same type declarations. This
|
|
694
|
+
* eliminates the TypeScript "dual module hazard" where separate `.d.cts`
|
|
695
|
+
* and `.d.mts` declarations cause `TS2352` ("neither type sufficiently
|
|
696
|
+
* overlaps") errors when casting between types derived from the same class.
|
|
697
|
+
*
|
|
698
|
+
* Only applies when building both `esm` and `cjs` formats simultaneously.
|
|
699
|
+
*
|
|
700
|
+
* @default false
|
|
701
|
+
*/
|
|
702
|
+
cjsReexport?: boolean;
|
|
703
|
+
}
|
|
671
704
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
672
705
|
type Format = ModuleFormat;
|
|
673
706
|
type NormalizedFormat = InternalModuleFormat;
|
|
@@ -1128,6 +1161,7 @@ interface InlineConfig extends UserConfig {
|
|
|
1128
1161
|
}
|
|
1129
1162
|
type UserConfigFn = (inlineConfig: InlineConfig, context: {
|
|
1130
1163
|
ci: boolean;
|
|
1164
|
+
rootConfig?: UserConfig;
|
|
1131
1165
|
}) => Awaitable<Arrayable<UserConfig>>;
|
|
1132
1166
|
type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
|
|
1133
1167
|
type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "injectStyle" | "removeNodeProtocol" | "external" | "noExternal" | "inlineOnly" | "skipNodeModulesBundle" | "logLevel" | "failOnWarn" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks" | "css">, {
|
|
@@ -1154,4 +1188,4 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
|
|
|
1154
1188
|
exe: false | ExeOptions;
|
|
1155
1189
|
}>;
|
|
1156
1190
|
//#endregion
|
|
1157
|
-
export { RolldownContext as A, TsdownBundle as B, ChunkAddonObject as C, PackageJsonWithPath as D, OutExtensionObject as E,
|
|
1191
|
+
export { RolldownContext as A, TsdownBundle as B, ChunkAddonObject as C, PackageJsonWithPath as D, OutExtensionObject as E, DepsConfig as F, CopyOptions as H, DepsPlugin as I, NoExternalFn as L, ExeOptions as M, SeaConfig as N, PackageType as O, DevtoolsOptions as P, ResolvedDepsConfig as R, ChunkAddonFunction as S, OutExtensionFactory as T, CopyOptionsFn as U, CopyEntry as V, ReportPlugin as _, NormalizedFormat as a, AttwOptions as b, TreeshakingOptions as c, UserConfig as d, UserConfigExport as f, ReportOptions as g, Workspace as h, InlineConfig as i, TsdownHooks as j, BuildContext as k, TsdownInputOption as l, WithEnabled as m, DtsOptions as n, ResolvedConfig as o, UserConfigFn as p, Format as r, Sourcemap as s, CIOption as t, UnusedOptions as u, PublintOptions as v, OutExtensionContext as w, ChunkAddon as x, ExportsOptions as y, RolldownChunk as z };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { i as noop, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
|
|
2
2
|
import { n as fsExists, t as fsCopy } 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-DXnmiQIy.mjs";
|
|
5
5
|
import { builtinModules } from "node:module";
|
|
6
6
|
import { chmod } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { bold, dim, green, underline } from "ansis";
|
|
9
9
|
import { createDebug } from "obug";
|
|
10
10
|
import { glob, isDynamicPattern } from "tinyglobby";
|
|
11
|
-
import { RE_DTS } from "rolldown-plugin-dts/
|
|
11
|
+
import { RE_DTS } from "rolldown-plugin-dts/internal";
|
|
12
12
|
import { promisify } from "node:util";
|
|
13
13
|
import { Buffer } from "node:buffer";
|
|
14
14
|
import { brotliCompress, gzip } from "node:zlib";
|
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.6",
|
|
5
5
|
"description": "The Elegant Bundler for Libraries",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@arethetypeswrong/core": "^0.18.1",
|
|
51
51
|
"@vitejs/devtools": "*",
|
|
52
52
|
"publint": "^0.3.0",
|
|
53
|
-
"typescript": "^5.0.0",
|
|
53
|
+
"typescript": "^5.0.0 || ^6.0.0",
|
|
54
54
|
"unplugin-unused": "^0.5.0",
|
|
55
|
-
"@tsdown/css": "0.21.
|
|
56
|
-
"@tsdown/exe": "0.21.
|
|
55
|
+
"@tsdown/css": "0.21.6",
|
|
56
|
+
"@tsdown/exe": "0.21.6"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@arethetypeswrong/core": {
|
|
@@ -86,15 +86,15 @@
|
|
|
86
86
|
"hookable": "^6.1.0",
|
|
87
87
|
"import-without-cache": "^0.2.5",
|
|
88
88
|
"obug": "^2.1.1",
|
|
89
|
-
"picomatch": "^4.0.
|
|
90
|
-
"rolldown": "1.0.0-rc.
|
|
91
|
-
"rolldown-plugin-dts": "^0.
|
|
89
|
+
"picomatch": "^4.0.4",
|
|
90
|
+
"rolldown": "1.0.0-rc.12",
|
|
91
|
+
"rolldown-plugin-dts": "^0.23.0",
|
|
92
92
|
"semver": "^7.7.4",
|
|
93
93
|
"tinyexec": "^1.0.4",
|
|
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.34"
|
|
98
98
|
},
|
|
99
99
|
"inlinedDependencies": {
|
|
100
100
|
"is-in-ci": "2.0.0",
|
|
@@ -103,24 +103,23 @@
|
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@arethetypeswrong/core": "^0.18.2",
|
|
106
|
-
"@publint/pack": "^0.1.4",
|
|
107
106
|
"@sxzz/eslint-config": "^7.8.3",
|
|
108
107
|
"@sxzz/prettier-config": "^2.3.1",
|
|
109
108
|
"@sxzz/test-utils": "^0.5.15",
|
|
110
109
|
"@types/node": "^25.5.0",
|
|
111
110
|
"@types/picomatch": "^4.0.2",
|
|
112
111
|
"@types/semver": "^7.7.1",
|
|
113
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
114
|
-
"@unocss/eslint-plugin": "^66.6.
|
|
115
|
-
"@vitejs/devtools": "^0.1.
|
|
116
|
-
"@vitest/coverage-v8": "^4.1.
|
|
117
|
-
"@vitest/ui": "^4.1.
|
|
112
|
+
"@typescript/native-preview": "7.0.0-dev.20260326.1",
|
|
113
|
+
"@unocss/eslint-plugin": "^66.6.7",
|
|
114
|
+
"@vitejs/devtools": "^0.1.11",
|
|
115
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
116
|
+
"@vitest/ui": "^4.1.2",
|
|
118
117
|
"@vueuse/core": "^14.2.1",
|
|
119
118
|
"bumpp": "^11.0.1",
|
|
120
119
|
"dedent": "^1.7.2",
|
|
121
|
-
"eslint": "^10.0
|
|
120
|
+
"eslint": "^10.1.0",
|
|
122
121
|
"is-in-ci": "^2.0.0",
|
|
123
|
-
"memfs": "^4.
|
|
122
|
+
"memfs": "^4.57.1",
|
|
124
123
|
"package-manager-detector": "^1.6.0",
|
|
125
124
|
"pkg-types": "^2.3.0",
|
|
126
125
|
"postcss": "^8.5.8",
|
|
@@ -130,17 +129,17 @@
|
|
|
130
129
|
"rolldown-plugin-dts-snapshot": "^0.4.0",
|
|
131
130
|
"rolldown-plugin-require-cjs": "^0.4.0",
|
|
132
131
|
"sass": "^1.98.0",
|
|
133
|
-
"typescript": "~
|
|
134
|
-
"unocss": "^66.6.
|
|
132
|
+
"typescript": "~6.0.2",
|
|
133
|
+
"unocss": "^66.6.7",
|
|
135
134
|
"unplugin-ast": "^0.16.0",
|
|
136
135
|
"unplugin-raw": "^0.6.4",
|
|
137
136
|
"unplugin-unused": "^0.5.7",
|
|
138
137
|
"unplugin-vue": "^7.1.1",
|
|
139
|
-
"vite": "^8.0.
|
|
140
|
-
"vitest": "^4.1.
|
|
141
|
-
"vue": "^3.5.
|
|
142
|
-
"@tsdown/css": "0.21.
|
|
143
|
-
"@tsdown/exe": "0.21.
|
|
138
|
+
"vite": "^8.0.3",
|
|
139
|
+
"vitest": "^4.1.2",
|
|
140
|
+
"vue": "^3.5.31",
|
|
141
|
+
"@tsdown/css": "0.21.6",
|
|
142
|
+
"@tsdown/exe": "0.21.6"
|
|
144
143
|
},
|
|
145
144
|
"prettier": "@sxzz/prettier-config",
|
|
146
145
|
"scripts": {
|
package/dist/build-dhDyu66J.mjs
DELETED