tsdown 0.21.0 → 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/client.d.ts +5 -0
- package/dist/build-B1oBkI4C.mjs +2 -0
- package/dist/{build-TmLngPCw.mjs → build-CpOl_krN.mjs} +27 -18
- package/dist/{config-BJBl3n_a.d.mts → config-Cz86PxVM.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/{format-CM79ZE77.mjs → format-DPVBd8E4.mjs} +19 -57
- package/dist/fs-Dd6Htx2P.mjs +46 -0
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -3
- package/dist/internal.d.mts +12 -0
- package/dist/internal.mjs +3 -0
- package/dist/logger-BUKd5OJy.d.mts +30 -0
- package/dist/{options-DpJJmGDp.mjs → options--36H_-x3.mjs} +38 -19
- package/dist/{package-BzvC5Wbf.mjs → package-B0nLlt00.mjs} +1 -1
- package/dist/plugins.d.mts +2 -1
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +4 -4
- package/dist/{types-DS6cAXR1.d.mts → types-DUxKwUmX.d.mts} +33 -157
- package/dist/{watch-BAbxxJcJ.mjs → watch-seL2bosb.mjs} +2 -1
- package/package.json +23 -19
- package/dist/build-gOkJM1H9.mjs +0 -2
- package/dist/css-CzF_A79W.mjs +0 -21
- package/dist/css.d.mts +0 -29
- package/dist/css.mjs +0 -3
- package/dist/plugin-BQv869Ce.mjs +0 -119
- /package/dist/{debug-tOJ_PtrM.mjs → debug-C4FmgzkJ.mjs} +0 -0
- /package/dist/{detect-DK-FDZQ9.mjs → detect-J1_Vd1yf.mjs} +0 -0
- /package/dist/{index-node-Djp92Gzb.mjs → index-node-Bpsmc0eX.mjs} +0 -0
package/client.d.ts
CHANGED
|
@@ -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
|
-
import { 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 {
|
|
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--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 {
|
|
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";
|
|
@@ -373,7 +373,7 @@ async function bundleDone(bundleByPkg, bundle) {
|
|
|
373
373
|
async function packTarball(packageJsonPath) {
|
|
374
374
|
const pkgDir = path.dirname(packageJsonPath);
|
|
375
375
|
const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
|
|
376
|
-
const [{ detect }, { pack }] = await Promise.all([import("./detect-
|
|
376
|
+
const [{ detect }, { pack }] = await Promise.all([import("./detect-J1_Vd1yf.mjs"), import("./index-node-Bpsmc0eX.mjs")]);
|
|
377
377
|
try {
|
|
378
378
|
const detected = await detect({ cwd: pkgDir });
|
|
379
379
|
if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
|
|
@@ -498,14 +498,11 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
498
498
|
...unused
|
|
499
499
|
}));
|
|
500
500
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
cssPlugin = CssPlugin(config);
|
|
507
|
-
}
|
|
508
|
-
plugins.push(cssPlugin, ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
|
|
501
|
+
if (pkgExists("@tsdown/css")) {
|
|
502
|
+
const { CssPlugin } = await import("@tsdown/css");
|
|
503
|
+
plugins.push(CssPlugin(config, { logger }));
|
|
504
|
+
} else plugins.push(CssGuardPlugin());
|
|
505
|
+
plugins.push(ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
|
|
509
506
|
if (globImport) plugins.push(importGlobPlugin({ root: cwd }));
|
|
510
507
|
}
|
|
511
508
|
if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(config, cjsDts, isDualFormat));
|
|
@@ -550,7 +547,7 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
|
|
|
550
547
|
}, config.inputOptions, [format, { cjsDts }]);
|
|
551
548
|
}
|
|
552
549
|
async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
553
|
-
const { banner, cjsDefault,
|
|
550
|
+
const { banner, cjsDefault, footer, minify, outDir, sourcemap, unbundle } = config;
|
|
554
551
|
const [entryFileNames, chunkFileNames] = resolveChunkFilename(config, inputOptions, format);
|
|
555
552
|
return await mergeUserOptions({
|
|
556
553
|
format: cjsDts ? "es" : format,
|
|
@@ -562,7 +559,7 @@ async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
|
562
559
|
entryFileNames,
|
|
563
560
|
chunkFileNames,
|
|
564
561
|
preserveModules: unbundle,
|
|
565
|
-
preserveModulesRoot: unbundle ?
|
|
562
|
+
preserveModulesRoot: unbundle ? config.root : void 0,
|
|
566
563
|
postBanner: resolveChunkAddon(banner, format),
|
|
567
564
|
postFooter: resolveChunkAddon(footer, format),
|
|
568
565
|
codeSplitting: config.exe ? false : void 0
|
|
@@ -600,6 +597,18 @@ function handlePluginInspect(plugins) {
|
|
|
600
597
|
else return `"rolldown plugin: ${plugins.name}"`;
|
|
601
598
|
};
|
|
602
599
|
}
|
|
600
|
+
function CssGuardPlugin() {
|
|
601
|
+
return {
|
|
602
|
+
name: "tsdown:css-guard",
|
|
603
|
+
transform: {
|
|
604
|
+
order: "post",
|
|
605
|
+
filter: { id: /\.(?:css|less|sass|scss|styl|stylus)$/ },
|
|
606
|
+
handler(_code, id) {
|
|
607
|
+
throw new Error(`CSS file "${id}" was encountered but \`@tsdown/css\` is not installed. Please install it: \`npm install @tsdown/css\``);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
603
612
|
//#endregion
|
|
604
613
|
//#region src/features/shortcuts.ts
|
|
605
614
|
function shortcuts(restart) {
|
|
@@ -754,7 +763,7 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
|
|
|
754
763
|
restart();
|
|
755
764
|
}
|
|
756
765
|
if ((event.event === "create" || event.event === "delete") && config.rawEntry && isGlobEntry(config.rawEntry)) {
|
|
757
|
-
const newEntry = await toObjectEntry(config.rawEntry, config.cwd);
|
|
766
|
+
const [newEntry] = await toObjectEntry(config.rawEntry, config.cwd);
|
|
758
767
|
if (Object.keys(config.entry).toSorted().join("\0") !== Object.keys(newEntry).toSorted().join("\0")) {
|
|
759
768
|
globalLogger.info("Entry files changed, restarting...");
|
|
760
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
|
@@ -1,54 +1,11 @@
|
|
|
1
1
|
import { c as resolveRegex, l as slash, r as matchPattern, u as toArray } from "./general-CRszZCrY.mjs";
|
|
2
2
|
import { isBuiltin } from "node:module";
|
|
3
|
-
import {
|
|
3
|
+
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
7
|
import { RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
|
|
8
8
|
import { and, id, importerId, include } from "rolldown/filter";
|
|
9
|
-
//#region src/utils/fs.ts
|
|
10
|
-
function fsExists(path) {
|
|
11
|
-
return access(path).then(() => true, () => false);
|
|
12
|
-
}
|
|
13
|
-
function fsStat(path) {
|
|
14
|
-
return stat(path).catch(() => null);
|
|
15
|
-
}
|
|
16
|
-
function fsRemove(path) {
|
|
17
|
-
return rm(path, {
|
|
18
|
-
force: true,
|
|
19
|
-
recursive: true
|
|
20
|
-
}).catch(() => {});
|
|
21
|
-
}
|
|
22
|
-
function fsCopy(from, to) {
|
|
23
|
-
return cp(from, to, {
|
|
24
|
-
recursive: true,
|
|
25
|
-
force: true
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function lowestCommonAncestor(...filepaths) {
|
|
29
|
-
if (filepaths.length === 0) return "";
|
|
30
|
-
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
|
31
|
-
filepaths = filepaths.map(path.normalize);
|
|
32
|
-
const [first, ...rest] = filepaths;
|
|
33
|
-
let ancestor = first.split(path.sep);
|
|
34
|
-
for (const filepath of rest) {
|
|
35
|
-
const directories = filepath.split(path.sep, ancestor.length);
|
|
36
|
-
let index = 0;
|
|
37
|
-
for (const directory of directories) if (directory === ancestor[index]) index += 1;
|
|
38
|
-
else {
|
|
39
|
-
ancestor = ancestor.slice(0, index);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
ancestor = ancestor.slice(0, index);
|
|
43
|
-
}
|
|
44
|
-
return ancestor.length <= 1 && ancestor[0] === "" ? path.sep + ancestor[0] : ancestor.join(path.sep);
|
|
45
|
-
}
|
|
46
|
-
function stripExtname(filePath) {
|
|
47
|
-
const ext = path.extname(filePath);
|
|
48
|
-
if (!ext.length) return filePath;
|
|
49
|
-
return filePath.slice(0, -ext.length);
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
9
|
//#region src/features/shims.ts
|
|
53
10
|
const shimFile = path.resolve(import.meta.dirname, "..", "esm-shims.js");
|
|
54
11
|
function getShimsInject(format, platform) {
|
|
@@ -61,7 +18,7 @@ function getShimsInject(format, platform) {
|
|
|
61
18
|
//#region src/features/deps.ts
|
|
62
19
|
const debug = createDebug("tsdown:dep");
|
|
63
20
|
function resolveDepsConfig(config, logger) {
|
|
64
|
-
let { neverBundle, alwaysBundle,
|
|
21
|
+
let { neverBundle, alwaysBundle, onlyBundle, skipNodeModulesBundle = false } = config.deps || {};
|
|
65
22
|
if (config.external != null) {
|
|
66
23
|
if (neverBundle != null) throw new TypeError("`external` is deprecated. Cannot be used with `deps.neverBundle`.");
|
|
67
24
|
logger?.warn("`external` is deprecated. Use `deps.neverBundle` instead.");
|
|
@@ -72,10 +29,15 @@ function resolveDepsConfig(config, logger) {
|
|
|
72
29
|
logger?.warn("`noExternal` is deprecated. Use `deps.alwaysBundle` instead.");
|
|
73
30
|
alwaysBundle = config.noExternal;
|
|
74
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
|
+
}
|
|
75
37
|
if (config.inlineOnly != null) {
|
|
76
|
-
if (
|
|
77
|
-
logger?.warn("`inlineOnly` is deprecated. Use `deps.
|
|
78
|
-
|
|
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;
|
|
79
41
|
}
|
|
80
42
|
if (config.skipNodeModulesBundle != null) {
|
|
81
43
|
if (config.deps?.skipNodeModulesBundle != null) throw new TypeError("`skipNodeModulesBundle` is deprecated. Cannot be used with `deps.skipNodeModulesBundle`.");
|
|
@@ -89,11 +51,11 @@ function resolveDepsConfig(config, logger) {
|
|
|
89
51
|
alwaysBundle = (id) => matchPattern(id, alwaysBundlePatterns);
|
|
90
52
|
}
|
|
91
53
|
if (skipNodeModulesBundle && alwaysBundle != null) throw new TypeError("`deps.skipNodeModulesBundle` and `deps.alwaysBundle` are mutually exclusive options and cannot be used together.");
|
|
92
|
-
if (
|
|
54
|
+
if (onlyBundle != null && onlyBundle !== false) onlyBundle = toArray(onlyBundle);
|
|
93
55
|
return {
|
|
94
56
|
neverBundle,
|
|
95
57
|
alwaysBundle,
|
|
96
|
-
|
|
58
|
+
onlyBundle,
|
|
97
59
|
skipNodeModulesBundle
|
|
98
60
|
};
|
|
99
61
|
}
|
|
@@ -115,7 +77,7 @@ async function parseBundledDep(moduleId) {
|
|
|
115
77
|
};
|
|
116
78
|
} catch {}
|
|
117
79
|
}
|
|
118
|
-
function DepPlugin({ pkg, deps: { alwaysBundle,
|
|
80
|
+
function DepPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBundle }, logger, nameLabel }, tsdownBundle) {
|
|
119
81
|
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
120
82
|
return {
|
|
121
83
|
name: "tsdown:external",
|
|
@@ -151,12 +113,12 @@ function DepPlugin({ pkg, deps: { alwaysBundle, onlyAllowBundle, skipNodeModules
|
|
|
151
113
|
}
|
|
152
114
|
}
|
|
153
115
|
debug("found deps in bundle: %o", deps);
|
|
154
|
-
if (
|
|
155
|
-
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")}`);
|
|
156
118
|
if (errors.length) this.error(errors.join("\n\n"));
|
|
157
|
-
const unusedPatterns =
|
|
158
|
-
if (unusedPatterns.length) logger.info(nameLabel, `The following entries in ${blue`deps.
|
|
159
|
-
} 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")}`);
|
|
160
122
|
}
|
|
161
123
|
}
|
|
162
124
|
};
|
|
@@ -204,4 +166,4 @@ function detectIndentation(jsonText) {
|
|
|
204
166
|
return 2;
|
|
205
167
|
}
|
|
206
168
|
//#endregion
|
|
207
|
-
export { getShimsInject as a,
|
|
169
|
+
export { getShimsInject as a, resolveDepsConfig as i, formatBytes as n, DepPlugin as r, detectIndentation as t };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { access, cp, rm, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/utils/fs.ts
|
|
4
|
+
function fsExists(path) {
|
|
5
|
+
return access(path).then(() => true, () => false);
|
|
6
|
+
}
|
|
7
|
+
function fsStat(path) {
|
|
8
|
+
return stat(path).catch(() => null);
|
|
9
|
+
}
|
|
10
|
+
function fsRemove(path) {
|
|
11
|
+
return rm(path, {
|
|
12
|
+
force: true,
|
|
13
|
+
recursive: true
|
|
14
|
+
}).catch(() => {});
|
|
15
|
+
}
|
|
16
|
+
function fsCopy(from, to) {
|
|
17
|
+
return cp(from, to, {
|
|
18
|
+
recursive: true,
|
|
19
|
+
force: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function lowestCommonAncestor(...filepaths) {
|
|
23
|
+
if (filepaths.length === 0) return "";
|
|
24
|
+
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
|
25
|
+
filepaths = filepaths.map(path.normalize);
|
|
26
|
+
const [first, ...rest] = filepaths;
|
|
27
|
+
let ancestor = first.split(path.sep);
|
|
28
|
+
for (const filepath of rest) {
|
|
29
|
+
const directories = filepath.split(path.sep, ancestor.length);
|
|
30
|
+
let index = 0;
|
|
31
|
+
for (const directory of directories) if (directory === ancestor[index]) index += 1;
|
|
32
|
+
else {
|
|
33
|
+
ancestor = ancestor.slice(0, index);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
ancestor = ancestor.slice(0, index);
|
|
37
|
+
}
|
|
38
|
+
return ancestor.length <= 1 && ancestor[0] === "" ? path.sep + ancestor[0] : ancestor.join(path.sep);
|
|
39
|
+
}
|
|
40
|
+
function stripExtname(filePath) {
|
|
41
|
+
const ext = path.extname(filePath);
|
|
42
|
+
if (!ext.length) return filePath;
|
|
43
|
+
return filePath.slice(0, -ext.length);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { lowestCommonAncestor as a, fsStat as i, fsExists as n, stripExtname as o, fsRemove as r, fsCopy as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
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-DUxKwUmX.mjs";
|
|
3
|
+
import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-Cz86PxVM.mjs";
|
|
3
4
|
import * as Rolldown from "rolldown";
|
|
4
5
|
|
|
5
6
|
//#region src/build.d.ts
|
|
@@ -18,4 +19,4 @@ declare function buildWithConfigs(configs: ResolvedConfig[], configFiles: string
|
|
|
18
19
|
//#region src/features/debug.d.ts
|
|
19
20
|
declare function enableDebug(debug?: boolean | Arrayable<string>): void;
|
|
20
21
|
//#endregion
|
|
21
|
-
export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn,
|
|
22
|
+
export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DepsConfig, DevtoolsOptions, DtsOptions, ExeOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, ResolvedDepsConfig, Rolldown, RolldownChunk, RolldownContext, SeaConfig, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
|
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-
|
|
5
|
-
import { t as enableDebug } from "./debug-
|
|
4
|
+
import { n as buildWithConfigs, t as build } from "./build-CpOl_krN.mjs";
|
|
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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { n as Logger, o as MarkPartial, s as Overwrite } from "./logger-BUKd5OJy.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/fs.d.ts
|
|
4
|
+
declare function fsExists(path: string): Promise<boolean>;
|
|
5
|
+
declare function fsRemove(path: string): Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/utils/general.d.ts
|
|
8
|
+
declare function toArray<T>(val: T | T[] | null | undefined, defaultValue?: T): T[];
|
|
9
|
+
declare function resolveComma<T extends string>(arr: T[]): T[];
|
|
10
|
+
declare function importWithError<T>(moduleName: string, resolvePaths?: string[]): Promise<T>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { type Logger, type MarkPartial, type Overwrite, fsExists, fsRemove, importWithError, resolveComma, toArray };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InternalModuleFormat } from "rolldown";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/types.d.ts
|
|
4
|
+
type Overwrite<T, U> = Omit<T, keyof U> & U;
|
|
5
|
+
type Awaitable<T> = T | Promise<T>;
|
|
6
|
+
type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
7
|
+
type Arrayable<T> = T | T[];
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/utils/logger.d.ts
|
|
10
|
+
type LogType = "error" | "warn" | "info";
|
|
11
|
+
type LogLevel = LogType | "silent";
|
|
12
|
+
interface LoggerOptions {
|
|
13
|
+
allowClearScreen?: boolean;
|
|
14
|
+
customLogger?: Logger;
|
|
15
|
+
console?: Console;
|
|
16
|
+
failOnWarn?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface Logger {
|
|
19
|
+
level: LogLevel;
|
|
20
|
+
options?: LoggerOptions;
|
|
21
|
+
info: (...args: any[]) => void;
|
|
22
|
+
warn: (...args: any[]) => void;
|
|
23
|
+
warnOnce: (...args: any[]) => void;
|
|
24
|
+
error: (...args: any[]) => void;
|
|
25
|
+
success: (...args: any[]) => void;
|
|
26
|
+
clearScreen: (type: LogType) => void;
|
|
27
|
+
}
|
|
28
|
+
declare const globalLogger: Logger;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Awaitable as a, Arrayable as i, Logger as n, MarkPartial as o, globalLogger as r, Overwrite as s, LogLevel as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
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, c as resolveRegex, l as slash, n as importWithError, r as matchPattern, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
|
|
4
|
-
import {
|
|
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 { n as
|
|
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-"));
|
|
@@ -342,8 +353,8 @@ function exportMeta(exports, all, packageJson) {
|
|
|
342
353
|
if (all) exports["./*"] = "./*";
|
|
343
354
|
else if (packageJson) exports["./package.json"] = "./package.json";
|
|
344
355
|
}
|
|
345
|
-
function exportCss(exports, chunks,
|
|
346
|
-
if (splitting) return;
|
|
356
|
+
function exportCss(exports, chunks, css, pkgRoot) {
|
|
357
|
+
if (css?.splitting) return;
|
|
347
358
|
for (const chunksByFormat of Object.values(chunks)) for (const chunk of chunksByFormat) if (chunk.type === "asset" && RE_CSS.test(chunk.fileName)) {
|
|
348
359
|
const filename = slash(chunk.fileName);
|
|
349
360
|
exports[`./${filename}`] = join(pkgRoot, chunk.outDir, filename);
|
|
@@ -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, 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, {});
|
|
@@ -639,6 +650,13 @@ async function resolveUserConfig(userConfig, inlineConfig) {
|
|
|
639
650
|
if (publint) logger.warn(nameLabel, "publint is enabled but package.json is not found");
|
|
640
651
|
if (attw) logger.warn(nameLabel, "attw is enabled but package.json is not found");
|
|
641
652
|
}
|
|
653
|
+
if (injectStyle != null) if (css?.inject == null) {
|
|
654
|
+
logger.warn(`${blue`injectStyle`} is deprecated. Use ${blue`css.inject`} instead.`);
|
|
655
|
+
css = {
|
|
656
|
+
...css,
|
|
657
|
+
inject: injectStyle
|
|
658
|
+
};
|
|
659
|
+
} else throw new TypeError("`injectStyle` is deprecated. Cannot be used with `css.inject`");
|
|
642
660
|
if (publicDir) if (copy) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
|
|
643
661
|
else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
|
|
644
662
|
envPrefix = toArray(envPrefix);
|
|
@@ -688,7 +706,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
|
|
|
688
706
|
cjsDefault,
|
|
689
707
|
clean,
|
|
690
708
|
copy: publicDir || copy,
|
|
691
|
-
css
|
|
709
|
+
css,
|
|
692
710
|
cwd,
|
|
693
711
|
deps: depsConfig,
|
|
694
712
|
devtools,
|
|
@@ -712,6 +730,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
|
|
|
712
730
|
publint,
|
|
713
731
|
rawEntry,
|
|
714
732
|
report,
|
|
733
|
+
root: resolvedRoot,
|
|
715
734
|
shims,
|
|
716
735
|
sourcemap,
|
|
717
736
|
target,
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as Logger } from "./logger-BUKd5OJy.mjs";
|
|
2
|
+
import { B as TsdownBundle, F as DepPlugin, _ as ReportPlugin } from "./types-DUxKwUmX.mjs";
|
|
2
3
|
import { Plugin } from "rolldown";
|
|
3
4
|
|
|
4
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,8 +2,8 @@
|
|
|
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-
|
|
6
|
-
import { t as enableDebug } from "./debug-
|
|
5
|
+
import { t as version } from "./package-B0nLlt00.mjs";
|
|
6
|
+
import { t as enableDebug } from "./debug-C4FmgzkJ.mjs";
|
|
7
7
|
import module from "node:module";
|
|
8
8
|
import process from "node:process";
|
|
9
9
|
import { dim, yellow } from "ansis";
|
|
@@ -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
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { a as Awaitable, i as Arrayable, n as Logger, o as MarkPartial, s as Overwrite, t as LogLevel } from "./logger-BUKd5OJy.mjs";
|
|
1
2
|
import { BuildOptions, ChecksOptions, ExternalOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, Plugin, TreeshakingOptions } from "rolldown";
|
|
2
3
|
import { Hookable } from "hookable";
|
|
3
4
|
import { Buffer } from "node:buffer";
|
|
5
|
+
import * as _tsdown_css0 from "@tsdown/css";
|
|
4
6
|
import { Options as DtsOptions } from "rolldown-plugin-dts";
|
|
5
7
|
import { StartOptions } from "@vitejs/devtools/cli-commands";
|
|
6
8
|
import { ExeExtensionOptions } from "@tsdown/exe";
|
|
@@ -8,12 +10,6 @@ import { CheckPackageOptions } from "@arethetypeswrong/core";
|
|
|
8
10
|
import { Options } from "publint";
|
|
9
11
|
import { Options as UnusedOptions } from "unplugin-unused";
|
|
10
12
|
|
|
11
|
-
//#region src/utils/types.d.ts
|
|
12
|
-
type Overwrite<T, U> = Omit<T, keyof U> & U;
|
|
13
|
-
type Awaitable<T> = T | Promise<T>;
|
|
14
|
-
type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
15
|
-
type Arrayable<T> = T | T[];
|
|
16
|
-
//#endregion
|
|
17
13
|
//#region src/features/copy.d.ts
|
|
18
14
|
interface CopyEntry {
|
|
19
15
|
/**
|
|
@@ -44,128 +40,6 @@ interface CopyEntry {
|
|
|
44
40
|
type CopyOptions = Arrayable<string | CopyEntry>;
|
|
45
41
|
type CopyOptionsFn = (options: ResolvedConfig) => Awaitable<CopyOptions>;
|
|
46
42
|
//#endregion
|
|
47
|
-
//#region src/features/css/index.d.ts
|
|
48
|
-
interface CssOptions {
|
|
49
|
-
/**
|
|
50
|
-
* Enable/disable CSS code splitting.
|
|
51
|
-
* When set to `false`, all CSS in the entire project will be extracted into a single CSS file.
|
|
52
|
-
* When set to `true`, CSS imported in async JS chunks will be preserved as chunks.
|
|
53
|
-
* @default false
|
|
54
|
-
*/
|
|
55
|
-
splitting?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Specify the name of the CSS file.
|
|
58
|
-
* @default 'style.css'
|
|
59
|
-
*/
|
|
60
|
-
fileName?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Set the target environment for CSS syntax lowering.
|
|
63
|
-
* Accepts esbuild-style target strings (e.g., `'chrome99'`, `'safari16.2'`).
|
|
64
|
-
* Defaults to the top-level `target` option.
|
|
65
|
-
*
|
|
66
|
-
* Requires `@tsdown/css` to be installed.
|
|
67
|
-
*
|
|
68
|
-
* @see https://vite.dev/config/build-options#build-csstarget
|
|
69
|
-
*/
|
|
70
|
-
target?: string | string[] | false;
|
|
71
|
-
/**
|
|
72
|
-
* Options for CSS preprocessors (Sass/Less/Stylus).
|
|
73
|
-
*
|
|
74
|
-
* In addition to options specific to each processor, `additionalData` option
|
|
75
|
-
* can be used to inject extra code for each style content.
|
|
76
|
-
*
|
|
77
|
-
* Requires `@tsdown/css` to be installed.
|
|
78
|
-
*/
|
|
79
|
-
preprocessorOptions?: PreprocessorOptions;
|
|
80
|
-
/**
|
|
81
|
-
* Enable/disable CSS minification.
|
|
82
|
-
*
|
|
83
|
-
* Requires `@tsdown/css` to be installed.
|
|
84
|
-
*
|
|
85
|
-
* @default false
|
|
86
|
-
*/
|
|
87
|
-
minify?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Lightning CSS options for CSS syntax lowering and transformations.
|
|
90
|
-
*
|
|
91
|
-
* Requires `@tsdown/css` to be installed.
|
|
92
|
-
*/
|
|
93
|
-
lightningcss?: LightningCSSOptions;
|
|
94
|
-
/**
|
|
95
|
-
* PostCSS configuration.
|
|
96
|
-
*
|
|
97
|
-
* - `string`: Path to the directory to search for PostCSS config files.
|
|
98
|
-
* - `object`: Inline PostCSS options with optional `plugins` array.
|
|
99
|
-
* - Omitted: Auto-detect PostCSS config from the project root.
|
|
100
|
-
*
|
|
101
|
-
* Only used when `transformer` is `'postcss'`.
|
|
102
|
-
* Requires `postcss` and `@tsdown/css` to be installed.
|
|
103
|
-
*
|
|
104
|
-
* @see https://github.com/postcss/postcss
|
|
105
|
-
*/
|
|
106
|
-
postcss?: PostCSSOptions;
|
|
107
|
-
/**
|
|
108
|
-
* CSS transformer to use. Controls how CSS is processed:
|
|
109
|
-
*
|
|
110
|
-
* - `'lightningcss'` (default): `@import` handled by Lightning CSS
|
|
111
|
-
* `bundleAsync()`, PostCSS is **not** used at all.
|
|
112
|
-
* - `'postcss'`: `@import` handled by `postcss-import`,
|
|
113
|
-
* PostCSS plugins applied, Lightning CSS used only for final
|
|
114
|
-
* targets/minify transform.
|
|
115
|
-
*
|
|
116
|
-
* Requires `@tsdown/css` to be installed.
|
|
117
|
-
*
|
|
118
|
-
* @default 'lightningcss'
|
|
119
|
-
* @see https://vite.dev/config/shared-options#css-transformer
|
|
120
|
-
*/
|
|
121
|
-
transformer?: "postcss" | "lightningcss";
|
|
122
|
-
}
|
|
123
|
-
type PostCSSOptions = string | (Record<string, any> & {
|
|
124
|
-
plugins?: any[];
|
|
125
|
-
});
|
|
126
|
-
interface PreprocessorOptions {
|
|
127
|
-
scss?: SassPreprocessorOptions;
|
|
128
|
-
sass?: SassPreprocessorOptions;
|
|
129
|
-
less?: LessPreprocessorOptions;
|
|
130
|
-
styl?: StylusPreprocessorOptions;
|
|
131
|
-
stylus?: StylusPreprocessorOptions;
|
|
132
|
-
}
|
|
133
|
-
type PreprocessorAdditionalDataResult = string | {
|
|
134
|
-
content: string;
|
|
135
|
-
map?: any;
|
|
136
|
-
};
|
|
137
|
-
type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
|
|
138
|
-
interface SassPreprocessorOptions {
|
|
139
|
-
additionalData?: PreprocessorAdditionalData;
|
|
140
|
-
[key: string]: any;
|
|
141
|
-
}
|
|
142
|
-
interface LessPreprocessorOptions {
|
|
143
|
-
additionalData?: PreprocessorAdditionalData;
|
|
144
|
-
math?: any;
|
|
145
|
-
paths?: string[];
|
|
146
|
-
plugins?: any[];
|
|
147
|
-
[key: string]: any;
|
|
148
|
-
}
|
|
149
|
-
interface StylusPreprocessorOptions {
|
|
150
|
-
additionalData?: PreprocessorAdditionalData;
|
|
151
|
-
define?: Record<string, any>;
|
|
152
|
-
paths?: string[];
|
|
153
|
-
[key: string]: any;
|
|
154
|
-
}
|
|
155
|
-
type LightningCSSOptions = Record<string, any>;
|
|
156
|
-
interface ResolvedCssOptions {
|
|
157
|
-
transformer: "postcss" | "lightningcss";
|
|
158
|
-
splitting: boolean;
|
|
159
|
-
fileName: string;
|
|
160
|
-
minify: boolean;
|
|
161
|
-
target?: string[];
|
|
162
|
-
preprocessorOptions?: PreprocessorOptions;
|
|
163
|
-
lightningcss?: LightningCSSOptions;
|
|
164
|
-
postcss?: PostCSSOptions;
|
|
165
|
-
}
|
|
166
|
-
declare const defaultCssBundleName = "style.css";
|
|
167
|
-
declare function resolveCssOptions(options?: CssOptions, topLevelTarget?: string[]): ResolvedCssOptions;
|
|
168
|
-
//#endregion
|
|
169
43
|
//#region src/utils/chunks.d.ts
|
|
170
44
|
type RolldownChunk = (OutputChunk | OutputAsset) & {
|
|
171
45
|
outDir: string;
|
|
@@ -177,27 +51,6 @@ interface TsdownBundle extends AsyncDisposable {
|
|
|
177
51
|
inlinedDeps: Map<string, Set<string>>;
|
|
178
52
|
}
|
|
179
53
|
//#endregion
|
|
180
|
-
//#region src/utils/logger.d.ts
|
|
181
|
-
type LogType = "error" | "warn" | "info";
|
|
182
|
-
type LogLevel = LogType | "silent";
|
|
183
|
-
interface LoggerOptions {
|
|
184
|
-
allowClearScreen?: boolean;
|
|
185
|
-
customLogger?: Logger;
|
|
186
|
-
console?: Console;
|
|
187
|
-
failOnWarn?: boolean;
|
|
188
|
-
}
|
|
189
|
-
interface Logger {
|
|
190
|
-
level: LogLevel;
|
|
191
|
-
options?: LoggerOptions;
|
|
192
|
-
info: (...args: any[]) => void;
|
|
193
|
-
warn: (...args: any[]) => void;
|
|
194
|
-
warnOnce: (...args: any[]) => void;
|
|
195
|
-
error: (...args: any[]) => void;
|
|
196
|
-
success: (...args: any[]) => void;
|
|
197
|
-
clearScreen: (type: LogType) => void;
|
|
198
|
-
}
|
|
199
|
-
declare const globalLogger: Logger;
|
|
200
|
-
//#endregion
|
|
201
54
|
//#region src/features/deps.d.ts
|
|
202
55
|
type NoExternalFn = (id: string, importer: string | undefined) => boolean | null | undefined | void;
|
|
203
56
|
interface DepsConfig {
|
|
@@ -219,6 +72,10 @@ interface DepsConfig {
|
|
|
219
72
|
*
|
|
220
73
|
* Note: Be sure to include all required sub-dependencies as well.
|
|
221
74
|
*/
|
|
75
|
+
onlyBundle?: Arrayable<string | RegExp> | false;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use {@link onlyBundle} instead.
|
|
78
|
+
*/
|
|
222
79
|
onlyAllowBundle?: Arrayable<string | RegExp> | false;
|
|
223
80
|
/**
|
|
224
81
|
* Skip bundling all `node_modules` dependencies.
|
|
@@ -232,14 +89,14 @@ interface DepsConfig {
|
|
|
232
89
|
interface ResolvedDepsConfig {
|
|
233
90
|
neverBundle?: ExternalOption;
|
|
234
91
|
alwaysBundle?: NoExternalFn;
|
|
235
|
-
|
|
92
|
+
onlyBundle?: Array<string | RegExp> | false;
|
|
236
93
|
skipNodeModulesBundle: boolean;
|
|
237
94
|
}
|
|
238
95
|
declare function DepPlugin({
|
|
239
96
|
pkg,
|
|
240
97
|
deps: {
|
|
241
98
|
alwaysBundle,
|
|
242
|
-
|
|
99
|
+
onlyBundle,
|
|
243
100
|
skipNodeModulesBundle
|
|
244
101
|
},
|
|
245
102
|
logger,
|
|
@@ -270,6 +127,11 @@ interface ExeOptions extends ExeExtensionOptions {
|
|
|
270
127
|
* For example, do not include `.exe`, platform suffixes, or architecture suffixes.
|
|
271
128
|
*/
|
|
272
129
|
fileName?: string | ((chunk: RolldownChunk) => string);
|
|
130
|
+
/**
|
|
131
|
+
* Output directory for executables.
|
|
132
|
+
* @default 'build'
|
|
133
|
+
*/
|
|
134
|
+
outDir?: string;
|
|
273
135
|
}
|
|
274
136
|
/**
|
|
275
137
|
* See also [Node.js SEA Documentation](https://nodejs.org/api/single-executable-applications.html#generating-single-executable-applications-with---build-sea)
|
|
@@ -877,7 +739,7 @@ interface UserConfig {
|
|
|
877
739
|
*/
|
|
878
740
|
noExternal?: Arrayable<string | RegExp> | NoExternalFn;
|
|
879
741
|
/**
|
|
880
|
-
* @deprecated Use `deps.
|
|
742
|
+
* @deprecated Use `deps.onlyBundle` instead.
|
|
881
743
|
*/
|
|
882
744
|
inlineOnly?: Arrayable<string | RegExp> | false;
|
|
883
745
|
/**
|
|
@@ -1067,6 +929,15 @@ interface UserConfig {
|
|
|
1067
929
|
*/
|
|
1068
930
|
unbundle?: boolean;
|
|
1069
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
|
+
/**
|
|
1070
941
|
* @deprecated Use `unbundle` instead.
|
|
1071
942
|
* @default true
|
|
1072
943
|
*/
|
|
@@ -1201,8 +1072,13 @@ interface UserConfig {
|
|
|
1201
1072
|
exports?: WithEnabled<ExportsOptions>;
|
|
1202
1073
|
/**
|
|
1203
1074
|
* **[experimental]** CSS options.
|
|
1075
|
+
* Requires `@tsdown/css` to be installed.
|
|
1076
|
+
*/
|
|
1077
|
+
css?: _tsdown_css0.CssOptions;
|
|
1078
|
+
/**
|
|
1079
|
+
* @deprecated Use `css.inject` instead.
|
|
1204
1080
|
*/
|
|
1205
|
-
|
|
1081
|
+
injectStyle?: boolean;
|
|
1206
1082
|
/**
|
|
1207
1083
|
* @deprecated Alias for `copy`, will be removed in the future.
|
|
1208
1084
|
*/
|
|
@@ -1254,7 +1130,7 @@ type UserConfigFn = (inlineConfig: InlineConfig, context: {
|
|
|
1254
1130
|
ci: boolean;
|
|
1255
1131
|
}) => Awaitable<Arrayable<UserConfig>>;
|
|
1256
1132
|
type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
|
|
1257
|
-
type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "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">, {
|
|
1133
|
+
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">, {
|
|
1258
1134
|
/** Resolved entry map (after glob expansion) */entry: Record<string, string>; /** Original entry config before glob resolution (for watch mode re-globbing) */
|
|
1259
1135
|
rawEntry?: TsdownInputOption;
|
|
1260
1136
|
nameLabel: string | undefined;
|
|
@@ -1265,8 +1141,8 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
|
|
|
1265
1141
|
nodeProtocol: "strip" | boolean;
|
|
1266
1142
|
logger: Logger;
|
|
1267
1143
|
ignoreWatch: Array<string | RegExp>;
|
|
1268
|
-
deps: ResolvedDepsConfig;
|
|
1269
|
-
|
|
1144
|
+
deps: ResolvedDepsConfig; /** Resolved root directory of input files */
|
|
1145
|
+
root: string;
|
|
1270
1146
|
dts: false | DtsOptions;
|
|
1271
1147
|
report: false | ReportOptions;
|
|
1272
1148
|
tsconfig: false | string;
|
|
@@ -1278,4 +1154,4 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
|
|
|
1278
1154
|
exe: false | ExeOptions;
|
|
1279
1155
|
}>;
|
|
1280
1156
|
//#endregion
|
|
1281
|
-
export {
|
|
1157
|
+
export { RolldownContext as A, TsdownBundle as B, ChunkAddonObject as C, PackageJsonWithPath as D, OutExtensionObject as E, DepPlugin as F, CopyOptions as H, DepsConfig 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,6 +1,7 @@
|
|
|
1
1
|
import { i as noop, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
|
|
2
|
-
import { n as
|
|
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-DPVBd8E4.mjs";
|
|
4
5
|
import { builtinModules } from "node:module";
|
|
5
6
|
import { chmod } from "node:fs/promises";
|
|
6
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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
".": "./dist/index.mjs",
|
|
19
19
|
"./config": "./dist/config.mjs",
|
|
20
|
-
"./
|
|
20
|
+
"./internal": "./dist/internal.mjs",
|
|
21
21
|
"./plugins": "./dist/plugins.mjs",
|
|
22
22
|
"./run": "./dist/run.mjs",
|
|
23
23
|
"./package.json": "./package.json",
|
|
@@ -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/
|
|
56
|
-
"@tsdown/
|
|
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,18 +108,18 @@
|
|
|
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.
|
|
115
|
-
"@unocss/eslint-plugin": "^66.6.
|
|
116
|
-
"@vitejs/devtools": "^0.0.0-alpha.
|
|
114
|
+
"@typescript/native-preview": "7.0.0-dev.20260311.1",
|
|
115
|
+
"@unocss/eslint-plugin": "^66.6.6",
|
|
116
|
+
"@vitejs/devtools": "^0.0.0-alpha.33",
|
|
117
117
|
"@vitest/coverage-v8": "^4.0.18",
|
|
118
118
|
"@vitest/ui": "^4.0.18",
|
|
119
119
|
"@vueuse/core": "^14.2.1",
|
|
120
120
|
"bumpp": "^10.4.1",
|
|
121
121
|
"dedent": "^1.7.2",
|
|
122
|
-
"eslint": "^10.0.
|
|
122
|
+
"eslint": "^10.0.3",
|
|
123
123
|
"is-in-ci": "^2.0.0",
|
|
124
124
|
"memfs": "^4.56.11",
|
|
125
125
|
"package-manager-detector": "^1.6.0",
|
|
@@ -129,22 +129,26 @@
|
|
|
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.
|
|
132
|
+
"rolldown-plugin-require-cjs": "^0.4.0",
|
|
133
|
+
"sass": "^1.98.0",
|
|
133
134
|
"typescript": "~5.9.3",
|
|
134
|
-
"unocss": "^66.6.
|
|
135
|
+
"unocss": "^66.6.6",
|
|
135
136
|
"unplugin-ast": "^0.16.0",
|
|
137
|
+
"unplugin-raw": "^0.6.4",
|
|
136
138
|
"unplugin-unused": "^0.5.7",
|
|
137
|
-
"
|
|
139
|
+
"unplugin-vue": "^7.1.1",
|
|
140
|
+
"vite": "^8.0.0-beta.18",
|
|
138
141
|
"vitest": "^4.0.18",
|
|
139
|
-
"
|
|
140
|
-
"@tsdown/
|
|
142
|
+
"vue": "^3.5.30",
|
|
143
|
+
"@tsdown/css": "0.21.2",
|
|
144
|
+
"@tsdown/exe": "0.21.2"
|
|
141
145
|
},
|
|
142
146
|
"prettier": "@sxzz/prettier-config",
|
|
143
147
|
"scripts": {
|
|
144
148
|
"lint": "eslint --cache --max-warnings 0 .",
|
|
145
149
|
"lint:fix": "pnpm run lint --fix",
|
|
146
|
-
"build": "
|
|
147
|
-
"dev": "
|
|
150
|
+
"build": "node -C dev ./src/run.ts",
|
|
151
|
+
"dev": "pnpm run build",
|
|
148
152
|
"test": "vitest",
|
|
149
153
|
"typecheck": "tsgo --noEmit",
|
|
150
154
|
"format": "prettier --cache --write .",
|
package/dist/build-gOkJM1H9.mjs
DELETED
package/dist/css-CzF_A79W.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
|
|
2
|
-
//#region src/features/css/index.ts
|
|
3
|
-
const defaultCssBundleName = "style.css";
|
|
4
|
-
function resolveCssOptions(options = {}, topLevelTarget) {
|
|
5
|
-
let cssTarget;
|
|
6
|
-
if (options.target === false) cssTarget = void 0;
|
|
7
|
-
else if (options.target == null) cssTarget = topLevelTarget;
|
|
8
|
-
else cssTarget = resolveComma(toArray(options.target));
|
|
9
|
-
return {
|
|
10
|
-
transformer: options.transformer ?? "lightningcss",
|
|
11
|
-
splitting: options.splitting ?? false,
|
|
12
|
-
fileName: options.fileName ?? "style.css",
|
|
13
|
-
minify: options.minify ?? false,
|
|
14
|
-
target: cssTarget,
|
|
15
|
-
preprocessorOptions: options.preprocessorOptions,
|
|
16
|
-
lightningcss: options.lightningcss,
|
|
17
|
-
postcss: options.postcss
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { resolveCssOptions as n, defaultCssBundleName as t };
|
package/dist/css.d.mts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { $ as defaultCssBundleName, G as LightningCSSOptions, J as PreprocessorAdditionalDataResult, K as PostCSSOptions, Q as StylusPreprocessorOptions, U as CssOptions, W as LessPreprocessorOptions, X as ResolvedCssOptions, Y as PreprocessorOptions, Z as SassPreprocessorOptions, et as resolveCssOptions, q as PreprocessorAdditionalData, s as Sourcemap } from "./types-DS6cAXR1.mjs";
|
|
2
|
-
import { OutputAsset, OutputChunk, Plugin } from "rolldown";
|
|
3
|
-
|
|
4
|
-
//#region src/features/css/plugin.d.ts
|
|
5
|
-
declare const RE_CSS: RegExp;
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/features/css/post.d.ts
|
|
8
|
-
type CssStyles = Map<string, string>;
|
|
9
|
-
declare function createCssPostHooks(config: {
|
|
10
|
-
css: {
|
|
11
|
-
splitting: boolean;
|
|
12
|
-
fileName: string;
|
|
13
|
-
};
|
|
14
|
-
}, styles: CssStyles): Pick<Required<Plugin>, "renderChunk" | "generateBundle">;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/features/css/pure-chunk.d.ts
|
|
17
|
-
/**
|
|
18
|
-
* Detect and remove "pure CSS chunks" — JS chunks that exist only because
|
|
19
|
-
* they imported CSS files. These chunks have no JS exports and all their
|
|
20
|
-
* modules are CSS. Following Vite's implementation.
|
|
21
|
-
*/
|
|
22
|
-
declare function removePureCssChunks(bundle: Record<string, OutputChunk | OutputAsset>, styles: CssStyles): void;
|
|
23
|
-
/**
|
|
24
|
-
* Create a replacer function that replaces import statements for pure CSS
|
|
25
|
-
* chunks with block comments of the same length, preserving source map offsets.
|
|
26
|
-
*/
|
|
27
|
-
declare function getEmptyChunkReplacer(pureCssChunkNames: string[]): (code: string) => string;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { type CssOptions, type CssStyles, type LessPreprocessorOptions, type LightningCSSOptions, type PostCSSOptions, type PreprocessorAdditionalData, type PreprocessorAdditionalDataResult, type PreprocessorOptions, RE_CSS, type ResolvedCssOptions, type SassPreprocessorOptions, type Sourcemap, type StylusPreprocessorOptions, createCssPostHooks, defaultCssBundleName, getEmptyChunkReplacer, removePureCssChunks, resolveCssOptions };
|
package/dist/css.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { n as resolveCssOptions, t as defaultCssBundleName } from "./css-CzF_A79W.mjs";
|
|
2
|
-
import { a as removePureCssChunks, i as getEmptyChunkReplacer, n as RE_CSS, r as createCssPostHooks } from "./plugin-BQv869Ce.mjs";
|
|
3
|
-
export { RE_CSS, createCssPostHooks, defaultCssBundleName, getEmptyChunkReplacer, removePureCssChunks, resolveCssOptions };
|
package/dist/plugin-BQv869Ce.mjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { t as defaultCssBundleName } from "./css-CzF_A79W.mjs";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
//#region src/features/css/pure-chunk.ts
|
|
5
|
-
/**
|
|
6
|
-
* Detect and remove "pure CSS chunks" — JS chunks that exist only because
|
|
7
|
-
* they imported CSS files. These chunks have no JS exports and all their
|
|
8
|
-
* modules are CSS. Following Vite's implementation.
|
|
9
|
-
*/
|
|
10
|
-
function removePureCssChunks(bundle, styles) {
|
|
11
|
-
const pureCssChunkNames = [];
|
|
12
|
-
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
13
|
-
if (chunk.type !== "chunk") continue;
|
|
14
|
-
if (chunk.exports.length > 0) continue;
|
|
15
|
-
const moduleIds = Object.keys(chunk.modules);
|
|
16
|
-
if (moduleIds.length === 0) continue;
|
|
17
|
-
if (!moduleIds.every((id) => styles.has(id))) continue;
|
|
18
|
-
pureCssChunkNames.push(fileName);
|
|
19
|
-
}
|
|
20
|
-
if (!pureCssChunkNames.length) return;
|
|
21
|
-
const replaceEmptyChunk = getEmptyChunkReplacer(pureCssChunkNames);
|
|
22
|
-
for (const file of Object.keys(bundle)) {
|
|
23
|
-
const chunk = bundle[file];
|
|
24
|
-
if (chunk.type !== "chunk") continue;
|
|
25
|
-
let chunkImportsPureCssChunk = false;
|
|
26
|
-
chunk.imports = chunk.imports.filter((importFile) => {
|
|
27
|
-
if (pureCssChunkNames.includes(importFile)) {
|
|
28
|
-
chunkImportsPureCssChunk = true;
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
});
|
|
33
|
-
if (chunkImportsPureCssChunk) chunk.code = replaceEmptyChunk(chunk.code);
|
|
34
|
-
}
|
|
35
|
-
for (const fileName of pureCssChunkNames) {
|
|
36
|
-
delete bundle[fileName];
|
|
37
|
-
delete bundle[`${fileName}.map`];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Create a replacer function that replaces import statements for pure CSS
|
|
42
|
-
* chunks with block comments of the same length, preserving source map offsets.
|
|
43
|
-
*/
|
|
44
|
-
function getEmptyChunkReplacer(pureCssChunkNames) {
|
|
45
|
-
const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex(path.basename(file))).join("|");
|
|
46
|
-
const emptyChunkRE = new RegExp(String.raw`\bimport\s*["'][^"']*(?:${emptyChunkFiles})["'];`, "g");
|
|
47
|
-
return (code) => code.replace(emptyChunkRE, (m) => {
|
|
48
|
-
return `/* empty css ${"".padEnd(m.length - 15)}*/`;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function escapeRegex(str) {
|
|
52
|
-
return str.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/features/css/post.ts
|
|
56
|
-
function createCssPostHooks(config, styles) {
|
|
57
|
-
const collectedCSS = [];
|
|
58
|
-
return {
|
|
59
|
-
renderChunk(_code, chunk) {
|
|
60
|
-
let chunkCSS = "";
|
|
61
|
-
for (const id of Object.keys(chunk.modules)) {
|
|
62
|
-
const code = styles.get(id);
|
|
63
|
-
if (code) chunkCSS += code;
|
|
64
|
-
}
|
|
65
|
-
if (!chunkCSS) return;
|
|
66
|
-
if (chunkCSS.length > 0 && !chunkCSS.endsWith("\n")) chunkCSS += "\n";
|
|
67
|
-
if (config.css.splitting) {
|
|
68
|
-
const cssAssetFileName = chunk.fileName.replace(/\.(m?js|cjs)$/, ".css");
|
|
69
|
-
this.emitFile({
|
|
70
|
-
type: "asset",
|
|
71
|
-
fileName: cssAssetFileName,
|
|
72
|
-
source: chunkCSS
|
|
73
|
-
});
|
|
74
|
-
} else collectedCSS.push(chunkCSS);
|
|
75
|
-
},
|
|
76
|
-
generateBundle(_outputOptions, bundle) {
|
|
77
|
-
if (!config.css.splitting && collectedCSS.length > 0) {
|
|
78
|
-
const allCSS = collectedCSS.join("");
|
|
79
|
-
if (allCSS) this.emitFile({
|
|
80
|
-
type: "asset",
|
|
81
|
-
fileName: config.css.fileName,
|
|
82
|
-
source: allCSS,
|
|
83
|
-
originalFileName: defaultCssBundleName
|
|
84
|
-
});
|
|
85
|
-
collectedCSS.length = 0;
|
|
86
|
-
}
|
|
87
|
-
removePureCssChunks(bundle, styles);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/features/css/plugin.ts
|
|
93
|
-
const RE_CSS = /\.css(?:$|\?)/;
|
|
94
|
-
function CssPlugin(config) {
|
|
95
|
-
const styles = /* @__PURE__ */ new Map();
|
|
96
|
-
const postHooks = createCssPostHooks(config, styles);
|
|
97
|
-
return {
|
|
98
|
-
name: "tsdown:builtin-css",
|
|
99
|
-
buildStart() {
|
|
100
|
-
styles.clear();
|
|
101
|
-
},
|
|
102
|
-
load: {
|
|
103
|
-
filter: { id: RE_CSS },
|
|
104
|
-
async handler(id) {
|
|
105
|
-
let code = await readFile(id, "utf8");
|
|
106
|
-
if (code.length > 0 && !code.endsWith("\n")) code += "\n";
|
|
107
|
-
styles.set(id, code);
|
|
108
|
-
return {
|
|
109
|
-
code: "",
|
|
110
|
-
moduleSideEffects: "no-treeshake",
|
|
111
|
-
moduleType: "js"
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
...postHooks
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
//#endregion
|
|
119
|
-
export { removePureCssChunks as a, getEmptyChunkReplacer as i, RE_CSS as n, createCssPostHooks as r, CssPlugin as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|