tsdown 0.15.1 → 0.15.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/{config-Cb8AaSYW.d.mts → config-Bm-9Qi9v.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{migrate-CliKn3g9.mjs → migrate-D3HWK6xC.mjs} +1 -1
- package/dist/package-13Z93fyS.mjs +5 -0
- package/dist/plugins.d.mts +1 -1
- package/dist/plugins.mjs +1 -1
- package/dist/run.mjs +6 -6
- package/dist/{src-Cv09-2ZP.mjs → src-CJAG-MXu.mjs} +43 -65
- package/dist/{types-CttfsBjJ.d.mts → types-CDDBvUh8.d.mts} +12 -0
- package/package.json +5 -5
- package/dist/package-CGTDSgsc.mjs +0 -5
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./types-
|
|
2
|
-
import { defineConfig } from "./config-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./types-CDDBvUh8.mjs";
|
|
2
|
+
import { defineConfig } from "./config-Bm-9Qi9v.mjs";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-
|
|
2
|
-
import { defineConfig } from "./config-
|
|
1
|
+
import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-CDDBvUh8.mjs";
|
|
2
|
+
import { defineConfig } from "./config-Bm-9Qi9v.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CCGWF4al.mjs";
|
|
2
|
-
import { build, buildSingle, shimFile } from "./src-
|
|
2
|
+
import { build, buildSingle, shimFile } from "./src-CJAG-MXu.mjs";
|
|
3
3
|
import { globalLogger } from "./logger-C09npKHT.mjs";
|
|
4
4
|
|
|
5
5
|
export { build, buildSingle, defineConfig, globalLogger, shimFile };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { globalLogger } from "./logger-C09npKHT.mjs";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-13Z93fyS.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";
|
package/dist/plugins.d.mts
CHANGED
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./config-CCGWF4al.mjs";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-CJAG-MXu.mjs";
|
|
3
3
|
import "./logger-C09npKHT.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { globalLogger, resolveComma, toArray } from "./logger-C09npKHT.mjs";
|
|
3
|
-
import { version } from "./package-
|
|
3
|
+
import { version } from "./package-13Z93fyS.mjs";
|
|
4
4
|
import module from "node:module";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { dim } from "ansis";
|
|
7
7
|
import { VERSION } from "rolldown";
|
|
8
|
-
import
|
|
8
|
+
import debug from "debug";
|
|
9
9
|
import { cac } from "cac";
|
|
10
10
|
|
|
11
11
|
//#region src/cli.ts
|
|
@@ -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-D3HWK6xC.mjs");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
|
@@ -31,10 +31,10 @@ async function runCLI() {
|
|
|
31
31
|
let namespace;
|
|
32
32
|
if (cli.options.debug === true) namespace = "tsdown:*";
|
|
33
33
|
else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
|
|
34
|
-
const enabled =
|
|
34
|
+
const enabled = debug.disable();
|
|
35
35
|
if (enabled) namespace += `,${enabled}`;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
debug.enable(namespace);
|
|
37
|
+
debug("tsdown:debug")("Debugging enabled", namespace);
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
40
|
await cli.runMatchedCommand();
|
|
@@ -11,7 +11,7 @@ import child_process from "node:child_process";
|
|
|
11
11
|
import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
12
12
|
import { tmpdir } from "node:os";
|
|
13
13
|
import { promisify } from "node:util";
|
|
14
|
-
import
|
|
14
|
+
import debug from "debug";
|
|
15
15
|
import coerce from "semver/functions/coerce.js";
|
|
16
16
|
import satisfies from "semver/functions/satisfies.js";
|
|
17
17
|
import { glob } from "tinyglobby";
|
|
@@ -67,7 +67,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
67
67
|
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/features/attw.ts
|
|
70
|
-
const debug$
|
|
70
|
+
const debug$8 = debug("tsdown:attw");
|
|
71
71
|
const exec$1 = promisify(child_process.exec);
|
|
72
72
|
/**
|
|
73
73
|
* ATTW profiles.
|
|
@@ -113,7 +113,7 @@ async function attw(options) {
|
|
|
113
113
|
}
|
|
114
114
|
const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
|
|
115
115
|
const t = performance.now();
|
|
116
|
-
debug$
|
|
116
|
+
debug$8("Running attw check");
|
|
117
117
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
118
118
|
let attwCore;
|
|
119
119
|
try {
|
|
@@ -146,7 +146,7 @@ async function attw(options) {
|
|
|
146
146
|
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
147
147
|
} catch (error) {
|
|
148
148
|
options.logger.error("ATTW check failed:", error);
|
|
149
|
-
debug$
|
|
149
|
+
debug$8("Found errors, setting exit code to 1");
|
|
150
150
|
process.exitCode = 1;
|
|
151
151
|
} finally {
|
|
152
152
|
await fsRemove(tempDir);
|
|
@@ -170,7 +170,7 @@ function warnLegacyCJS(config) {
|
|
|
170
170
|
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/features/clean.ts
|
|
173
|
-
const debug$
|
|
173
|
+
const debug$7 = debug("tsdown:clean");
|
|
174
174
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
175
175
|
async function cleanOutDir(configs) {
|
|
176
176
|
const removes = /* @__PURE__ */ new Set();
|
|
@@ -187,10 +187,10 @@ async function cleanOutDir(configs) {
|
|
|
187
187
|
if (!removes.size) return;
|
|
188
188
|
globalLogger.info(`Cleaning ${removes.size} files`);
|
|
189
189
|
await Promise.all([...removes].map(async (file) => {
|
|
190
|
-
debug$
|
|
190
|
+
debug$7("Removing", file);
|
|
191
191
|
await fsRemove(file);
|
|
192
192
|
}));
|
|
193
|
-
debug$
|
|
193
|
+
debug$7("Removed %d files", removes.size);
|
|
194
194
|
}
|
|
195
195
|
function resolveClean(clean, outDir, cwd) {
|
|
196
196
|
if (clean === true) clean = [slash(outDir)];
|
|
@@ -348,7 +348,7 @@ async function createHooks$1(options) {
|
|
|
348
348
|
|
|
349
349
|
//#endregion
|
|
350
350
|
//#region src/features/publint.ts
|
|
351
|
-
const debug$
|
|
351
|
+
const debug$6 = debug("tsdown:publint");
|
|
352
352
|
async function publint(options) {
|
|
353
353
|
if (!options.publint) return;
|
|
354
354
|
if (!options.pkg) {
|
|
@@ -356,11 +356,11 @@ async function publint(options) {
|
|
|
356
356
|
return;
|
|
357
357
|
}
|
|
358
358
|
const t = performance.now();
|
|
359
|
-
debug$
|
|
359
|
+
debug$6("Running publint");
|
|
360
360
|
const { publint: publint$1 } = await import("publint");
|
|
361
361
|
const { formatMessage } = await import("publint/utils");
|
|
362
362
|
const { messages } = await publint$1(options.publint === true ? {} : options.publint);
|
|
363
|
-
debug$
|
|
363
|
+
debug$6("Found %d issues", messages.length);
|
|
364
364
|
if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
365
365
|
let hasError = false;
|
|
366
366
|
for (const message of messages) {
|
|
@@ -374,7 +374,7 @@ async function publint(options) {
|
|
|
374
374
|
options.logger[logType](formattedMessage);
|
|
375
375
|
}
|
|
376
376
|
if (hasError) {
|
|
377
|
-
debug$
|
|
377
|
+
debug$6("Found errors, setting exit code to 1");
|
|
378
378
|
process.exitCode = 1;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
@@ -429,31 +429,6 @@ function resolvePackageTarget(pkg) {
|
|
|
429
429
|
if (nodeMinVersion.version === "0.0.0") return;
|
|
430
430
|
return `node${nodeMinVersion.version}`;
|
|
431
431
|
}
|
|
432
|
-
let warned = false;
|
|
433
|
-
function RuntimeHelperCheckPlugin(logger, targets) {
|
|
434
|
-
return {
|
|
435
|
-
name: "tsdown:runtime-helper-check",
|
|
436
|
-
resolveId: {
|
|
437
|
-
filter: { id: /^@oxc-project\/runtime/ },
|
|
438
|
-
async handler(id, ...args) {
|
|
439
|
-
const EXTERNAL = {
|
|
440
|
-
id,
|
|
441
|
-
external: true
|
|
442
|
-
};
|
|
443
|
-
if (warned) return EXTERNAL;
|
|
444
|
-
const resolved = await this.resolve(id, ...args);
|
|
445
|
-
if (!resolved) {
|
|
446
|
-
if (!warned) {
|
|
447
|
-
warned = true;
|
|
448
|
-
logger.warn(`The target environment (${targets.join(", ")}) requires runtime helpers from ${blue`@oxc-project/runtime`}. Please install it to ensure all necessary polyfills are included.\nFor more information, visit: https://tsdown.dev/options/target#runtime-helpers`);
|
|
449
|
-
}
|
|
450
|
-
return EXTERNAL;
|
|
451
|
-
}
|
|
452
|
-
return resolved;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
432
|
|
|
458
433
|
//#endregion
|
|
459
434
|
//#region src/features/tsconfig.ts
|
|
@@ -485,11 +460,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
|
|
|
485
460
|
|
|
486
461
|
//#endregion
|
|
487
462
|
//#region src/utils/package.ts
|
|
488
|
-
const debug$
|
|
463
|
+
const debug$5 = debug("tsdown:package");
|
|
489
464
|
async function readPackageJson(dir) {
|
|
490
465
|
const packageJsonPath = up$1({ cwd: dir });
|
|
491
466
|
if (!packageJsonPath) return;
|
|
492
|
-
debug$
|
|
467
|
+
debug$5("Reading package.json:", packageJsonPath);
|
|
493
468
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
494
469
|
return {
|
|
495
470
|
...JSON.parse(contents),
|
|
@@ -615,7 +590,7 @@ async function nativeImport(id) {
|
|
|
615
590
|
|
|
616
591
|
//#endregion
|
|
617
592
|
//#region src/options/index.ts
|
|
618
|
-
const debug$
|
|
593
|
+
const debug$4 = debug("tsdown:options");
|
|
619
594
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
620
595
|
"**/node_modules/**",
|
|
621
596
|
"**/dist/**",
|
|
@@ -623,20 +598,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
623
598
|
"**/t?(e)mp/**"
|
|
624
599
|
];
|
|
625
600
|
async function resolveOptions(options) {
|
|
626
|
-
debug$
|
|
601
|
+
debug$4("options %O", options);
|
|
627
602
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
628
603
|
const files = [];
|
|
629
604
|
if (file) {
|
|
630
605
|
files.push(file);
|
|
631
|
-
debug$
|
|
632
|
-
debug$
|
|
633
|
-
} else debug$
|
|
606
|
+
debug$4("loaded root config file %s", file);
|
|
607
|
+
debug$4("root configs %O", rootConfigs);
|
|
608
|
+
} else debug$4("no root config file found");
|
|
634
609
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
635
610
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
636
611
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
637
612
|
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
|
|
638
613
|
}))).flat();
|
|
639
|
-
debug$
|
|
614
|
+
debug$4("resolved configs %O", configs);
|
|
640
615
|
return {
|
|
641
616
|
configs,
|
|
642
617
|
files
|
|
@@ -679,16 +654,16 @@ async function resolveWorkspace(config, options) {
|
|
|
679
654
|
const files = [];
|
|
680
655
|
return {
|
|
681
656
|
configs: (await Promise.all(packages.map(async (cwd) => {
|
|
682
|
-
debug$
|
|
657
|
+
debug$4("loading workspace config %s", cwd);
|
|
683
658
|
const { configs, file } = await loadConfigFile({
|
|
684
659
|
...options,
|
|
685
660
|
config: workspaceConfig,
|
|
686
661
|
cwd
|
|
687
662
|
}, cwd);
|
|
688
663
|
if (file) {
|
|
689
|
-
debug$
|
|
664
|
+
debug$4("loaded workspace config file %s", file);
|
|
690
665
|
files.push(file);
|
|
691
|
-
} else debug$
|
|
666
|
+
} else debug$4("no workspace config file found in %s", cwd);
|
|
692
667
|
return configs.map((config$1) => ({
|
|
693
668
|
...normalized,
|
|
694
669
|
cwd,
|
|
@@ -699,7 +674,7 @@ async function resolveWorkspace(config, options) {
|
|
|
699
674
|
};
|
|
700
675
|
}
|
|
701
676
|
async function resolveConfig(userConfig) {
|
|
702
|
-
let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = false, customLogger, 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, cjsDefault = true } = userConfig;
|
|
677
|
+
let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = false, customLogger, 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, cjsDefault = true, globImport = true } = userConfig;
|
|
703
678
|
const logger = createLogger(logLevel, {
|
|
704
679
|
customLogger,
|
|
705
680
|
failOnWarn
|
|
@@ -770,7 +745,8 @@ async function resolveConfig(userConfig) {
|
|
|
770
745
|
exports,
|
|
771
746
|
unbundle,
|
|
772
747
|
nodeProtocol,
|
|
773
|
-
cjsDefault
|
|
748
|
+
cjsDefault,
|
|
749
|
+
globImport
|
|
774
750
|
};
|
|
775
751
|
}
|
|
776
752
|
async function mergeUserOptions(defaults, user, args) {
|
|
@@ -783,7 +759,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
783
759
|
|
|
784
760
|
//#endregion
|
|
785
761
|
//#region src/features/external.ts
|
|
786
|
-
const debug$
|
|
762
|
+
const debug$3 = debug("tsdown:external");
|
|
787
763
|
function ExternalPlugin(options) {
|
|
788
764
|
const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
|
|
789
765
|
return {
|
|
@@ -810,7 +786,7 @@ function ExternalPlugin(options) {
|
|
|
810
786
|
}
|
|
811
787
|
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
812
788
|
if (shouldExternal) {
|
|
813
|
-
debug$
|
|
789
|
+
debug$3("External dependency:", id);
|
|
814
790
|
return {
|
|
815
791
|
id,
|
|
816
792
|
external: shouldExternal,
|
|
@@ -934,12 +910,12 @@ function resolveChunkFilename({ outExtensions, fixedExtension, pkg, hash }, inpu
|
|
|
934
910
|
jsExtension = js;
|
|
935
911
|
dtsExtension = dts;
|
|
936
912
|
}
|
|
937
|
-
jsExtension
|
|
913
|
+
jsExtension ??= `.${resolveJsOutputExtension(packageType, format, fixedExtension)}`;
|
|
938
914
|
const suffix = format === "iife" || format === "umd" ? `.${format}` : "";
|
|
939
915
|
return [createChunkFilename(`[name]${suffix}`, jsExtension, dtsExtension), createChunkFilename(`[name]${suffix}${hash ? "-[hash]" : ""}`, jsExtension, dtsExtension)];
|
|
940
916
|
}
|
|
941
917
|
function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
942
|
-
if (
|
|
918
|
+
if (dtsExtension === void 0) return `${basename}${jsExtension}`;
|
|
943
919
|
return (chunk) => {
|
|
944
920
|
return `${basename}${chunk.name.endsWith(".d") ? dtsExtension : jsExtension}`;
|
|
945
921
|
};
|
|
@@ -971,7 +947,7 @@ function formatBytes(bytes) {
|
|
|
971
947
|
|
|
972
948
|
//#endregion
|
|
973
949
|
//#region src/features/report.ts
|
|
974
|
-
const debug$
|
|
950
|
+
const debug$2 = debug("tsdown:report");
|
|
975
951
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
976
952
|
const gzipAsync = promisify(gzip);
|
|
977
953
|
function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
@@ -1012,19 +988,19 @@ function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
|
1012
988
|
};
|
|
1013
989
|
}
|
|
1014
990
|
async function calcSize(options, chunk) {
|
|
1015
|
-
debug$
|
|
991
|
+
debug$2(`Calculating size for`, chunk.fileName);
|
|
1016
992
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
1017
993
|
const raw = Buffer.byteLength(content, "utf8");
|
|
1018
|
-
debug$
|
|
994
|
+
debug$2("[size]", chunk.fileName, raw);
|
|
1019
995
|
let gzip$1 = Infinity;
|
|
1020
996
|
let brotli = Infinity;
|
|
1021
|
-
if (raw > (options.maxCompressSize ?? 1e6)) debug$
|
|
997
|
+
if (raw > (options.maxCompressSize ?? 1e6)) debug$2(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
1022
998
|
else {
|
|
1023
999
|
gzip$1 = (await gzipAsync(content)).length;
|
|
1024
|
-
debug$
|
|
1000
|
+
debug$2("[gzip]", chunk.fileName, gzip$1);
|
|
1025
1001
|
if (options.brotli) {
|
|
1026
1002
|
brotli = (await brotliCompressAsync(content)).length;
|
|
1027
|
-
debug$
|
|
1003
|
+
debug$2("[brotli]", chunk.fileName, brotli);
|
|
1028
1004
|
}
|
|
1029
1005
|
}
|
|
1030
1006
|
return {
|
|
@@ -1071,7 +1047,7 @@ function getShimsInject(format, platform) {
|
|
|
1071
1047
|
|
|
1072
1048
|
//#endregion
|
|
1073
1049
|
//#region src/features/rolldown.ts
|
|
1074
|
-
const debug =
|
|
1050
|
+
const debug$1 = debug("tsdown:rolldown");
|
|
1075
1051
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
1076
1052
|
const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
|
|
1077
1053
|
const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
|
|
@@ -1079,11 +1055,11 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
|
1079
1055
|
...inputOptions,
|
|
1080
1056
|
output: outputOptions
|
|
1081
1057
|
};
|
|
1082
|
-
debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1058
|
+
debug$1("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1083
1059
|
return rolldownConfig;
|
|
1084
1060
|
}
|
|
1085
1061
|
async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
1086
|
-
const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer } = config;
|
|
1062
|
+
const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer, globImport } = config;
|
|
1087
1063
|
const plugins = [];
|
|
1088
1064
|
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
1089
1065
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
@@ -1107,8 +1083,9 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
1107
1083
|
const { Unused } = await import("unplugin-unused");
|
|
1108
1084
|
plugins.push(Unused.rolldown(unused === true ? {} : unused));
|
|
1109
1085
|
}
|
|
1110
|
-
if (target) plugins.push(
|
|
1111
|
-
plugins.push(ShebangPlugin(logger, cwd, name, isMultiFormat)
|
|
1086
|
+
if (target) plugins.push(await LightningCSSPlugin({ target }));
|
|
1087
|
+
plugins.push(ShebangPlugin(logger, cwd, name, isMultiFormat));
|
|
1088
|
+
if (globImport) plugins.push(importGlobPlugin());
|
|
1112
1089
|
}
|
|
1113
1090
|
if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(report, logger, cwd, cjsDts, name, isMultiFormat));
|
|
1114
1091
|
if (!cjsDts) plugins.push(userPlugins);
|
|
@@ -1136,7 +1113,8 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
1136
1113
|
onLog: cjsDefault ? (level, log, defaultHandler) => {
|
|
1137
1114
|
if (log.code === "MIXED_EXPORT") return;
|
|
1138
1115
|
defaultHandler(level, log);
|
|
1139
|
-
} : void 0
|
|
1116
|
+
} : void 0,
|
|
1117
|
+
experimental: { resolveNewUrlToAsset: true }
|
|
1140
1118
|
}, config.inputOptions, [format, { cjsDts }]);
|
|
1141
1119
|
}
|
|
1142
1120
|
async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
|
|
@@ -292,6 +292,9 @@ interface Options {
|
|
|
292
292
|
*/
|
|
293
293
|
nodeProtocol?: "strip" | boolean;
|
|
294
294
|
plugins?: InputOptions["plugins"];
|
|
295
|
+
/**
|
|
296
|
+
* Use with caution; ensure you understand the implications.
|
|
297
|
+
*/
|
|
295
298
|
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
|
|
296
299
|
cjsDts: boolean;
|
|
297
300
|
}) => Awaitable<InputOptions | void | null>);
|
|
@@ -347,6 +350,9 @@ interface Options {
|
|
|
347
350
|
* @default true
|
|
348
351
|
*/
|
|
349
352
|
cjsDefault?: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Use with caution; ensure you understand the implications.
|
|
355
|
+
*/
|
|
350
356
|
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat, context: {
|
|
351
357
|
cjsDts: boolean;
|
|
352
358
|
}) => Awaitable<OutputOptions | void | null>);
|
|
@@ -438,6 +444,12 @@ interface Options {
|
|
|
438
444
|
*/
|
|
439
445
|
report?: boolean | ReportOptions;
|
|
440
446
|
/**
|
|
447
|
+
* `import.meta.glob` support.
|
|
448
|
+
* @see https://vite.dev/guide/features.html#glob-import
|
|
449
|
+
* @default true
|
|
450
|
+
*/
|
|
451
|
+
globImport?: boolean;
|
|
452
|
+
/**
|
|
441
453
|
* **[experimental]** Generate package exports for `package.json`.
|
|
442
454
|
*
|
|
443
455
|
* This will set the `main`, `module`, `types`, `exports` fields in `package.json`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"ansis": "^4.1.0",
|
|
73
73
|
"cac": "^6.7.14",
|
|
74
74
|
"chokidar": "^4.0.3",
|
|
75
|
-
"debug": "^4.4.
|
|
75
|
+
"debug": "^4.4.3",
|
|
76
76
|
"diff": "^8.0.2",
|
|
77
77
|
"empathic": "^2.0.0",
|
|
78
78
|
"hookable": "^5.5.3",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"@arethetypeswrong/core": "^0.18.2",
|
|
89
89
|
"@sxzz/eslint-config": "^7.1.4",
|
|
90
90
|
"@sxzz/prettier-config": "^2.2.4",
|
|
91
|
-
"@sxzz/test-utils": "^0.5.
|
|
91
|
+
"@sxzz/test-utils": "^0.5.11",
|
|
92
92
|
"@types/debug": "^4.1.12",
|
|
93
|
-
"@types/node": "^24.
|
|
93
|
+
"@types/node": "^24.5.0",
|
|
94
94
|
"@types/semver": "^7.7.1",
|
|
95
95
|
"@unocss/eslint-plugin": "^66.5.1",
|
|
96
96
|
"@vueuse/core": "^13.9.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"tsx": "^4.20.5",
|
|
104
104
|
"typescript": "~5.9.2",
|
|
105
105
|
"unocss": "^66.5.1",
|
|
106
|
-
"unplugin-lightningcss": "^0.4.
|
|
106
|
+
"unplugin-lightningcss": "^0.4.3",
|
|
107
107
|
"unplugin-unused": "^0.5.3",
|
|
108
108
|
"vite": "npm:rolldown-vite@latest",
|
|
109
109
|
"vitest": "^3.2.4"
|