tsdown 0.5.3 → 0.5.4
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-0LDjKwZ7.js +8 -0
- package/dist/config.d-DWijXKYW.d.ts +77 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +3 -0
- package/dist/external-QIv-o_HK.js +33 -0
- package/dist/index.d.ts +7 -75
- package/dist/index.js +15 -9
- package/dist/{logger-Pk57TMWT.js → logger-ByXVlJsC.js} +1 -1
- package/dist/{plugins.d-CKHmQhmh.d.ts → plugins.d-DtLTz4jh.d.ts} +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -2
- package/dist/run.js +2 -2
- package/package.json +16 -15
- package/dist/external-9r3oq3tH.js +0 -28
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { E as External } from './plugins.d-DtLTz4jh.js';
|
|
2
|
+
import { InputOptions, ModuleFormat, OutputOptions, InternalModuleFormat } from 'rolldown';
|
|
3
|
+
import { Options as Options$1 } from 'unplugin-isolated-decl';
|
|
4
|
+
import { Options as Options$2 } from 'unplugin-unused';
|
|
5
|
+
|
|
6
|
+
type Overwrite<
|
|
7
|
+
T,
|
|
8
|
+
U
|
|
9
|
+
> = Omit<T, keyof U> & U;
|
|
10
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
11
|
+
type MarkPartial<
|
|
12
|
+
T,
|
|
13
|
+
K extends keyof T
|
|
14
|
+
> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
15
|
+
type Arrayable<T> = T | T[];
|
|
16
|
+
|
|
17
|
+
type Sourcemap = boolean | "inline" | "hidden";
|
|
18
|
+
/**
|
|
19
|
+
* Options for tsdown.
|
|
20
|
+
*/
|
|
21
|
+
interface Options {
|
|
22
|
+
entry?: InputOptions["input"];
|
|
23
|
+
format?: ModuleFormat | ModuleFormat[];
|
|
24
|
+
globalName?: string;
|
|
25
|
+
plugins?: InputOptions["plugins"];
|
|
26
|
+
external?: External;
|
|
27
|
+
outDir?: string;
|
|
28
|
+
clean?: boolean | string[];
|
|
29
|
+
silent?: boolean;
|
|
30
|
+
config?: boolean | string;
|
|
31
|
+
sourcemap?: Sourcemap;
|
|
32
|
+
alias?: Record<string, string>;
|
|
33
|
+
/** @default true */
|
|
34
|
+
treeshake?: boolean;
|
|
35
|
+
/** @default false */
|
|
36
|
+
minify?: boolean;
|
|
37
|
+
target?: string | string[];
|
|
38
|
+
define?: Record<string, string>;
|
|
39
|
+
/** @default 'node' */
|
|
40
|
+
platform?: "node" | "neutral" | "browser";
|
|
41
|
+
shims?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
44
|
+
*/
|
|
45
|
+
dts?: boolean | Options$1;
|
|
46
|
+
/** @default true */
|
|
47
|
+
bundleDts?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Enable unused dependencies check with `unplugin-unused` (experimental)
|
|
50
|
+
*/
|
|
51
|
+
unused?: boolean | Options$2;
|
|
52
|
+
watch?: boolean | string | string[];
|
|
53
|
+
inputOptions?: InputOptions | ((options: InputOptions, format: ModuleFormat) => MaybePromise<InputOptions | void | null>);
|
|
54
|
+
outputOptions?: OutputOptions | ((options: OutputOptions, format: ModuleFormat) => MaybePromise<OutputOptions | void | null>);
|
|
55
|
+
onSuccess?: () => void | Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Skip bundling node_modules.
|
|
58
|
+
*/
|
|
59
|
+
skipNodeModulesBundle?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Options without specifying config file path.
|
|
63
|
+
*/
|
|
64
|
+
type Config = Arrayable<Omit<Options, "config">>;
|
|
65
|
+
type NormalizedFormat = Exclude<InternalModuleFormat, "app"> | "experimental-app";
|
|
66
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "globalName" | "inputOptions" | "outputOptions" | "minify" | "target" | "define" | "alias" | "external" | "onSuccess" | "dts">, {
|
|
67
|
+
format: NormalizedFormat[];
|
|
68
|
+
clean: string[] | false;
|
|
69
|
+
dts: false | Options$1;
|
|
70
|
+
}>, "config">;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Defines the configuration for tsdown.
|
|
74
|
+
*/
|
|
75
|
+
declare function defineConfig(options: Config): Config;
|
|
76
|
+
|
|
77
|
+
export { type Config as C, type Options as O, type ResolvedOptions as R, defineConfig as d };
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Debug from "debug";
|
|
2
|
+
|
|
3
|
+
//#region src/features/external.ts
|
|
4
|
+
const debug = Debug("tsdown:external");
|
|
5
|
+
function ExternalPlugin(pkg, skipNodeModulesBundle) {
|
|
6
|
+
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
7
|
+
return {
|
|
8
|
+
name: "tsdown:external",
|
|
9
|
+
async resolveId(id, importer, { isEntry }) {
|
|
10
|
+
if (isEntry) return;
|
|
11
|
+
let shouldExternal = false;
|
|
12
|
+
if (skipNodeModulesBundle) {
|
|
13
|
+
const resolved = await this.resolve(id);
|
|
14
|
+
if (!resolved) return;
|
|
15
|
+
shouldExternal = resolved.external || /[\\/]node_modules[\\/]/.test(resolved.id);
|
|
16
|
+
}
|
|
17
|
+
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
18
|
+
if (shouldExternal) {
|
|
19
|
+
debug("External dependency:", id);
|
|
20
|
+
return {
|
|
21
|
+
id,
|
|
22
|
+
external: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function getProductionDeps(pkg) {
|
|
29
|
+
return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ExternalPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,75 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Options as Options$1 } from 'unplugin-isolated-decl';
|
|
4
|
-
import { Options as Options$2 } from 'unplugin-unused';
|
|
1
|
+
import { O as Options, R as ResolvedOptions } from './config.d-DWijXKYW.js';
|
|
2
|
+
export { C as Config, d as defineConfig } from './config.d-DWijXKYW.js';
|
|
5
3
|
import { ConsolaInstance } from 'consola';
|
|
4
|
+
import './plugins.d-DtLTz4jh.js';
|
|
6
5
|
import 'pkg-types';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
U
|
|
11
|
-
> = Omit<T, keyof U> & U;
|
|
12
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
13
|
-
type MarkPartial<
|
|
14
|
-
T,
|
|
15
|
-
K extends keyof T
|
|
16
|
-
> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
17
|
-
type Arrayable<T> = T | T[];
|
|
18
|
-
|
|
19
|
-
type Sourcemap = boolean | "inline" | "hidden";
|
|
20
|
-
/**
|
|
21
|
-
* Options for tsdown.
|
|
22
|
-
*/
|
|
23
|
-
interface Options {
|
|
24
|
-
entry?: InputOptions["input"];
|
|
25
|
-
format?: ModuleFormat | ModuleFormat[];
|
|
26
|
-
globalName?: string;
|
|
27
|
-
plugins?: InputOptions["plugins"];
|
|
28
|
-
external?: External;
|
|
29
|
-
outDir?: string;
|
|
30
|
-
clean?: boolean | string[];
|
|
31
|
-
silent?: boolean;
|
|
32
|
-
config?: boolean | string;
|
|
33
|
-
sourcemap?: Sourcemap;
|
|
34
|
-
alias?: Record<string, string>;
|
|
35
|
-
/** @default true */
|
|
36
|
-
treeshake?: boolean;
|
|
37
|
-
/** @default false */
|
|
38
|
-
minify?: boolean;
|
|
39
|
-
target?: string | string[];
|
|
40
|
-
define?: Record<string, string>;
|
|
41
|
-
/** @default 'node' */
|
|
42
|
-
platform?: "node" | "neutral" | "browser";
|
|
43
|
-
shims?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
46
|
-
*/
|
|
47
|
-
dts?: boolean | Options$1;
|
|
48
|
-
/** @default true */
|
|
49
|
-
bundleDts?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Enable unused dependencies check with `unplugin-unused` (experimental)
|
|
52
|
-
*/
|
|
53
|
-
unused?: boolean | Options$2;
|
|
54
|
-
watch?: boolean | string | string[];
|
|
55
|
-
inputOptions?: InputOptions | ((options: InputOptions, format: ModuleFormat) => MaybePromise<InputOptions | void | null>);
|
|
56
|
-
outputOptions?: OutputOptions | ((options: OutputOptions, format: ModuleFormat) => MaybePromise<OutputOptions | void | null>);
|
|
57
|
-
onSuccess?: () => void | Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Skip bundling node_modules.
|
|
60
|
-
*/
|
|
61
|
-
skipNodeModulesBundle?: boolean;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Options without specifying config file path.
|
|
65
|
-
*/
|
|
66
|
-
type Config = Arrayable<Omit<Options, "config">>;
|
|
67
|
-
type NormalizedFormat = Exclude<InternalModuleFormat, "app"> | "experimental-app";
|
|
68
|
-
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "globalName" | "inputOptions" | "outputOptions" | "minify" | "target" | "define" | "alias" | "external" | "onSuccess" | "dts">, {
|
|
69
|
-
format: NormalizedFormat[];
|
|
70
|
-
clean: string[] | false;
|
|
71
|
-
dts: false | Options$1;
|
|
72
|
-
}>, "config">;
|
|
6
|
+
import 'rolldown';
|
|
7
|
+
import 'unplugin-isolated-decl';
|
|
8
|
+
import 'unplugin-unused';
|
|
73
9
|
|
|
74
10
|
/**
|
|
75
11
|
* Logger instance
|
|
@@ -87,9 +23,5 @@ declare const pkgRoot: string;
|
|
|
87
23
|
* @param resolved Resolved options
|
|
88
24
|
*/
|
|
89
25
|
declare function buildSingle(resolved: ResolvedOptions): Promise<(() => Promise<void>) | undefined>;
|
|
90
|
-
/**
|
|
91
|
-
* Defines the configuration for tsdown.
|
|
92
|
-
*/
|
|
93
|
-
declare function defineConfig(options: Config): Config;
|
|
94
26
|
|
|
95
|
-
export {
|
|
27
|
+
export { Options, build, buildSingle, logger, pkgRoot };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { defineConfig } from "./config-0LDjKwZ7.js";
|
|
2
|
+
import { debug, logger } from "./logger-ByXVlJsC.js";
|
|
3
|
+
import { ExternalPlugin } from "./external-QIv-o_HK.js";
|
|
3
4
|
import path, { dirname, normalize, sep } from "node:path";
|
|
4
5
|
import process from "node:process";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -8,6 +9,7 @@ import { transformPlugin } from "rolldown/experimental";
|
|
|
8
9
|
import { IsolatedDecl } from "unplugin-isolated-decl";
|
|
9
10
|
import { Unused } from "unplugin-unused";
|
|
10
11
|
import { access, readdir, rm, stat } from "node:fs/promises";
|
|
12
|
+
import Debug from "debug";
|
|
11
13
|
import { glob } from "tinyglobby";
|
|
12
14
|
import { rollup } from "rollup";
|
|
13
15
|
import DtsPlugin from "rollup-plugin-dts";
|
|
@@ -47,6 +49,7 @@ else {
|
|
|
47
49
|
|
|
48
50
|
//#endregion
|
|
49
51
|
//#region src/features/clean.ts
|
|
52
|
+
const debug$1 = Debug("tsdown:clean");
|
|
50
53
|
async function cleanOutDir(cwd, patterns) {
|
|
51
54
|
const files = [];
|
|
52
55
|
if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path.resolve(cwd, file)));
|
|
@@ -56,7 +59,7 @@ async function cleanOutDir(cwd, patterns) {
|
|
|
56
59
|
}));
|
|
57
60
|
logger.info("Cleaning output folder");
|
|
58
61
|
for (const file of files) {
|
|
59
|
-
debug("
|
|
62
|
+
debug$1("Removing", file);
|
|
60
63
|
await fsRemove(file);
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -295,6 +298,7 @@ function normalizeFormat(format) {
|
|
|
295
298
|
}
|
|
296
299
|
});
|
|
297
300
|
}
|
|
301
|
+
let loaded = false;
|
|
298
302
|
async function loadConfigFile(options) {
|
|
299
303
|
let { config: filePath } = options;
|
|
300
304
|
if (filePath === false) return [[]];
|
|
@@ -309,6 +313,7 @@ async function loadConfigFile(options) {
|
|
|
309
313
|
cwd = path.dirname(filePath);
|
|
310
314
|
} else cwd = resolved;
|
|
311
315
|
}
|
|
316
|
+
const nativeLoader = !loaded && process.features.typescript;
|
|
312
317
|
const { config, sources } = await loadConfig({
|
|
313
318
|
sources: overrideConfig ? [{
|
|
314
319
|
files: filePath,
|
|
@@ -332,8 +337,12 @@ async function loadConfigFile(options) {
|
|
|
332
337
|
}],
|
|
333
338
|
cwd,
|
|
334
339
|
defaults: {},
|
|
335
|
-
importx: {
|
|
336
|
-
|
|
340
|
+
importx: {
|
|
341
|
+
loader: nativeLoader ? "native" : "bundle-require",
|
|
342
|
+
fallbackLoaders: [...nativeLoader ? ["bundle-require"] : [], "jiti"],
|
|
343
|
+
cache: loaded ? false : null
|
|
344
|
+
}
|
|
345
|
+
}).finally(() => loaded = true);
|
|
337
346
|
if (sources.length > 0) logger.info(`Using tsdown config: ${pc.underline(sources.join(", "))}`);
|
|
338
347
|
const file = sources[0];
|
|
339
348
|
return [toArray(config), file];
|
|
@@ -386,7 +395,7 @@ async function buildSingle(resolved) {
|
|
|
386
395
|
platform,
|
|
387
396
|
define,
|
|
388
397
|
plugins: [
|
|
389
|
-
pkg && ExternalPlugin(pkg, resolved.skipNodeModulesBundle),
|
|
398
|
+
(pkg || resolved.skipNodeModulesBundle) && ExternalPlugin(pkg, resolved.skipNodeModulesBundle),
|
|
390
399
|
unused && Unused.rolldown(unused === true ? {} : unused),
|
|
391
400
|
dts && IsolatedDecl.rolldown({
|
|
392
401
|
...dts,
|
|
@@ -417,9 +426,6 @@ async function buildSingle(resolved) {
|
|
|
417
426
|
await onSuccess?.();
|
|
418
427
|
}
|
|
419
428
|
}
|
|
420
|
-
function defineConfig(options) {
|
|
421
|
-
return options;
|
|
422
|
-
}
|
|
423
429
|
|
|
424
430
|
//#endregion
|
|
425
431
|
export { build, buildSingle, defineConfig, logger, pkgRoot };
|
|
@@ -2,6 +2,6 @@ import { PackageJson } from 'pkg-types';
|
|
|
2
2
|
import { Plugin, InputOptions } from 'rolldown';
|
|
3
3
|
|
|
4
4
|
type External = InputOptions["external"];
|
|
5
|
-
declare function ExternalPlugin(pkg
|
|
5
|
+
declare function ExternalPlugin(pkg?: PackageJson, skipNodeModulesBundle?: boolean): Plugin;
|
|
6
6
|
|
|
7
7
|
export { type External as E, ExternalPlugin as a };
|
package/dist/plugins.d.ts
CHANGED
package/dist/plugins.js
CHANGED
package/dist/run.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { logger } from "./logger-
|
|
1
|
+
import { logger } from "./logger-ByXVlJsC.js";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { VERSION } from "rolldown";
|
|
4
4
|
import pc from "picocolors";
|
|
5
5
|
import { cac } from "cac";
|
|
6
6
|
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "0.5.
|
|
8
|
+
var version = "0.5.4";
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/cli.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "An even faster bundler powered by Rolldown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": "./dist/index.js",
|
|
25
|
+
"./config": "./dist/config.js",
|
|
25
26
|
"./plugins": "./dist/plugins.js",
|
|
26
27
|
"./package.json": "./package.json"
|
|
27
28
|
},
|
|
@@ -42,34 +43,34 @@
|
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"cac": "^6.7.14",
|
|
44
45
|
"chokidar": "^4.0.3",
|
|
45
|
-
"consola": "^3.
|
|
46
|
+
"consola": "^3.4.0",
|
|
46
47
|
"debug": "^4.4.0",
|
|
47
48
|
"picocolors": "^1.1.1",
|
|
48
|
-
"pkg-types": "^1.3.
|
|
49
|
+
"pkg-types": "^1.3.1",
|
|
49
50
|
"rolldown": "^1.0.0-beta.1",
|
|
50
|
-
"rollup": "^4.
|
|
51
|
+
"rollup": "^4.31.0",
|
|
51
52
|
"rollup-plugin-dts": "^6.1.1",
|
|
52
53
|
"tinyglobby": "^0.2.10",
|
|
53
|
-
"unconfig": "^0.6.
|
|
54
|
-
"unplugin-isolated-decl": "^0.10.
|
|
54
|
+
"unconfig": "^0.6.1",
|
|
55
|
+
"unplugin-isolated-decl": "^0.10.5",
|
|
55
56
|
"unplugin-unused": "^0.3.0"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
|
-
"@sxzz/eslint-config": "^4.
|
|
59
|
-
"@sxzz/prettier-config": "^2.0
|
|
60
|
-
"@sxzz/test-utils": "^0.
|
|
59
|
+
"@sxzz/eslint-config": "^4.6.0",
|
|
60
|
+
"@sxzz/prettier-config": "^2.1.0",
|
|
61
|
+
"@sxzz/test-utils": "^0.4.0",
|
|
61
62
|
"@types/debug": "^4.1.12",
|
|
62
|
-
"@types/node": "^22.10.
|
|
63
|
-
"bumpp": "^9.
|
|
64
|
-
"eslint": "^9.
|
|
65
|
-
"oxc-transform": "^0.
|
|
63
|
+
"@types/node": "^22.10.7",
|
|
64
|
+
"bumpp": "^9.10.1",
|
|
65
|
+
"eslint": "^9.18.0",
|
|
66
|
+
"oxc-transform": "^0.47.1",
|
|
66
67
|
"prettier": "^3.4.2",
|
|
67
68
|
"tinyexec": "^0.3.2",
|
|
68
69
|
"tsup": "^8.3.5",
|
|
69
70
|
"tsx": "^4.19.2",
|
|
70
|
-
"typescript": "~5.7.
|
|
71
|
+
"typescript": "~5.7.3",
|
|
71
72
|
"unplugin-ast": "^0.13.1",
|
|
72
|
-
"vitest": "^3.0.
|
|
73
|
+
"vitest": "^3.0.2"
|
|
73
74
|
},
|
|
74
75
|
"engines": {
|
|
75
76
|
"node": ">=18.0.0"
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { debug } from "./logger-Pk57TMWT.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
//#region src/features/external.ts
|
|
5
|
-
function ExternalPlugin(pkg, skipNodeModulesBundle) {
|
|
6
|
-
const deps = Array.from(getProductionDeps(pkg));
|
|
7
|
-
return {
|
|
8
|
-
name: "tsdown:external",
|
|
9
|
-
resolveId(id, importer, { isEntry }) {
|
|
10
|
-
if (isEntry) return;
|
|
11
|
-
let shouldExternal = skipNodeModulesBundle && !path.isAbsolute(id) && id[0] !== ".";
|
|
12
|
-
shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
13
|
-
if (shouldExternal) {
|
|
14
|
-
debug("[external]", "External dependency:", id);
|
|
15
|
-
return {
|
|
16
|
-
id,
|
|
17
|
-
external: true
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function getProductionDeps(pkg) {
|
|
24
|
-
return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { ExternalPlugin };
|