tsdown 0.2.15 → 0.2.17
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/{external-NHKSS1J8.js → external-m3ERo7i1.js} +1 -1
- package/dist/features/entry.d.ts +2 -2
- package/dist/features/external.d.ts +5 -5
- package/dist/features/output.d.ts +2 -2
- package/dist/features/watch.d.ts +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.js +43 -28
- package/dist/options.d.ts +45 -30
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -1
- package/dist/run.js +1 -1
- package/dist/utils/logger.d.ts +4 -1
- package/dist/utils/package.d.ts +2 -2
- package/package.json +12 -12
|
@@ -18,7 +18,7 @@ function ExternalPlugin(pkg, platform) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
function getProductionDeps(pkg) {
|
|
21
|
-
return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})
|
|
21
|
+
return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
//#endregion
|
package/dist/features/entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Options } from
|
|
2
|
-
export declare function resolveEntry(entry: Options[
|
|
1
|
+
import type { Options } from '../options';
|
|
2
|
+
export declare function resolveEntry(entry: Options['entry']): Promise<string[] | Record<string, string>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ResolvedOptions } from
|
|
2
|
-
import type { PackageJson } from
|
|
3
|
-
import type { InputOptions, Plugin } from
|
|
4
|
-
export type External = InputOptions[
|
|
5
|
-
export declare function ExternalPlugin(pkg: PackageJson | undefined, platform: ResolvedOptions[
|
|
1
|
+
import type { ResolvedOptions } from '../options';
|
|
2
|
+
import type { PackageJson } from 'pkg-types';
|
|
3
|
+
import type { InputOptions, Plugin } from 'rolldown';
|
|
4
|
+
export type External = InputOptions['external'];
|
|
5
|
+
export declare function ExternalPlugin(pkg: PackageJson | undefined, platform: ResolvedOptions['platform']): Plugin;
|
|
6
6
|
export declare function getProductionDeps(pkg: PackageJson): Set<string>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Format } from
|
|
2
|
-
export declare function resolveOutputExtension(pkg: any, format: Format):
|
|
1
|
+
import type { Format } from '../options';
|
|
2
|
+
export declare function resolveOutputExtension(pkg: any, format: Format): 'mjs' | 'cjs' | 'js';
|
package/dist/features/watch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ResolvedOptions } from
|
|
1
|
+
import type { ResolvedOptions } from '../options';
|
|
2
2
|
export declare function watchBuild(options: ResolvedOptions, rebuild: () => void): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { type Options, type OptionsWithoutConfig } from
|
|
2
|
-
import { logger } from
|
|
3
|
-
|
|
1
|
+
import { type Options, type OptionsWithoutConfig } from './options';
|
|
2
|
+
import { logger } from './utils/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Build with tsdown.
|
|
5
|
+
*/
|
|
6
|
+
export declare function build(userOptions?: Omit<Options, 'silent'>): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Defines the configuration for tsdown.
|
|
9
|
+
*/
|
|
4
10
|
export declare function defineConfig(options: OptionsWithoutConfig): OptionsWithoutConfig;
|
|
5
11
|
export { logger };
|
|
6
12
|
export type { Options, OptionsWithoutConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { logger } from "./logger-e0Fr5WMR.js";
|
|
2
|
-
import { ExternalPlugin } from "./external-
|
|
2
|
+
import { ExternalPlugin } from "./external-m3ERo7i1.js";
|
|
3
3
|
import { default as process, default as process$1, default as process$2 } from "node:process";
|
|
4
4
|
import { rolldown } from "rolldown";
|
|
5
5
|
import { IsolatedDecl } from "unplugin-isolated-decl";
|
|
6
6
|
import { Unused } from "unplugin-unused";
|
|
7
7
|
import { access, readdir, rm, stat } from "node:fs/promises";
|
|
8
|
-
import { default as path, default as path$1, default as path$2
|
|
8
|
+
import { default as path, default as path$1, default as path$2 } from "node:path";
|
|
9
9
|
import { glob, glob as glob$1 } from "tinyglobby";
|
|
10
10
|
import { readPackageJSON } from "pkg-types";
|
|
11
11
|
import { default as pc, default as pc$1 } from "picocolors";
|
|
12
12
|
import { loadConfig } from "unconfig";
|
|
13
13
|
|
|
14
14
|
//#region src/utils/fs.ts
|
|
15
|
-
function fsExists(path$
|
|
16
|
-
return access(path$
|
|
15
|
+
function fsExists(path$3) {
|
|
16
|
+
return access(path$3).then(() => true, () => false);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/features/clean.ts
|
|
21
21
|
async function cleanOutDir(cwd, patterns) {
|
|
22
22
|
const files = [];
|
|
23
|
-
if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$
|
|
23
|
+
if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$2.resolve(cwd, file)));
|
|
24
24
|
if (patterns.length) {
|
|
25
25
|
files.push(...await glob$1(patterns, {
|
|
26
26
|
cwd,
|
|
@@ -39,7 +39,7 @@ async function cleanOutDir(cwd, patterns) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/utils/package.ts
|
|
41
41
|
async function readPackageJson(dir) {
|
|
42
|
-
const packageJsonPath = path$
|
|
42
|
+
const packageJsonPath = path$1.join(dir, "package.json");
|
|
43
43
|
const exists = await fsExists(packageJsonPath);
|
|
44
44
|
if (!exists) return;
|
|
45
45
|
return readPackageJSON(packageJsonPath);
|
|
@@ -101,12 +101,14 @@ async function watchBuild(options, rebuild) {
|
|
|
101
101
|
const { watch } = await import("chokidar");
|
|
102
102
|
const debouncedRebuild = debounce(rebuild, 100);
|
|
103
103
|
const files = typeof options.watch === "boolean" ? process$2.cwd() : options.watch;
|
|
104
|
-
const ignored = ["**/{.git,node_modules}/**", path$1.resolve(options.outDir)];
|
|
105
104
|
logger.info(`Watching for changes in ${toArray(files).join(", ")}`);
|
|
106
105
|
const watcher = watch(files, {
|
|
107
106
|
ignoreInitial: true,
|
|
108
107
|
ignorePermissionErrors: true,
|
|
109
|
-
ignored
|
|
108
|
+
ignored: (id) => {
|
|
109
|
+
if (id.includes("/.git/") || id.includes("/node_modules/")) return true;
|
|
110
|
+
return id.startsWith(options.outDir);
|
|
111
|
+
}
|
|
110
112
|
});
|
|
111
113
|
watcher.on("all", (type, file) => {
|
|
112
114
|
logger.info(`Change detected: ${type} ${file}`);
|
|
@@ -159,7 +161,7 @@ async function normalizeOptions(options) {
|
|
|
159
161
|
plugins,
|
|
160
162
|
external,
|
|
161
163
|
format,
|
|
162
|
-
outDir,
|
|
164
|
+
outDir: path.resolve(outDir),
|
|
163
165
|
clean,
|
|
164
166
|
silent,
|
|
165
167
|
alias,
|
|
@@ -196,12 +198,21 @@ async function loadConfigFile(options) {
|
|
|
196
198
|
extensions: []
|
|
197
199
|
}] : [{
|
|
198
200
|
files: "tsdown.config",
|
|
199
|
-
extensions: [
|
|
201
|
+
extensions: [
|
|
202
|
+
"ts",
|
|
203
|
+
"mts",
|
|
204
|
+
"cts",
|
|
205
|
+
"js",
|
|
206
|
+
"mjs",
|
|
207
|
+
"cjs",
|
|
208
|
+
"json",
|
|
209
|
+
""
|
|
210
|
+
]
|
|
200
211
|
}, {
|
|
201
212
|
files: "package.json",
|
|
202
213
|
extensions: [],
|
|
203
214
|
rewrite: (config$1) => config$1?.tsdown
|
|
204
|
-
}
|
|
215
|
+
}],
|
|
205
216
|
cwd,
|
|
206
217
|
defaults: {}
|
|
207
218
|
});
|
|
@@ -218,25 +229,28 @@ async function build(userOptions = {}) {
|
|
|
218
229
|
const { entry, external, plugins, outDir, format, clean, platform, alias, treeshake, sourcemap, dts, minify, watch, unused } = resolved;
|
|
219
230
|
if (clean) await cleanOutDir(outDir, clean);
|
|
220
231
|
const pkg = await readPackageJson(process.cwd());
|
|
221
|
-
let startTime
|
|
222
|
-
|
|
223
|
-
input: entry,
|
|
224
|
-
external,
|
|
225
|
-
resolve: { alias },
|
|
226
|
-
treeshake,
|
|
227
|
-
platform,
|
|
228
|
-
plugins: [ExternalPlugin(pkg, platform), dts && IsolatedDecl.rolldown(dts === true ? {} : dts), unused && Unused.rolldown(unused === true ? {} : unused), ...plugins,].filter((plugin) => !!plugin),
|
|
229
|
-
...resolved.inputOptions
|
|
230
|
-
};
|
|
231
|
-
const build$1 = await rolldown(inputOptions);
|
|
232
|
-
await writeBundle(true);
|
|
232
|
+
let startTime;
|
|
233
|
+
await rebuild(true);
|
|
233
234
|
if (watch) {
|
|
234
|
-
await watchBuild(resolved,
|
|
235
|
-
} else {
|
|
236
|
-
await build$1.close();
|
|
235
|
+
await watchBuild(resolved, rebuild);
|
|
237
236
|
}
|
|
238
|
-
async function
|
|
239
|
-
|
|
237
|
+
async function rebuild(first) {
|
|
238
|
+
startTime = performance.now();
|
|
239
|
+
const inputOptions = {
|
|
240
|
+
input: entry,
|
|
241
|
+
external,
|
|
242
|
+
resolve: { alias },
|
|
243
|
+
treeshake,
|
|
244
|
+
platform,
|
|
245
|
+
plugins: [
|
|
246
|
+
ExternalPlugin(pkg, platform),
|
|
247
|
+
dts && IsolatedDecl.rolldown(dts === true ? {} : dts),
|
|
248
|
+
unused && Unused.rolldown(unused === true ? {} : unused),
|
|
249
|
+
...plugins
|
|
250
|
+
].filter((plugin) => !!plugin),
|
|
251
|
+
...resolved.inputOptions
|
|
252
|
+
};
|
|
253
|
+
const build$1 = await rolldown(inputOptions);
|
|
240
254
|
await Promise.all(format.map(async (format$1) => {
|
|
241
255
|
const extension = resolveOutputExtension(pkg, format$1);
|
|
242
256
|
const outputOptions = {
|
|
@@ -253,6 +267,7 @@ async function build(userOptions = {}) {
|
|
|
253
267
|
...userOutputOptions
|
|
254
268
|
});
|
|
255
269
|
}));
|
|
270
|
+
await build$1.close();
|
|
256
271
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${Math.round(performance.now() - startTime)}ms`);
|
|
257
272
|
}
|
|
258
273
|
}
|
package/dist/options.d.ts
CHANGED
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
import type { External } from
|
|
2
|
-
import type { MarkPartial, MaybePromise, Overwrite } from
|
|
3
|
-
import type { InputOptions, OutputOptions } from
|
|
4
|
-
import type { Options as IsolatedDeclOptions } from
|
|
5
|
-
import type { Options as UnusedOptions } from
|
|
6
|
-
export type Format =
|
|
7
|
-
export type Sourcemap = boolean |
|
|
1
|
+
import type { External } from './features/external';
|
|
2
|
+
import type { MarkPartial, MaybePromise, Overwrite } from './utils/types';
|
|
3
|
+
import type { InputOptions, OutputOptions } from 'rolldown';
|
|
4
|
+
import type { Options as IsolatedDeclOptions } from 'unplugin-isolated-decl';
|
|
5
|
+
import type { Options as UnusedOptions } from 'unplugin-unused';
|
|
6
|
+
export type Format = 'es' | 'cjs' | 'esm' | 'module' | 'commonjs' | 'iife';
|
|
7
|
+
export type Sourcemap = boolean | 'inline' | 'hidden';
|
|
8
|
+
/**
|
|
9
|
+
* Options for tsdown.
|
|
10
|
+
*/
|
|
8
11
|
export interface Options {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
entry?: InputOptions['input'];
|
|
13
|
+
format?: Format | Format[];
|
|
14
|
+
plugins?: InputOptions['plugins'];
|
|
15
|
+
external?: External;
|
|
16
|
+
outDir?: string;
|
|
17
|
+
clean?: boolean | string[];
|
|
18
|
+
silent?: boolean;
|
|
19
|
+
config?: boolean | string;
|
|
20
|
+
sourcemap?: Sourcemap;
|
|
21
|
+
alias?: Record<string, string>;
|
|
22
|
+
/** @default true */
|
|
23
|
+
treeshake?: boolean;
|
|
24
|
+
/** @default false */
|
|
25
|
+
minify?: boolean;
|
|
26
|
+
/** @default 'node' */
|
|
27
|
+
platform?: 'node' | 'neutral' | 'browser';
|
|
28
|
+
/**
|
|
29
|
+
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
30
|
+
*/
|
|
31
|
+
dts?: boolean | IsolatedDeclOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Enable unused dependencies check with `unplugin-unused` (experimental)
|
|
34
|
+
*/
|
|
35
|
+
unused?: boolean | UnusedOptions;
|
|
36
|
+
watch?: boolean | string | string[];
|
|
37
|
+
inputOptions?: InputOptions;
|
|
38
|
+
outputOptions?: OutputOptions | ((options: OutputOptions, format: Format) => MaybePromise<OutputOptions | void | null>);
|
|
27
39
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Options without specifying config file path.
|
|
42
|
+
*/
|
|
43
|
+
export type OptionsWithoutConfig = Omit<Options, 'config'>;
|
|
44
|
+
export type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, 'inputOptions' | 'outputOptions' | 'minify' | 'alias' | 'external'>, {
|
|
45
|
+
format: Format[];
|
|
46
|
+
clean: string[] | false;
|
|
47
|
+
}>, 'config'>;
|
|
33
48
|
export declare function normalizeOptions(options: Options): Promise<ResolvedOptions>;
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ExternalPlugin } from
|
|
1
|
+
export { ExternalPlugin } from './features/external';
|
package/dist/plugins.js
CHANGED
package/dist/run.js
CHANGED
package/dist/utils/logger.d.ts
CHANGED
package/dist/utils/package.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type PackageJson } from
|
|
1
|
+
import { type PackageJson } from 'pkg-types';
|
|
2
2
|
export declare function readPackageJson(dir: string): Promise<PackageJson | undefined>;
|
|
3
|
-
export declare function getPackageType(pkg: PackageJson | undefined):
|
|
3
|
+
export declare function getPackageType(pkg: PackageJson | undefined): 'module' | 'commonjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "An even faster bundler powered by Rolldown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,29 +40,29 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"cac": "^6.7.14",
|
|
43
|
-
"chokidar": "^
|
|
43
|
+
"chokidar": "^4.0.1",
|
|
44
44
|
"consola": "^3.2.3",
|
|
45
45
|
"picocolors": "^1.1.0",
|
|
46
46
|
"pkg-types": "^1.2.0",
|
|
47
47
|
"rolldown": "nightly",
|
|
48
48
|
"tinyglobby": "^0.2.6",
|
|
49
|
-
"unconfig": "^0.
|
|
50
|
-
"unplugin-isolated-decl": "^0.
|
|
49
|
+
"unconfig": "^0.6.0",
|
|
50
|
+
"unplugin-isolated-decl": "^0.6.5",
|
|
51
51
|
"unplugin-unused": "^0.2.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@sxzz/eslint-config": "^4.2.0",
|
|
55
55
|
"@sxzz/prettier-config": "^2.0.2",
|
|
56
|
-
"@types/node": "^22.
|
|
57
|
-
"bumpp": "^9.
|
|
58
|
-
"eslint": "^9.
|
|
59
|
-
"execa": "^9.
|
|
56
|
+
"@types/node": "^22.7.4",
|
|
57
|
+
"bumpp": "^9.6.1",
|
|
58
|
+
"eslint": "^9.11.1",
|
|
59
|
+
"execa": "^9.4.0",
|
|
60
60
|
"fdir": "^6.3.0",
|
|
61
61
|
"prettier": "^3.3.3",
|
|
62
|
-
"tsup": "^8.
|
|
63
|
-
"tsx": "^4.19.
|
|
64
|
-
"typescript": "~5.
|
|
65
|
-
"vitest": "^2.
|
|
62
|
+
"tsup": "^8.3.0",
|
|
63
|
+
"tsx": "^4.19.1",
|
|
64
|
+
"typescript": "~5.6.2",
|
|
65
|
+
"vitest": "^2.1.1"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=18.0.0"
|