tsdown 0.20.0-beta.1 → 0.20.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-CXZGeZ37.mjs +3 -0
- package/dist/{build-DnPwx_xA.mjs → build-D6KBDCuU.mjs} +4 -4
- package/dist/{config-EotW13uc.d.mts → config-DG-M_Jhl.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{options-CkeyyBq1.mjs → options-BUM1iPoj.mjs} +24 -12
- package/dist/package-Coy28bEr.mjs +5 -0
- package/dist/plugins.d.mts +1 -1
- package/dist/plugins.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/dist/{types-CBPWCTS8.d.mts → types-Dzu__V1_.d.mts} +1 -1
- package/dist/{watch-Bv7WwwWF.mjs → watch-HGpZB4EX.mjs} +2 -2
- package/package.json +1 -1
- package/dist/build-BsDjbCDD.mjs +0 -3
- package/dist/package-CjSq_Wqi.mjs +0 -5
|
@@ -1,14 +1,13 @@
|
|
|
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 globalLogger, d as promiseWithResolvers, h as toArray, m as slash, s as importWithError, t as LogLevels } from "./logger-scxPimHj.mjs";
|
|
4
|
-
import { a as getPackageType, c as cleanChunks, i as loadConfigFile, l as cleanOutDir, n as mergeUserOptions, o as writeExports, r as resolveUserConfig, s as defaultCssBundleName } from "./options-
|
|
4
|
+
import { a as getPackageType, c as cleanChunks, i as loadConfigFile, l as cleanOutDir, n as mergeUserOptions, o as writeExports, r as resolveUserConfig, s as defaultCssBundleName } from "./options-BUM1iPoj.mjs";
|
|
5
5
|
import { a as fsRemove, r as fsCopy, s as lowestCommonAncestor } from "./format-54qVrVD4.mjs";
|
|
6
|
-
import { t as version } from "./package-
|
|
7
|
-
import { a as ReportPlugin, c as getShimsInject, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, s as ExternalPlugin, t as WatchPlugin } from "./watch-
|
|
6
|
+
import { t as version } from "./package-Coy28bEr.mjs";
|
|
7
|
+
import { a as ReportPlugin, c as getShimsInject, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, s as ExternalPlugin, t as WatchPlugin } from "./watch-HGpZB4EX.mjs";
|
|
8
8
|
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import process from "node:process";
|
|
11
|
-
import { formatWithOptions, inspect } from "node:util";
|
|
12
11
|
import { bold, dim, green } from "ansis";
|
|
13
12
|
import { createDebug } from "obug";
|
|
14
13
|
import { glob, isDynamicPattern } from "tinyglobby";
|
|
@@ -21,6 +20,7 @@ const satisfies = __cjs_require("semver/functions/satisfies.js");
|
|
|
21
20
|
import { Hookable } from "hookable";
|
|
22
21
|
import { exec } from "tinyexec";
|
|
23
22
|
const treeKill = __cjs_require("tree-kill");
|
|
23
|
+
import { formatWithOptions, inspect } from "node:util";
|
|
24
24
|
import { tmpdir } from "node:os";
|
|
25
25
|
import { importGlobPlugin } from "rolldown/experimental";
|
|
26
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as UserConfig, i as InlineConfig, m as UserConfigFn, p as UserConfigExport, s as ResolvedConfig } from "./types-
|
|
1
|
+
import { f as UserConfig, i as InlineConfig, m as UserConfigFn, p as UserConfigExport, s as ResolvedConfig } from "./types-Dzu__V1_.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 { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./types-
|
|
2
|
-
import { n as mergeConfig, t as defineConfig } from "./config-
|
|
1
|
+
import { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./types-Dzu__V1_.mjs";
|
|
2
|
+
import { n as mergeConfig, t as defineConfig } from "./config-DG-M_Jhl.mjs";
|
|
3
3
|
export { UserConfig, UserConfigExport, UserConfigFn, defineConfig, mergeConfig };
|
package/dist/config.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as OutExtensionFactory, B as CopyOptions, C as RolldownChunk, D as ChunkAddonFunction, E as ChunkAddon, F as RolldownContext, H as Arrayable, I as TsdownHooks, L as DevtoolsOptions, M as PackageJsonWithPath, N as PackageType, O as ChunkAddonObject, P as BuildContext, R as CssOptions, S as ExportsOptions, T as AttwOptions, V as CopyOptionsFn, _ as ReportOptions, a as NoExternalFn, b as globalLogger, c as Sourcemap, d as UnusedOptions, f as UserConfig, g as Workspace, h as WithEnabled, i as InlineConfig, j as OutExtensionObject, k as OutExtensionContext, l as TreeshakingOptions, m as UserConfigFn, n as DtsOptions, o as NormalizedFormat, p as UserConfigExport, r as Format, s as ResolvedConfig, t as CIOption, u as TsdownInputOption, w as TsdownBundle, x as PublintOptions, y as Logger, z as CopyEntry } from "./types-
|
|
2
|
-
import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-
|
|
1
|
+
import { A as OutExtensionFactory, B as CopyOptions, C as RolldownChunk, D as ChunkAddonFunction, E as ChunkAddon, F as RolldownContext, H as Arrayable, I as TsdownHooks, L as DevtoolsOptions, M as PackageJsonWithPath, N as PackageType, O as ChunkAddonObject, P as BuildContext, R as CssOptions, S as ExportsOptions, T as AttwOptions, V as CopyOptionsFn, _ as ReportOptions, a as NoExternalFn, b as globalLogger, c as Sourcemap, d as UnusedOptions, f as UserConfig, g as Workspace, h as WithEnabled, i as InlineConfig, j as OutExtensionObject, k as OutExtensionContext, l as TreeshakingOptions, m as UserConfigFn, n as DtsOptions, o as NormalizedFormat, p as UserConfigExport, r as Format, s as ResolvedConfig, t as CIOption, u as TsdownInputOption, w as TsdownBundle, x as PublintOptions, y as Logger, z as CopyEntry } from "./types-Dzu__V1_.mjs";
|
|
2
|
+
import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-DG-M_Jhl.mjs";
|
|
3
3
|
import * as Rolldown from "rolldown";
|
|
4
4
|
|
|
5
5
|
//#region src/build.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as globalLogger } from "./logger-scxPimHj.mjs";
|
|
2
|
-
import { r as resolveUserConfig, t as mergeConfig } from "./options-
|
|
2
|
+
import { r as resolveUserConfig, t as mergeConfig } from "./options-BUM1iPoj.mjs";
|
|
3
3
|
import { defineConfig } from "./config.mjs";
|
|
4
|
-
import { n as buildWithConfigs, t as build } from "./build-
|
|
4
|
+
import { n as buildWithConfigs, t as build } from "./build-D6KBDCuU.mjs";
|
|
5
5
|
import { t as enableDebug } from "./debug-BkS9sORj.mjs";
|
|
6
6
|
import * as Rolldown from "rolldown";
|
|
7
7
|
|
|
@@ -5,7 +5,6 @@ import { a as fsRemove, c as stripExtname, i as fsExists, o as fsStat, s as lowe
|
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import process, { env } from "node:process";
|
|
8
|
-
import { parseEnv } from "node:util";
|
|
9
8
|
import { blue, underline } from "ansis";
|
|
10
9
|
import { createDefu } from "defu";
|
|
11
10
|
import { createDebug } from "obug";
|
|
@@ -89,9 +88,13 @@ async function resolveEntry(logger, entry, cwd, color, nameLabel) {
|
|
|
89
88
|
logger.info(nameLabel, `entry: ${color(entries.map((entry$1) => path.relative(cwd, entry$1)).join(", "))}`);
|
|
90
89
|
return entryMap;
|
|
91
90
|
}
|
|
92
|
-
|
|
91
|
+
function toObjectEntry(entry, cwd) {
|
|
93
92
|
if (typeof entry === "string") entry = [entry];
|
|
94
|
-
if (!Array.isArray(entry)) return
|
|
93
|
+
if (!Array.isArray(entry)) return resolveObjectEntry(entry, cwd);
|
|
94
|
+
return resolveArrayEntry(entry, cwd);
|
|
95
|
+
}
|
|
96
|
+
async function resolveObjectEntry(entries, cwd) {
|
|
97
|
+
return Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
|
|
95
98
|
if (!key.includes("*")) {
|
|
96
99
|
if (Array.isArray(value)) throw new TypeError(`Object entry "${key}" cannot have an array value when the key is not a glob pattern.`);
|
|
97
100
|
return [[key, value]];
|
|
@@ -105,25 +108,32 @@ async function toObjectEntry(entry, cwd) {
|
|
|
105
108
|
let valueGlobBase;
|
|
106
109
|
for (const pattern of patterns) {
|
|
107
110
|
if (pattern.startsWith("!")) continue;
|
|
108
|
-
const base
|
|
109
|
-
if (valueGlobBase === void 0) valueGlobBase = base
|
|
110
|
-
else if (valueGlobBase !== base
|
|
111
|
+
const base = picomatch.scan(pattern).base;
|
|
112
|
+
if (valueGlobBase === void 0) valueGlobBase = base;
|
|
113
|
+
else if (valueGlobBase !== base) throw new Error(`When using object entry with glob pattern key "${key}", all value glob patterns must have the same base directory.`);
|
|
111
114
|
}
|
|
112
115
|
if (valueGlobBase === void 0) throw new Error(`Cannot determine base directory for value glob patterns of key "${key}".`);
|
|
113
116
|
return files.map((file) => [slash(key.replaceAll("*", stripExtname(path.relative(valueGlobBase, file)))), path.resolve(cwd, file)]);
|
|
114
117
|
}))).flat());
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
}
|
|
119
|
+
async function resolveArrayEntry(entries, cwd) {
|
|
120
|
+
const stringEntries = [];
|
|
121
|
+
const objectEntries = [];
|
|
122
|
+
for (const e of entries) if (typeof e === "string") stringEntries.push(e);
|
|
123
|
+
else objectEntries.push(e);
|
|
124
|
+
const isGlob = stringEntries.some((e) => isDynamicPattern(e));
|
|
125
|
+
let resolvedEntries;
|
|
126
|
+
if (isGlob) resolvedEntries = (await glob(stringEntries, {
|
|
118
127
|
cwd,
|
|
119
128
|
expandDirectories: false,
|
|
120
129
|
absolute: true
|
|
121
130
|
})).map((file) => path.resolve(file));
|
|
122
|
-
else
|
|
123
|
-
const base = lowestCommonAncestor(...
|
|
124
|
-
|
|
131
|
+
else resolvedEntries = stringEntries;
|
|
132
|
+
const base = lowestCommonAncestor(...resolvedEntries);
|
|
133
|
+
const arrayEntryMap = Object.fromEntries(resolvedEntries.map((file) => {
|
|
125
134
|
return [slash(stripExtname(path.relative(base, file))), file];
|
|
126
135
|
}));
|
|
136
|
+
return Object.assign({}, arrayEntryMap, ...await Promise.all(objectEntries.map((entry) => resolveObjectEntry(entry, cwd))));
|
|
127
137
|
}
|
|
128
138
|
|
|
129
139
|
//#endregion
|
|
@@ -492,6 +502,7 @@ async function unrunImport(id) {
|
|
|
492
502
|
//#endregion
|
|
493
503
|
//#region src/config/options.ts
|
|
494
504
|
const debug = createDebug("tsdown:config:options");
|
|
505
|
+
const parseEnv = process.getBuiltinModule("node:util").parseEnv;
|
|
495
506
|
/**
|
|
496
507
|
* Resolve user config into resolved configs
|
|
497
508
|
*
|
|
@@ -543,6 +554,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
|
|
|
543
554
|
if (envPrefix.includes("")) logger.warn("`envPrefix` includes an empty string; filtering is disabled. All environment variables from the env file and process.env will be injected into the build. Ensure this is intended to avoid accidental leakage of sensitive information.");
|
|
544
555
|
const envFromProcess = filterEnv(process.env, envPrefix);
|
|
545
556
|
if (envFile) {
|
|
557
|
+
if (!parseEnv) throw new Error(`Your runtime does not support 'util.parseEnv()'. Please upgrade to Node.js v20.12.0 or later.`);
|
|
546
558
|
const resolvedPath = path.resolve(cwd, envFile);
|
|
547
559
|
logger.info(nameLabel, `env file: ${color(resolvedPath)}`);
|
|
548
560
|
env$1 = {
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as ResolvedConfig, v as ReportPlugin, w as TsdownBundle, y as Logger } from "./types-
|
|
1
|
+
import { s as ResolvedConfig, v as ReportPlugin, w as TsdownBundle, y as Logger } from "./types-Dzu__V1_.mjs";
|
|
2
2
|
import { Plugin } from "rolldown";
|
|
3
3
|
|
|
4
4
|
//#region src/features/external.d.ts
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, s as ExternalPlugin, t as WatchPlugin } from "./watch-
|
|
1
|
+
import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, s as ExternalPlugin, t as WatchPlugin } from "./watch-HGpZB4EX.mjs";
|
|
2
2
|
|
|
3
3
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as globalLogger } from "./logger-scxPimHj.mjs";
|
|
3
|
-
import { t as version } from "./package-
|
|
3
|
+
import { t as version } from "./package-Coy28bEr.mjs";
|
|
4
4
|
import { t as enableDebug } from "./debug-BkS9sORj.mjs";
|
|
5
5
|
import module from "node:module";
|
|
6
6
|
import process from "node:process";
|
|
@@ -18,7 +18,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
18
18
|
}).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("--external <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("-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) => {
|
|
19
19
|
globalLogger.level = flags.logLevel || "info";
|
|
20
20
|
globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
21
|
-
const { build: build$1 } = await import("./build-
|
|
21
|
+
const { build: build$1 } = await import("./build-CXZGeZ37.mjs");
|
|
22
22
|
if (input.length > 0) flags.entry = input;
|
|
23
23
|
await build$1(flags);
|
|
24
24
|
});
|
|
@@ -602,7 +602,7 @@ type NormalizedFormat = InternalModuleFormat;
|
|
|
602
602
|
* }
|
|
603
603
|
* ```
|
|
604
604
|
*/
|
|
605
|
-
type TsdownInputOption = string |
|
|
605
|
+
type TsdownInputOption = Arrayable<string | Record<string, Arrayable<string>>>;
|
|
606
606
|
interface Workspace {
|
|
607
607
|
/**
|
|
608
608
|
* Workspace directories. Glob patterns are supported.
|
|
@@ -3,10 +3,10 @@ import { i as fsExists, n as formatBytes } from "./format-54qVrVD4.mjs";
|
|
|
3
3
|
import { builtinModules, isBuiltin } from "node:module";
|
|
4
4
|
import { chmod } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { promisify } from "node:util";
|
|
7
6
|
import { blue, bold, dim, green, underline } from "ansis";
|
|
8
7
|
import { createDebug } from "obug";
|
|
9
8
|
import { RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
|
|
9
|
+
import { promisify } from "node:util";
|
|
10
10
|
import { and, id, importerId, include } from "rolldown/filter";
|
|
11
11
|
import { Buffer } from "node:buffer";
|
|
12
12
|
import { brotliCompress, gzip } from "node:zlib";
|
|
@@ -39,7 +39,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
|
|
|
39
39
|
external: shouldExternal,
|
|
40
40
|
moduleSideEffects: nodeBuiltinModule ? false : void 0
|
|
41
41
|
};
|
|
42
|
-
if (inlineOnly && !
|
|
42
|
+
if (inlineOnly && !nodeBuiltinModule && !path.isAbsolute(id$1)) {
|
|
43
43
|
const shouldInline = shouldExternal === "no-external" || matchPattern(id$1, inlineOnly);
|
|
44
44
|
debug$1("shouldInline: %s = %s", id$1, shouldInline);
|
|
45
45
|
if (shouldInline) return;
|
package/package.json
CHANGED
package/dist/build-BsDjbCDD.mjs
DELETED