tsdown 0.12.8 → 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-D_2fTM9-.d.mts → config-DL8S79AB.d.mts} +21 -2
- package/dist/config.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +11 -10
- package/dist/{migrate-D3HAtePC.mjs → migrate-B-cABzzU.mjs} +1 -1
- package/dist/package--rzHLoNS.mjs +5 -0
- package/dist/{plugins-qNZNAFcS.mjs → plugins-BsFgA-ka.mjs} +18 -3
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/package.json +21 -21
- package/dist/package-DRxdhN87.mjs +0 -5
|
@@ -161,8 +161,8 @@ declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: bool
|
|
|
161
161
|
//#endregion
|
|
162
162
|
//#region src/options/types.d.ts
|
|
163
163
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
164
|
-
type Format =
|
|
165
|
-
type NormalizedFormat =
|
|
164
|
+
type Format = ModuleFormat;
|
|
165
|
+
type NormalizedFormat = InternalModuleFormat;
|
|
166
166
|
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
167
167
|
interface Workspace {
|
|
168
168
|
/**
|
|
@@ -387,6 +387,7 @@ interface Options$3 {
|
|
|
387
387
|
* If enabled, strips the `node:` protocol prefix from import source.
|
|
388
388
|
*
|
|
389
389
|
* @default false
|
|
390
|
+
* @deprecated Use `nodeProtocol: 'strip'` instead.
|
|
390
391
|
*
|
|
391
392
|
* @example
|
|
392
393
|
* // With removeNodeProtocol enabled:
|
|
@@ -394,6 +395,23 @@ interface Options$3 {
|
|
|
394
395
|
*/
|
|
395
396
|
removeNodeProtocol?: boolean;
|
|
396
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
|
+
/**
|
|
397
415
|
* If enabled, appends hash to chunk filenames.
|
|
398
416
|
* @default true
|
|
399
417
|
*/
|
|
@@ -428,6 +446,7 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
|
|
|
428
446
|
tsconfig: string | false;
|
|
429
447
|
pkg?: PackageJson;
|
|
430
448
|
exports: false | ExportsOptions;
|
|
449
|
+
nodeProtocol: "strip" | boolean;
|
|
431
450
|
}>, "config" | "fromVite">;
|
|
432
451
|
//#endregion
|
|
433
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, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-
|
|
1
|
+
import { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-DL8S79AB.mjs";
|
|
2
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";
|
|
@@ -175,11 +175,10 @@ async function writeExports(options, chunks) {
|
|
|
175
175
|
updatedPkg.publishConfig ||= {};
|
|
176
176
|
updatedPkg.publishConfig.exports = publishExports;
|
|
177
177
|
}
|
|
178
|
-
await
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}, 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");
|
|
183
182
|
}
|
|
184
183
|
async function generateExports(pkg, outDir, chunks, { devExports, all, customExports }) {
|
|
185
184
|
const pkgJsonPath = pkg.packageJsonPath;
|
|
@@ -802,8 +801,9 @@ async function resolveWorkspace(config, options) {
|
|
|
802
801
|
};
|
|
803
802
|
}
|
|
804
803
|
async function resolveConfig(userConfig) {
|
|
805
|
-
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 } = 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;
|
|
806
805
|
if (typeof bundle === "boolean") logger.warn("`bundle` option is deprecated. Use `unbundle` instead.");
|
|
806
|
+
nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
|
|
807
807
|
outDir = path.resolve(cwd, outDir);
|
|
808
808
|
clean = resolveClean(clean, outDir, cwd);
|
|
809
809
|
const pkg = await readPackageJson(cwd);
|
|
@@ -860,7 +860,8 @@ async function resolveConfig(userConfig) {
|
|
|
860
860
|
external,
|
|
861
861
|
noExternal,
|
|
862
862
|
exports,
|
|
863
|
-
unbundle
|
|
863
|
+
unbundle,
|
|
864
|
+
nodeProtocol
|
|
864
865
|
};
|
|
865
866
|
return config;
|
|
866
867
|
}
|
|
@@ -965,9 +966,9 @@ async function buildSingle(config, clean) {
|
|
|
965
966
|
}
|
|
966
967
|
}
|
|
967
968
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
968
|
-
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;
|
|
969
970
|
const plugins = [];
|
|
970
|
-
if (
|
|
971
|
+
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
971
972
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
972
973
|
if (dts) {
|
|
973
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";
|
|
@@ -96,9 +96,9 @@ function getProductionDeps(pkg) {
|
|
|
96
96
|
* The `node:` protocol was added in Node.js v14.18.0.
|
|
97
97
|
* @see https://nodejs.org/api/esm.html#node-imports
|
|
98
98
|
*/
|
|
99
|
-
function NodeProtocolPlugin() {
|
|
100
|
-
return {
|
|
101
|
-
name: "tsdown:node-protocol",
|
|
99
|
+
function NodeProtocolPlugin(nodeProtocolOption) {
|
|
100
|
+
if (nodeProtocolOption === "strip") return {
|
|
101
|
+
name: "tsdown:node-protocol:strip",
|
|
102
102
|
resolveId: {
|
|
103
103
|
order: "pre",
|
|
104
104
|
filter: { id: /^node:/ },
|
|
@@ -111,6 +111,21 @@ function NodeProtocolPlugin() {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
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
|
+
};
|
|
114
129
|
}
|
|
115
130
|
|
|
116
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,10 +72,10 @@
|
|
|
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",
|
|
@@ -83,33 +83,33 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@arethetypeswrong/core": "^0.18.2",
|
|
86
|
-
"@
|
|
87
|
-
"@sxzz/
|
|
88
|
-
"@sxzz/prettier-config": "^2.2.1",
|
|
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": "^24.0.
|
|
90
|
+
"@types/node": "^24.0.4",
|
|
92
91
|
"@types/semver": "^7.7.0",
|
|
93
|
-
"@unocss/eslint-plugin": "^66.2.
|
|
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.2.
|
|
104
|
+
"unocss": "^66.2.3",
|
|
105
105
|
"unplugin-lightningcss": "^0.4.1",
|
|
106
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.5.
|
|
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
|
}
|