tsdown 0.12.7 → 0.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{config-BJDUww56.d.mts → config-DL8S79AB.d.mts} +80 -28
- package/dist/config.d.mts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +68 -14
- package/dist/{migrate-CMJIC73T.mjs → migrate-B-cABzzU.mjs} +1 -1
- package/dist/package--rzHLoNS.mjs +5 -0
- package/dist/{plugins-BmNEEFYs.mjs → plugins-BsFgA-ka.mjs} +25 -6
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/package.json +23 -23
- package/dist/package-ZDuXNobF.mjs +0 -5
|
@@ -13,6 +13,40 @@ type Awaitable<T> = T | Promise<T>;
|
|
|
13
13
|
type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
14
14
|
type Arrayable<T> = T | T[];
|
|
15
15
|
//#endregion
|
|
16
|
+
//#region src/features/attw.d.ts
|
|
17
|
+
interface AttwOptions extends CheckPackageOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Profiles select a set of resolution modes to require/ignore. All are evaluated but failures outside
|
|
20
|
+
* of those required are ignored.
|
|
21
|
+
*
|
|
22
|
+
* The available profiles are:
|
|
23
|
+
* - `strict`: requires all resolutions
|
|
24
|
+
* - `node16`: ignores node10 resolution failures
|
|
25
|
+
* - `esmOnly`: ignores CJS resolution failures
|
|
26
|
+
*
|
|
27
|
+
* @default 'strict'
|
|
28
|
+
*/
|
|
29
|
+
profile?: "strict" | "node16" | "esmOnly";
|
|
30
|
+
/**
|
|
31
|
+
* The level of the check.
|
|
32
|
+
*
|
|
33
|
+
* The available levels are:
|
|
34
|
+
* - `error`: fails the build
|
|
35
|
+
* - `warn`: warns the build
|
|
36
|
+
*
|
|
37
|
+
* @default 'warn'
|
|
38
|
+
*/
|
|
39
|
+
level?: "error" | "warn";
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/features/copy.d.ts
|
|
43
|
+
interface CopyEntry {
|
|
44
|
+
from: string;
|
|
45
|
+
to: string;
|
|
46
|
+
}
|
|
47
|
+
type CopyOptions = Arrayable<string | CopyEntry>;
|
|
48
|
+
type CopyOptionsFn = (options: ResolvedOptions) => Awaitable<CopyOptions>;
|
|
49
|
+
//#endregion
|
|
16
50
|
//#region src/utils/logger.d.ts
|
|
17
51
|
declare class Logger {
|
|
18
52
|
silent: boolean;
|
|
@@ -72,13 +106,25 @@ type TsdownChunks = Partial<Record<NormalizedFormat, Array<OutputChunk | OutputA
|
|
|
72
106
|
*/
|
|
73
107
|
declare function buildSingle(config: ResolvedOptions, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
|
|
74
108
|
//#endregion
|
|
75
|
-
//#region src/features/
|
|
76
|
-
interface
|
|
77
|
-
|
|
78
|
-
to
|
|
109
|
+
//#region src/features/exports.d.ts
|
|
110
|
+
interface ExportsOptions {
|
|
111
|
+
/**
|
|
112
|
+
* Generate exports that link to source code during development.
|
|
113
|
+
* - string: add as a custom condition.
|
|
114
|
+
* - true: all conditions point to source files, and add dist exports to `publishConfig`.
|
|
115
|
+
*/
|
|
116
|
+
devExports?: boolean | string;
|
|
117
|
+
/**
|
|
118
|
+
* Exports for all files.
|
|
119
|
+
*/
|
|
120
|
+
all?: boolean;
|
|
121
|
+
customExports?: (exports: Record<string, any>, context: {
|
|
122
|
+
pkg: PackageJson;
|
|
123
|
+
chunks: TsdownChunks;
|
|
124
|
+
outDir: string;
|
|
125
|
+
isPublish: boolean;
|
|
126
|
+
}) => Awaitable<Record<string, any>>;
|
|
79
127
|
}
|
|
80
|
-
type CopyOptions = Arrayable<string | CopyEntry>;
|
|
81
|
-
type CopyOptionsFn = (options: ResolvedOptions) => Awaitable<CopyOptions>;
|
|
82
128
|
//#endregion
|
|
83
129
|
//#region src/utils/package.d.ts
|
|
84
130
|
type PackageType = "module" | "commonjs" | undefined;
|
|
@@ -115,8 +161,8 @@ declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: bool
|
|
|
115
161
|
//#endregion
|
|
116
162
|
//#region src/options/types.d.ts
|
|
117
163
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
118
|
-
type Format =
|
|
119
|
-
type NormalizedFormat =
|
|
164
|
+
type Format = ModuleFormat;
|
|
165
|
+
type NormalizedFormat = InternalModuleFormat;
|
|
120
166
|
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
121
167
|
interface Workspace {
|
|
122
168
|
/**
|
|
@@ -135,24 +181,6 @@ interface Workspace {
|
|
|
135
181
|
*/
|
|
136
182
|
config?: boolean | string;
|
|
137
183
|
}
|
|
138
|
-
interface ExportsOptions {
|
|
139
|
-
/**
|
|
140
|
-
* Generate exports that link to source code during development.
|
|
141
|
-
* - string: add as a custom condition.
|
|
142
|
-
* - true: all conditions point to source files, and add dist exports to `publishConfig`.
|
|
143
|
-
*/
|
|
144
|
-
devExports?: boolean | string;
|
|
145
|
-
/**
|
|
146
|
-
* Exports for all files.
|
|
147
|
-
*/
|
|
148
|
-
all?: boolean;
|
|
149
|
-
customExports?: (exports: Record<string, any>, context: {
|
|
150
|
-
pkg: PackageJson;
|
|
151
|
-
chunks: TsdownChunks;
|
|
152
|
-
outDir: string;
|
|
153
|
-
isPublish: boolean;
|
|
154
|
-
}) => Awaitable<Record<string, any>>;
|
|
155
|
-
}
|
|
156
184
|
/**
|
|
157
185
|
* Options for tsdown.
|
|
158
186
|
*/
|
|
@@ -225,6 +253,11 @@ interface Options$3 {
|
|
|
225
253
|
* @default false
|
|
226
254
|
*/
|
|
227
255
|
unbundle?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated Use `unbundle` instead.
|
|
258
|
+
* @default true
|
|
259
|
+
*/
|
|
260
|
+
bundle?: boolean;
|
|
228
261
|
define?: Record<string, string>;
|
|
229
262
|
/** @default false */
|
|
230
263
|
shims?: boolean;
|
|
@@ -310,7 +343,7 @@ interface Options$3 {
|
|
|
310
343
|
* @default false
|
|
311
344
|
* @see https://github.com/arethetypeswrong/arethetypeswrong.github.io
|
|
312
345
|
*/
|
|
313
|
-
attw?: boolean |
|
|
346
|
+
attw?: boolean | AttwOptions;
|
|
314
347
|
/**
|
|
315
348
|
* Enable size reporting after bundling.
|
|
316
349
|
* @default true
|
|
@@ -354,6 +387,7 @@ interface Options$3 {
|
|
|
354
387
|
* If enabled, strips the `node:` protocol prefix from import source.
|
|
355
388
|
*
|
|
356
389
|
* @default false
|
|
390
|
+
* @deprecated Use `nodeProtocol: 'strip'` instead.
|
|
357
391
|
*
|
|
358
392
|
* @example
|
|
359
393
|
* // With removeNodeProtocol enabled:
|
|
@@ -361,6 +395,23 @@ interface Options$3 {
|
|
|
361
395
|
*/
|
|
362
396
|
removeNodeProtocol?: boolean;
|
|
363
397
|
/**
|
|
398
|
+
* - If true, add `node:` prefix to built-in modules.
|
|
399
|
+
* - If 'strip', strips the `node:` protocol prefix from import source.
|
|
400
|
+
* - If false, does not modify the import source.
|
|
401
|
+
*
|
|
402
|
+
* @default false
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* // With nodeProtocol enabled:
|
|
406
|
+
* import('fs'); // becomes import('node:fs')
|
|
407
|
+
* // With nodeProtocol set to 'strip':
|
|
408
|
+
* import('node:fs'); // becomes import('fs')
|
|
409
|
+
* // With nodeProtocol set to false:
|
|
410
|
+
* import('node:fs'); // remains import('node:fs')
|
|
411
|
+
*
|
|
412
|
+
*/
|
|
413
|
+
nodeProtocol?: "strip" | boolean;
|
|
414
|
+
/**
|
|
364
415
|
* If enabled, appends hash to chunk filenames.
|
|
365
416
|
* @default true
|
|
366
417
|
*/
|
|
@@ -386,7 +437,7 @@ interface Options$3 {
|
|
|
386
437
|
*/
|
|
387
438
|
type UserConfig = Arrayable<Omit<Options$3, "config" | "filter">>;
|
|
388
439
|
type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
389
|
-
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "
|
|
440
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "bundle">, {
|
|
390
441
|
format: NormalizedFormat[];
|
|
391
442
|
target?: string[];
|
|
392
443
|
clean: string[];
|
|
@@ -395,6 +446,7 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
|
|
|
395
446
|
tsconfig: string | false;
|
|
396
447
|
pkg?: PackageJson;
|
|
397
448
|
exports: false | ExportsOptions;
|
|
449
|
+
nodeProtocol: "strip" | boolean;
|
|
398
450
|
}>, "config" | "fromVite">;
|
|
399
451
|
//#endregion
|
|
400
452
|
//#region src/config.d.ts
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn, defineConfig } from "./config-
|
|
1
|
+
import { UserConfig, UserConfigFn, defineConfig } from "./config-DL8S79AB.mjs";
|
|
2
2
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-
|
|
2
|
-
export { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot };
|
|
1
|
+
import { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-DL8S79AB.mjs";
|
|
2
|
+
export { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CzjtjH-U.mjs";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-BsFgA-ka.mjs";
|
|
3
3
|
import { debounce, generateColor, logger, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-CdK2zFTY.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
@@ -24,12 +24,50 @@ import { loadConfig } from "unconfig";
|
|
|
24
24
|
//#region src/features/attw.ts
|
|
25
25
|
const debug$5 = debug("tsdown:attw");
|
|
26
26
|
const exec$1 = promisify(child_process.exec);
|
|
27
|
+
/**
|
|
28
|
+
* ATTW profiles.
|
|
29
|
+
* Defines the resolution modes to ignore for each profile.
|
|
30
|
+
*
|
|
31
|
+
* @see https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/packages/cli/README.md#profiles
|
|
32
|
+
*/
|
|
33
|
+
const profiles = {
|
|
34
|
+
strict: [],
|
|
35
|
+
node16: ["node10"],
|
|
36
|
+
esmOnly: ["node10", "node16-cjs"]
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Format an ATTW problem for display
|
|
40
|
+
*/
|
|
41
|
+
function formatProblem(problem) {
|
|
42
|
+
const resolutionKind = "resolutionKind" in problem ? ` (${problem.resolutionKind})` : "";
|
|
43
|
+
const entrypoint = "entrypoint" in problem ? ` at ${problem.entrypoint}` : "";
|
|
44
|
+
switch (problem.kind) {
|
|
45
|
+
case "NoResolution": return ` ❌ No resolution${resolutionKind}${entrypoint}`;
|
|
46
|
+
case "UntypedResolution": return ` ⚠️ Untyped resolution${resolutionKind}${entrypoint}`;
|
|
47
|
+
case "FalseESM": return ` 🔄 False ESM: Types indicate ESM (${problem.typesModuleKind}) but implementation is CJS (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
|
|
48
|
+
case "FalseCJS": return ` 🔄 False CJS: Types indicate CJS (${problem.typesModuleKind}) but implementation is ESM (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
|
|
49
|
+
case "CJSResolvesToESM": return ` ⚡ CJS resolves to ESM${resolutionKind}${entrypoint}`;
|
|
50
|
+
case "NamedExports": {
|
|
51
|
+
const missingExports = problem.missing?.length > 0 ? ` Missing: ${problem.missing.join(", ")}` : "";
|
|
52
|
+
const allMissing = problem.isMissingAllNamed ? " (all named exports missing)" : "";
|
|
53
|
+
return ` 📤 Named exports problem${allMissing}${missingExports}\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
|
|
54
|
+
}
|
|
55
|
+
case "FallbackCondition": return ` 🎯 Fallback condition used${resolutionKind}${entrypoint}`;
|
|
56
|
+
case "FalseExportDefault": return ` 🎭 False export default\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
|
|
57
|
+
case "MissingExportEquals": return ` 📝 Missing export equals\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
|
|
58
|
+
case "InternalResolutionError": return ` 💥 Internal resolution error in ${problem.fileName} (${problem.resolutionOption})\n Module: ${problem.moduleSpecifier} | Mode: ${problem.resolutionMode}`;
|
|
59
|
+
case "UnexpectedModuleSyntax": return ` 📋 Unexpected module syntax in ${problem.fileName}\n Expected: ${problem.moduleKind} | Found: ${problem.syntax === 99 ? "ESM" : "CJS"}`;
|
|
60
|
+
case "CJSOnlyExportsDefault": return ` 🏷️ CJS only exports default in ${problem.fileName}`;
|
|
61
|
+
default: return ` ❓ Unknown problem: ${JSON.stringify(problem)}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
27
64
|
async function attw(options) {
|
|
28
65
|
if (!options.attw) return;
|
|
29
66
|
if (!options.pkg) {
|
|
30
67
|
logger.warn("attw is enabled but package.json is not found");
|
|
31
68
|
return;
|
|
32
69
|
}
|
|
70
|
+
const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
|
|
33
71
|
const t = performance.now();
|
|
34
72
|
debug$5("Running attw check");
|
|
35
73
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
@@ -41,15 +79,28 @@ async function attw(options) {
|
|
|
41
79
|
return;
|
|
42
80
|
}
|
|
43
81
|
try {
|
|
44
|
-
const { stdout: tarballInfo } = await exec$1(`npm pack --json ----pack-destination ${tempDir}`, {
|
|
82
|
+
const { stdout: tarballInfo } = await exec$1(`npm pack --json ----pack-destination ${tempDir}`, {
|
|
83
|
+
encoding: "utf8",
|
|
84
|
+
cwd: options.cwd
|
|
85
|
+
});
|
|
45
86
|
const parsed = JSON.parse(tarballInfo);
|
|
46
87
|
if (!Array.isArray(parsed) || !parsed[0]?.filename) throw new Error("Invalid npm pack output format");
|
|
47
88
|
const tarballPath = path.join(tempDir, parsed[0].filename);
|
|
48
89
|
const tarball = await readFile(tarballPath);
|
|
49
90
|
const pkg = attwCore.createPackageFromTarballData(tarball);
|
|
50
|
-
const checkResult = await attwCore.checkPackage(pkg,
|
|
51
|
-
if (checkResult.types !== false && checkResult.problems)
|
|
52
|
-
|
|
91
|
+
const checkResult = await attwCore.checkPackage(pkg, attwOptions);
|
|
92
|
+
if (checkResult.types !== false && checkResult.problems) {
|
|
93
|
+
const problems = checkResult.problems.filter((problem) => {
|
|
94
|
+
if ("resolutionKind" in problem) return !profiles[profile]?.includes(problem.resolutionKind);
|
|
95
|
+
return true;
|
|
96
|
+
});
|
|
97
|
+
if (problems.length) {
|
|
98
|
+
const problemList = problems.map(formatProblem).join("\n");
|
|
99
|
+
const problemMessage = `Are the types wrong problems found:\n${problemList}`;
|
|
100
|
+
if (level === "error") throw new Error(problemMessage);
|
|
101
|
+
logger.warn(problemMessage);
|
|
102
|
+
}
|
|
103
|
+
} else logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
53
104
|
} catch (error) {
|
|
54
105
|
logger.error("ATTW check failed:", error);
|
|
55
106
|
debug$5("Found errors, setting exit code to 1");
|
|
@@ -124,11 +175,10 @@ async function writeExports(options, chunks) {
|
|
|
124
175
|
updatedPkg.publishConfig ||= {};
|
|
125
176
|
updatedPkg.publishConfig.exports = publishExports;
|
|
126
177
|
}
|
|
127
|
-
await
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}, null, 2)}\n`);
|
|
178
|
+
const original = await readFile(pkg.packageJsonPath, "utf8");
|
|
179
|
+
let contents = JSON.stringify(updatedPkg, null, original.includes(" ") ? " " : 2);
|
|
180
|
+
if (original.endsWith("\n")) contents += "\n";
|
|
181
|
+
if (contents !== original) await writeFile(pkg.packageJsonPath, contents, "utf8");
|
|
132
182
|
}
|
|
133
183
|
async function generateExports(pkg, outDir, chunks, { devExports, all, customExports }) {
|
|
134
184
|
const pkgJsonPath = pkg.packageJsonPath;
|
|
@@ -751,7 +801,9 @@ async function resolveWorkspace(config, options) {
|
|
|
751
801
|
};
|
|
752
802
|
}
|
|
753
803
|
async function resolveConfig(userConfig) {
|
|
754
|
-
let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch = [], shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false } = userConfig;
|
|
804
|
+
let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch = [], shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol } = userConfig;
|
|
805
|
+
if (typeof bundle === "boolean") logger.warn("`bundle` option is deprecated. Use `unbundle` instead.");
|
|
806
|
+
nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
|
|
755
807
|
outDir = path.resolve(cwd, outDir);
|
|
756
808
|
clean = resolveClean(clean, outDir, cwd);
|
|
757
809
|
const pkg = await readPackageJson(cwd);
|
|
@@ -807,7 +859,9 @@ async function resolveConfig(userConfig) {
|
|
|
807
859
|
name,
|
|
808
860
|
external,
|
|
809
861
|
noExternal,
|
|
810
|
-
exports
|
|
862
|
+
exports,
|
|
863
|
+
unbundle,
|
|
864
|
+
nodeProtocol
|
|
811
865
|
};
|
|
812
866
|
return config;
|
|
813
867
|
}
|
|
@@ -912,9 +966,9 @@ async function buildSingle(config, clean) {
|
|
|
912
966
|
}
|
|
913
967
|
}
|
|
914
968
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
915
|
-
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env,
|
|
969
|
+
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, unbundle } = config;
|
|
916
970
|
const plugins = [];
|
|
917
|
-
if (
|
|
971
|
+
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
918
972
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
919
973
|
if (dts) {
|
|
920
974
|
const { dts: dtsPlugin } = await import("rolldown-plugin-dts");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from "./logger-CdK2zFTY.mjs";
|
|
2
|
-
import { version } from "./package
|
|
2
|
+
import { version } from "./package--rzHLoNS.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { bold, green, underline } from "ansis";
|
|
5
5
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger, noop, prettyFormat, prettyName, toArray } from "./logger-CdK2zFTY.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { builtinModules } from "node:module";
|
|
3
3
|
import path, { dirname, normalize, sep } from "node:path";
|
|
4
4
|
import { bold, dim, green, underline } from "ansis";
|
|
5
5
|
import { access, chmod, cp, rm, stat } from "node:fs/promises";
|
|
@@ -61,7 +61,11 @@ function ExternalPlugin(options) {
|
|
|
61
61
|
if (noExternal) {
|
|
62
62
|
const noExternalPatterns = toArray(noExternal);
|
|
63
63
|
if (noExternalPatterns.some((pattern) => {
|
|
64
|
-
|
|
64
|
+
if (pattern instanceof RegExp) {
|
|
65
|
+
pattern.lastIndex = 0;
|
|
66
|
+
return pattern.test(id);
|
|
67
|
+
}
|
|
68
|
+
return id === pattern;
|
|
65
69
|
})) return;
|
|
66
70
|
}
|
|
67
71
|
let shouldExternal = false;
|
|
@@ -76,7 +80,7 @@ function ExternalPlugin(options) {
|
|
|
76
80
|
return {
|
|
77
81
|
id,
|
|
78
82
|
external: shouldExternal,
|
|
79
|
-
moduleSideEffects: id.startsWith("node:") ||
|
|
83
|
+
moduleSideEffects: id.startsWith("node:") || builtinModules.includes(id) ? false : void 0
|
|
80
84
|
};
|
|
81
85
|
}
|
|
82
86
|
}
|
|
@@ -92,9 +96,9 @@ function getProductionDeps(pkg) {
|
|
|
92
96
|
* The `node:` protocol was added in Node.js v14.18.0.
|
|
93
97
|
* @see https://nodejs.org/api/esm.html#node-imports
|
|
94
98
|
*/
|
|
95
|
-
function NodeProtocolPlugin() {
|
|
96
|
-
return {
|
|
97
|
-
name: "tsdown:node-protocol",
|
|
99
|
+
function NodeProtocolPlugin(nodeProtocolOption) {
|
|
100
|
+
if (nodeProtocolOption === "strip") return {
|
|
101
|
+
name: "tsdown:node-protocol:strip",
|
|
98
102
|
resolveId: {
|
|
99
103
|
order: "pre",
|
|
100
104
|
filter: { id: /^node:/ },
|
|
@@ -107,6 +111,21 @@ function NodeProtocolPlugin() {
|
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
};
|
|
114
|
+
const builtinModulesRegex = /* @__PURE__ */ new RegExp(`^(${builtinModules.join("|")})$`);
|
|
115
|
+
return {
|
|
116
|
+
name: "tsdown:node-protocol:add",
|
|
117
|
+
resolveId: {
|
|
118
|
+
order: "pre",
|
|
119
|
+
filter: { id: builtinModulesRegex },
|
|
120
|
+
handler(id) {
|
|
121
|
+
return {
|
|
122
|
+
id: `node:${id}`,
|
|
123
|
+
external: true,
|
|
124
|
+
moduleSideEffects: false
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
110
129
|
}
|
|
111
130
|
|
|
112
131
|
//#endregion
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReportPlugin, ResolvedOptions } from "./config-
|
|
1
|
+
import { ReportPlugin, ResolvedOptions } from "./config-DL8S79AB.mjs";
|
|
2
2
|
import { Plugin } from "rolldown";
|
|
3
3
|
import { PackageJson } from "pkg-types";
|
|
4
4
|
|
|
@@ -16,6 +16,6 @@ declare function ShebangPlugin(cwd: string, name?: string, isMultiFormat?: boole
|
|
|
16
16
|
* The `node:` protocol was added in Node.js v14.18.0.
|
|
17
17
|
* @see https://nodejs.org/api/esm.html#node-imports
|
|
18
18
|
*/
|
|
19
|
-
declare function NodeProtocolPlugin(): Plugin;
|
|
19
|
+
declare function NodeProtocolPlugin(nodeProtocolOption: "strip" | true): Plugin;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-
|
|
1
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-BsFgA-ka.mjs";
|
|
2
2
|
import "./logger-CdK2zFTY.mjs";
|
|
3
3
|
|
|
4
4
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { logger, resolveComma, toArray } from "./logger-CdK2zFTY.mjs";
|
|
3
|
-
import { version } from "./package
|
|
3
|
+
import { version } from "./package--rzHLoNS.mjs";
|
|
4
4
|
import module from "node:module";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { dim } from "ansis";
|
|
@@ -22,7 +22,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
22
22
|
await build$1(flags);
|
|
23
23
|
});
|
|
24
24
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
25
|
-
const { migrate } = await import("./migrate-
|
|
25
|
+
const { migrate } = await import("./migrate-B-cABzzU.mjs");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.9",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,44 +72,44 @@
|
|
|
72
72
|
"chokidar": "^4.0.3",
|
|
73
73
|
"debug": "^4.4.1",
|
|
74
74
|
"diff": "^8.0.2",
|
|
75
|
-
"empathic": "^
|
|
75
|
+
"empathic": "^2.0.0",
|
|
76
76
|
"hookable": "^5.5.3",
|
|
77
|
-
"rolldown": "1.0.0-beta.
|
|
78
|
-
"rolldown-plugin-dts": "^0.13.
|
|
77
|
+
"rolldown": "^1.0.0-beta.19",
|
|
78
|
+
"rolldown-plugin-dts": "^0.13.12",
|
|
79
79
|
"semver": "^7.7.2",
|
|
80
80
|
"tinyexec": "^1.0.1",
|
|
81
81
|
"tinyglobby": "^0.2.14",
|
|
82
82
|
"unconfig": "^7.3.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@arethetypeswrong/core": "^0.18.
|
|
86
|
-
"@
|
|
87
|
-
"@sxzz/
|
|
88
|
-
"@sxzz/prettier-config": "^2.2.1",
|
|
85
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
86
|
+
"@sxzz/eslint-config": "^7.0.4",
|
|
87
|
+
"@sxzz/prettier-config": "^2.2.3",
|
|
89
88
|
"@sxzz/test-utils": "^0.5.6",
|
|
90
89
|
"@types/debug": "^4.1.12",
|
|
91
|
-
"@types/node": "^
|
|
90
|
+
"@types/node": "^24.0.4",
|
|
92
91
|
"@types/semver": "^7.7.0",
|
|
93
|
-
"@unocss/eslint-plugin": "^66.
|
|
94
|
-
"@vueuse/core": "^13.
|
|
95
|
-
"bumpp": "^10.
|
|
96
|
-
"eslint": "^9.
|
|
92
|
+
"@unocss/eslint-plugin": "^66.2.3",
|
|
93
|
+
"@vueuse/core": "^13.4.0",
|
|
94
|
+
"bumpp": "^10.2.0",
|
|
95
|
+
"eslint": "^9.29.0",
|
|
97
96
|
"lightningcss": "^1.30.1",
|
|
98
97
|
"pkg-types": "^2.1.0",
|
|
99
|
-
"prettier": "^3.
|
|
98
|
+
"prettier": "^3.6.0",
|
|
100
99
|
"publint": "^0.3.12",
|
|
100
|
+
"tsx": "^4.20.3",
|
|
101
101
|
"typedoc": "^0.28.5",
|
|
102
|
-
"typedoc-plugin-markdown": "^4.
|
|
102
|
+
"typedoc-plugin-markdown": "^4.7.0",
|
|
103
103
|
"typescript": "~5.8.3",
|
|
104
|
-
"unocss": "^66.
|
|
104
|
+
"unocss": "^66.2.3",
|
|
105
105
|
"unplugin-lightningcss": "^0.4.1",
|
|
106
|
-
"unplugin-unused": "^0.5.
|
|
106
|
+
"unplugin-unused": "^0.5.1",
|
|
107
107
|
"vite": "npm:rolldown-vite@latest",
|
|
108
108
|
"vitepress": "^1.6.3",
|
|
109
109
|
"vitepress-plugin-group-icons": "^1.6.0",
|
|
110
|
-
"vitepress-plugin-llms": "^1.
|
|
111
|
-
"vitest": "^3.2.
|
|
112
|
-
"vue": "^3.5.
|
|
110
|
+
"vitepress-plugin-llms": "^1.5.1",
|
|
111
|
+
"vitest": "^3.2.4",
|
|
112
|
+
"vue": "^3.5.17"
|
|
113
113
|
},
|
|
114
114
|
"engines": {
|
|
115
115
|
"node": ">=18.0.0"
|
|
@@ -122,8 +122,8 @@
|
|
|
122
122
|
"scripts": {
|
|
123
123
|
"lint": "eslint --cache --max-warnings 0 .",
|
|
124
124
|
"lint:fix": "pnpm run lint --fix",
|
|
125
|
-
"build": "
|
|
126
|
-
"dev": "
|
|
125
|
+
"build": "tsx ./src/run.ts",
|
|
126
|
+
"dev": "tsx ./src/run.ts",
|
|
127
127
|
"test": "vitest",
|
|
128
128
|
"typecheck": "tsc --noEmit",
|
|
129
129
|
"format": "prettier --cache --write .",
|
|
@@ -131,6 +131,6 @@
|
|
|
131
131
|
"docs:dev": "vitepress dev docs",
|
|
132
132
|
"docs:build": "vitepress build docs",
|
|
133
133
|
"docs:preview": "vitepress preview docs",
|
|
134
|
-
"docs:generate": "
|
|
134
|
+
"docs:generate": "tsx ./docs/.vitepress/scripts/docs-generate.ts"
|
|
135
135
|
}
|
|
136
136
|
}
|