tsdown 0.6.4 → 0.6.6
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/README.md +8 -0
- package/dist/config.d.ts +2 -1
- package/dist/dts-DuyYOCuS.js +175 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +10 -69
- package/dist/{migrate-CbXRAJ1k.js → migrate-Y0DZZqeT.js} +1 -1
- package/dist/{options.d-B6hAHDaA.d.ts → options.d-D2X9ak47.d.ts} +8 -2
- package/dist/package-Dga7uLAE.js +6 -0
- package/dist/plugins.d.ts +6 -2
- package/dist/plugins.js +2 -2
- package/dist/run.js +3 -3
- package/package.json +15 -14
- package/dist/external-CaGWwJ2H.js +0 -61
- package/dist/package-VF4o7Lus.js +0 -6
- /package/dist/{logger-4bmpqibt.js → logger-9p9U7Sx7.js} +0 -0
package/README.md
CHANGED
|
@@ -27,6 +27,14 @@ export default defineConfig({
|
|
|
27
27
|
})
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Migrate from tsup
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx tsdown migrate
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Please make sure to commit your changes before migrating.
|
|
37
|
+
|
|
30
38
|
## Credits
|
|
31
39
|
|
|
32
40
|
This project also partially contains code derived or copied from [tsup](https://github.com/egoist/tsup).
|
package/dist/config.d.ts
CHANGED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import path, { dirname, normalize, sep } from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { access, rm } from "node:fs/promises";
|
|
4
|
+
import Debug from "debug";
|
|
5
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
6
|
+
import { rollup } from "rollup";
|
|
7
|
+
import DtsPlugin from "rollup-plugin-dts";
|
|
8
|
+
|
|
9
|
+
//#region src/utils/fs.ts
|
|
10
|
+
function fsExists(path$1) {
|
|
11
|
+
return access(path$1).then(() => true, () => false);
|
|
12
|
+
}
|
|
13
|
+
function fsRemove(path$1) {
|
|
14
|
+
return rm(path$1, {
|
|
15
|
+
force: true,
|
|
16
|
+
recursive: true
|
|
17
|
+
}).catch(() => {});
|
|
18
|
+
}
|
|
19
|
+
function lowestCommonAncestor(...filepaths) {
|
|
20
|
+
if (filepaths.length === 0) return "";
|
|
21
|
+
if (filepaths.length === 1) return dirname(filepaths[0]);
|
|
22
|
+
filepaths = filepaths.map(normalize);
|
|
23
|
+
const [first, ...rest] = filepaths;
|
|
24
|
+
let ancestor = first.split(sep);
|
|
25
|
+
for (const filepath of rest) {
|
|
26
|
+
const directories = filepath.split(sep, ancestor.length);
|
|
27
|
+
let index = 0;
|
|
28
|
+
for (const directory of directories) if (directory === ancestor[index]) index += 1;
|
|
29
|
+
else {
|
|
30
|
+
ancestor = ancestor.slice(0, index);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
ancestor = ancestor.slice(0, index);
|
|
34
|
+
}
|
|
35
|
+
return ancestor.length <= 1 && ancestor[0] === "" ? sep + ancestor[0] : ancestor.join(sep);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/utils/general.ts
|
|
40
|
+
function toArray(val, defaultValue) {
|
|
41
|
+
if (Array.isArray(val)) return val;
|
|
42
|
+
else if (val == null) {
|
|
43
|
+
if (defaultValue) return [defaultValue];
|
|
44
|
+
return [];
|
|
45
|
+
} else return [val];
|
|
46
|
+
}
|
|
47
|
+
function debounce(fn, wait) {
|
|
48
|
+
let timeout;
|
|
49
|
+
return function(...args) {
|
|
50
|
+
if (timeout) clearTimeout(timeout);
|
|
51
|
+
timeout = setTimeout(() => {
|
|
52
|
+
timeout = void 0;
|
|
53
|
+
fn.apply(this, args);
|
|
54
|
+
}, wait);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/features/external.ts
|
|
60
|
+
const debug$1 = Debug("tsdown:external");
|
|
61
|
+
function ExternalPlugin(options, pkg) {
|
|
62
|
+
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
63
|
+
return {
|
|
64
|
+
name: "tsdown:external",
|
|
65
|
+
async resolveId(id, importer, { isEntry }) {
|
|
66
|
+
if (isEntry) return;
|
|
67
|
+
const { noExternal } = options;
|
|
68
|
+
if (typeof noExternal === "function" && noExternal(id, importer)) return;
|
|
69
|
+
if (noExternal) {
|
|
70
|
+
const noExternalPatterns = toArray(noExternal);
|
|
71
|
+
if (noExternalPatterns.some((pattern) => {
|
|
72
|
+
return pattern instanceof RegExp ? pattern.test(id) : id === pattern;
|
|
73
|
+
})) return;
|
|
74
|
+
}
|
|
75
|
+
let shouldExternal = false;
|
|
76
|
+
if (options.skipNodeModulesBundle) {
|
|
77
|
+
const resolved = await this.resolve(id);
|
|
78
|
+
if (!resolved) return;
|
|
79
|
+
shouldExternal = resolved.external || /[\\/]node_modules[\\/]/.test(resolved.id);
|
|
80
|
+
}
|
|
81
|
+
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
82
|
+
if (shouldExternal) {
|
|
83
|
+
debug$1("External dependency:", id);
|
|
84
|
+
return {
|
|
85
|
+
id,
|
|
86
|
+
external: true
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function getProductionDeps(pkg) {
|
|
93
|
+
return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/features/dts.ts
|
|
98
|
+
const debug = Debug("tsdown:dts");
|
|
99
|
+
const TEMP_DTS_DIR = ".tsdown-types";
|
|
100
|
+
function getTempDtsDir(format) {
|
|
101
|
+
return `${TEMP_DTS_DIR}-${format}`;
|
|
102
|
+
}
|
|
103
|
+
async function bundleDts(options, jsExtension, format, pkg) {
|
|
104
|
+
const ext = jsExtension.replace("j", "t");
|
|
105
|
+
const dtsOutDir = path.resolve(options.outDir, getTempDtsDir(format));
|
|
106
|
+
const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path.resolve(dtsOutDir, `${key}.d.${ext}`)]));
|
|
107
|
+
const build = await rollup({
|
|
108
|
+
input: dtsEntry,
|
|
109
|
+
external: options.external,
|
|
110
|
+
onLog(level, log, defaultHandler) {
|
|
111
|
+
if (log.code !== "EMPTY_BUNDLE" && log.code !== "UNRESOLVED_IMPORT") defaultHandler(level, log);
|
|
112
|
+
},
|
|
113
|
+
plugins: [
|
|
114
|
+
ExternalPlugin(options, pkg),
|
|
115
|
+
options.bundleDts.resolve && ResolveDtsPlugin(),
|
|
116
|
+
DtsPlugin({ compilerOptions: {
|
|
117
|
+
...options.bundleDts.compilerOptions,
|
|
118
|
+
declaration: true,
|
|
119
|
+
noEmit: false,
|
|
120
|
+
emitDeclarationOnly: true,
|
|
121
|
+
noEmitOnError: true,
|
|
122
|
+
checkJs: false,
|
|
123
|
+
declarationMap: false,
|
|
124
|
+
skipLibCheck: true,
|
|
125
|
+
preserveSymlinks: false,
|
|
126
|
+
target: 99
|
|
127
|
+
} })
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
let outDir = options.outDir;
|
|
131
|
+
const extraOutdir = options.dts.extraOutdir;
|
|
132
|
+
if (extraOutdir) outDir = path.resolve(outDir, extraOutdir);
|
|
133
|
+
await build.write({
|
|
134
|
+
dir: outDir,
|
|
135
|
+
format: "es",
|
|
136
|
+
entryFileNames: `[name].d.${ext}`
|
|
137
|
+
});
|
|
138
|
+
await fsRemove(dtsOutDir);
|
|
139
|
+
}
|
|
140
|
+
let resolver;
|
|
141
|
+
function ResolveDtsPlugin() {
|
|
142
|
+
return {
|
|
143
|
+
name: "resolve-dts",
|
|
144
|
+
buildStart() {
|
|
145
|
+
resolver ||= new ResolverFactory({
|
|
146
|
+
mainFields: ["types"],
|
|
147
|
+
conditionNames: [
|
|
148
|
+
"types",
|
|
149
|
+
"typings",
|
|
150
|
+
"import",
|
|
151
|
+
"require"
|
|
152
|
+
],
|
|
153
|
+
extensions: [".d.ts", ".ts"],
|
|
154
|
+
modules: ["node_modules", "node_modules/@types"]
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
async resolveId(id, importer) {
|
|
158
|
+
if (id[0] === "." || path.isAbsolute(id)) return;
|
|
159
|
+
if (/\0/.test(id)) return;
|
|
160
|
+
const directory = importer ? path.dirname(importer) : process.cwd();
|
|
161
|
+
debug("Resolving:", id, "from:", directory);
|
|
162
|
+
const { path: resolved } = await resolver.async(directory, id);
|
|
163
|
+
if (!resolved) return;
|
|
164
|
+
debug("Resolved:", resolved);
|
|
165
|
+
if (/[cm]?jsx?$/.test(resolved)) {
|
|
166
|
+
const dts = resolved.replace(/\.([cm]?)jsx?$/, ".d.$1ts");
|
|
167
|
+
return await fsExists(dts) ? dts : void 0;
|
|
168
|
+
}
|
|
169
|
+
return resolved;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
export { ExternalPlugin, ResolveDtsPlugin, bundleDts, debounce, fsExists, fsRemove, getTempDtsDir, lowestCommonAncestor, toArray };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { O as Options, R as ResolvedOptions } from './options.d-
|
|
2
|
-
export { U as UserConfig } from './options.d-
|
|
1
|
+
import { O as Options, R as ResolvedOptions } from './options.d-D2X9ak47.js';
|
|
2
|
+
export { U as UserConfig } from './options.d-D2X9ak47.js';
|
|
3
3
|
import { ConsolaInstance } from 'consola';
|
|
4
4
|
export { defineConfig } from './config.js';
|
|
5
5
|
import 'publint';
|
|
6
6
|
import 'rolldown';
|
|
7
|
+
import 'typescript';
|
|
7
8
|
import 'unplugin-isolated-decl';
|
|
8
9
|
import 'unplugin-unused';
|
|
9
10
|
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,19 @@
|
|
|
1
1
|
import { defineConfig } from "./config-0LDjKwZ7.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import path
|
|
2
|
+
import { ExternalPlugin, bundleDts, debounce, fsExists, fsRemove, getTempDtsDir, lowestCommonAncestor, toArray } from "./dts-DuyYOCuS.js";
|
|
3
|
+
import { debug, logger, setSilent } from "./logger-9p9U7Sx7.js";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { build as build$1 } from "rolldown";
|
|
8
8
|
import { transformPlugin } from "rolldown/experimental";
|
|
9
|
-
import {
|
|
9
|
+
import { readdir, stat } from "node:fs/promises";
|
|
10
10
|
import Debug from "debug";
|
|
11
11
|
import { glob } from "tinyglobby";
|
|
12
|
-
import { rollup } from "rollup";
|
|
13
|
-
import DtsPlugin from "rollup-plugin-dts";
|
|
14
12
|
import { readPackageJSON } from "pkg-types";
|
|
15
13
|
import readline from "node:readline";
|
|
16
14
|
import { blue, bold, dim, underline } from "ansis";
|
|
17
15
|
import { loadConfig } from "unconfig";
|
|
18
16
|
|
|
19
|
-
//#region src/utils/fs.ts
|
|
20
|
-
function fsExists(path$1) {
|
|
21
|
-
return access(path$1).then(() => true, () => false);
|
|
22
|
-
}
|
|
23
|
-
function fsRemove(path$1) {
|
|
24
|
-
return rm(path$1, {
|
|
25
|
-
force: true,
|
|
26
|
-
recursive: true
|
|
27
|
-
}).catch(() => {});
|
|
28
|
-
}
|
|
29
|
-
function lowestCommonAncestor(...filepaths) {
|
|
30
|
-
if (filepaths.length === 0) return "";
|
|
31
|
-
if (filepaths.length === 1) return dirname(filepaths[0]);
|
|
32
|
-
filepaths = filepaths.map(normalize);
|
|
33
|
-
const [first, ...rest] = filepaths;
|
|
34
|
-
let ancestor = first.split(sep);
|
|
35
|
-
for (const filepath of rest) {
|
|
36
|
-
const directories = filepath.split(sep, ancestor.length);
|
|
37
|
-
let index = 0;
|
|
38
|
-
for (const directory of directories) if (directory === ancestor[index]) index += 1;
|
|
39
|
-
else {
|
|
40
|
-
ancestor = ancestor.slice(0, index);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
ancestor = ancestor.slice(0, index);
|
|
44
|
-
}
|
|
45
|
-
return ancestor.length <= 1 && ancestor[0] === "" ? sep + ancestor[0] : ancestor.join(sep);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
17
|
//#region src/features/clean.ts
|
|
50
18
|
const debug$2 = Debug("tsdown:clean");
|
|
51
19
|
async function cleanOutDir(cwd, patterns) {
|
|
@@ -62,34 +30,6 @@ async function cleanOutDir(cwd, patterns) {
|
|
|
62
30
|
}
|
|
63
31
|
}
|
|
64
32
|
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/features/dts.ts
|
|
67
|
-
const TEMP_DTS_DIR = ".tsdown-types";
|
|
68
|
-
function getTempDtsDir(format) {
|
|
69
|
-
return `${TEMP_DTS_DIR}-${format}`;
|
|
70
|
-
}
|
|
71
|
-
async function bundleDts(options, jsExtension, format) {
|
|
72
|
-
const ext = jsExtension.replace("j", "t");
|
|
73
|
-
const dtsOutDir = path.resolve(options.outDir, getTempDtsDir(format));
|
|
74
|
-
const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path.resolve(dtsOutDir, `${key}.d.${ext}`)]));
|
|
75
|
-
const build$2 = await rollup({
|
|
76
|
-
input: dtsEntry,
|
|
77
|
-
onLog(level, log, defaultHandler) {
|
|
78
|
-
if (log.code !== "EMPTY_BUNDLE" && log.code !== "UNRESOLVED_IMPORT") defaultHandler(level, log);
|
|
79
|
-
},
|
|
80
|
-
plugins: [DtsPlugin()]
|
|
81
|
-
});
|
|
82
|
-
let outDir = options.outDir;
|
|
83
|
-
const extraOutdir = options.dts.extraOutdir;
|
|
84
|
-
if (extraOutdir) outDir = path.resolve(outDir, extraOutdir);
|
|
85
|
-
await build$2.write({
|
|
86
|
-
dir: outDir,
|
|
87
|
-
format: "es",
|
|
88
|
-
entryFileNames: `[name].d.${ext}`
|
|
89
|
-
});
|
|
90
|
-
await fsRemove(dtsOutDir);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
33
|
//#endregion
|
|
94
34
|
//#region src/utils/package.ts
|
|
95
35
|
async function readPackageJson(dir) {
|
|
@@ -134,9 +74,9 @@ function resolveOutputExtension(pkg, format, fixedExtension) {
|
|
|
134
74
|
//#region src/features/publint.ts
|
|
135
75
|
const debug$1 = Debug("tsdown:publint");
|
|
136
76
|
async function publint(pkg) {
|
|
77
|
+
debug$1("Running publint");
|
|
137
78
|
const { publint: publint$1 } = await import("publint");
|
|
138
79
|
const { formatMessage } = await import("publint/utils");
|
|
139
|
-
debug$1("Running publint");
|
|
140
80
|
const { messages } = await publint$1();
|
|
141
81
|
debug$1("Found %d issues", messages.length);
|
|
142
82
|
if (!messages.length) logger.success("No publint issues found");
|
|
@@ -285,6 +225,7 @@ async function resolveOptions(options) {
|
|
|
285
225
|
entry = await resolveEntry(entry);
|
|
286
226
|
if (clean === true) clean = [];
|
|
287
227
|
if (publint$1 === true) publint$1 = {};
|
|
228
|
+
if (bundleDts$1 === true) bundleDts$1 = {};
|
|
288
229
|
if (fromVite) {
|
|
289
230
|
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd);
|
|
290
231
|
if (viteUserConfig) {
|
|
@@ -454,9 +395,9 @@ async function buildSingle(config) {
|
|
|
454
395
|
...dts,
|
|
455
396
|
extraOutdir: config.bundleDts ? getTempDtsDir(format$1) : dts.extraOutdir
|
|
456
397
|
}),
|
|
457
|
-
target && transformPlugin({ target: target && (typeof target === "string" ? target : target.join(",")) }),
|
|
398
|
+
!!target && transformPlugin({ target: target && (typeof target === "string" ? target : target.join(",")) }),
|
|
458
399
|
userPlugins
|
|
459
|
-
]
|
|
400
|
+
],
|
|
460
401
|
inject: { ...shims && getShimsInject(format$1, platform) }
|
|
461
402
|
}, config.inputOptions, [format$1]);
|
|
462
403
|
const extension = resolveOutputExtension(pkg, format$1, fixedExtension);
|
|
@@ -473,12 +414,12 @@ async function buildSingle(config) {
|
|
|
473
414
|
...inputOptions,
|
|
474
415
|
output: outputOptions
|
|
475
416
|
});
|
|
476
|
-
if (config.dts && config.bundleDts) await bundleDts(config, extension, format$1);
|
|
417
|
+
if (config.dts && config.bundleDts) await bundleDts(config, extension, format$1, pkg);
|
|
477
418
|
}));
|
|
478
419
|
if (config.publint) if (pkg) await publint(pkg);
|
|
479
420
|
else logger.warn("publint is enabled but package.json is not found");
|
|
480
421
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${Math.round(performance.now() - startTime)}ms`);
|
|
481
|
-
await onSuccess?.();
|
|
422
|
+
await onSuccess?.(config);
|
|
482
423
|
}
|
|
483
424
|
}
|
|
484
425
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Options as Options$3 } from 'publint';
|
|
2
2
|
import { InputOptions, ExternalOption, ModuleFormat, OutputOptions, InternalModuleFormat } from 'rolldown';
|
|
3
|
+
import { CompilerOptions } from 'typescript';
|
|
3
4
|
import { Options as Options$1 } from 'unplugin-isolated-decl';
|
|
4
5
|
import { Options as Options$2 } from 'unplugin-unused';
|
|
5
6
|
|
|
@@ -15,6 +16,10 @@ type MarkPartial<
|
|
|
15
16
|
type Arrayable<T> = T | T[];
|
|
16
17
|
|
|
17
18
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
19
|
+
interface BundleDtsOptions {
|
|
20
|
+
resolve?: boolean;
|
|
21
|
+
compilerOptions?: CompilerOptions;
|
|
22
|
+
}
|
|
18
23
|
/**
|
|
19
24
|
* Options for tsdown.
|
|
20
25
|
*/
|
|
@@ -43,7 +48,7 @@ interface Options {
|
|
|
43
48
|
silent?: boolean;
|
|
44
49
|
config?: boolean | string;
|
|
45
50
|
watch?: boolean | string | string[];
|
|
46
|
-
onSuccess?: () => void | Promise<void>;
|
|
51
|
+
onSuccess?: (config: ResolvedOptions) => void | Promise<void>;
|
|
47
52
|
/**
|
|
48
53
|
* Skip bundling node_modules.
|
|
49
54
|
*/
|
|
@@ -65,7 +70,7 @@ interface Options {
|
|
|
65
70
|
*/
|
|
66
71
|
dts?: boolean | Options$1;
|
|
67
72
|
/** @default true */
|
|
68
|
-
bundleDts?: boolean;
|
|
73
|
+
bundleDts?: boolean | BundleDtsOptions;
|
|
69
74
|
/**
|
|
70
75
|
* Enable unused dependencies check with `unplugin-unused`
|
|
71
76
|
* Requires `unplugin-unused` to be installed.
|
|
@@ -86,6 +91,7 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "globalName" | "input
|
|
|
86
91
|
format: NormalizedFormat[]
|
|
87
92
|
clean: string[] | false
|
|
88
93
|
dts: false | Options$1
|
|
94
|
+
bundleDts: false | BundleDtsOptions
|
|
89
95
|
}>, "config" | "fromVite">;
|
|
90
96
|
|
|
91
97
|
export type { Options as O, ResolvedOptions as R, UserConfig as U };
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { R as ResolvedOptions } from './options.d-
|
|
1
|
+
import { R as ResolvedOptions } from './options.d-D2X9ak47.js';
|
|
2
2
|
import { PackageJson } from 'pkg-types';
|
|
3
3
|
import { Plugin } from 'rolldown';
|
|
4
|
+
import { Plugin as Plugin$1 } from 'rollup';
|
|
4
5
|
import 'publint';
|
|
6
|
+
import 'typescript';
|
|
5
7
|
import 'unplugin-isolated-decl';
|
|
6
8
|
import 'unplugin-unused';
|
|
7
9
|
|
|
8
10
|
declare function ExternalPlugin(options: ResolvedOptions, pkg?: PackageJson): Plugin;
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
declare function ResolveDtsPlugin(): Plugin$1;
|
|
13
|
+
|
|
14
|
+
export { ExternalPlugin, ResolveDtsPlugin };
|
package/dist/plugins.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExternalPlugin } from "./
|
|
1
|
+
import { ExternalPlugin, ResolveDtsPlugin } from "./dts-DuyYOCuS.js";
|
|
2
2
|
|
|
3
|
-
export { ExternalPlugin };
|
|
3
|
+
export { ExternalPlugin, ResolveDtsPlugin };
|
package/dist/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { logger, setSilent } from "./logger-
|
|
2
|
-
import { version } from "./package-
|
|
1
|
+
import { logger, setSilent } from "./logger-9p9U7Sx7.js";
|
|
2
|
+
import { version } from "./package-Dga7uLAE.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { VERSION } from "rolldown";
|
|
5
5
|
import { dim } from "ansis";
|
|
@@ -16,7 +16,7 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
|
|
|
16
16
|
await build$1(flags);
|
|
17
17
|
});
|
|
18
18
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
19
|
-
const { migrate } = await import("./migrate-
|
|
19
|
+
const { migrate } = await import("./migrate-Y0DZZqeT.js");
|
|
20
20
|
await migrate(args);
|
|
21
21
|
});
|
|
22
22
|
async function runCLI() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "An even faster bundler powered by Rolldown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,34 +60,35 @@
|
|
|
60
60
|
"consola": "^3.4.0",
|
|
61
61
|
"debug": "^4.4.0",
|
|
62
62
|
"diff": "^7.0.0",
|
|
63
|
+
"oxc-resolver": "^5.0.0",
|
|
63
64
|
"pkg-types": "^2.1.0",
|
|
64
|
-
"rolldown": "
|
|
65
|
-
"rollup": "^4.
|
|
65
|
+
"rolldown": "1.0.0-beta.3-commit.e170e6e",
|
|
66
|
+
"rollup": "^4.35.0",
|
|
66
67
|
"rollup-plugin-dts": "^6.1.1",
|
|
67
68
|
"tinyglobby": "^0.2.12",
|
|
68
|
-
"unconfig": "^7.3.
|
|
69
|
-
"unplugin-isolated-decl": "^0.13.
|
|
69
|
+
"unconfig": "^7.3.1",
|
|
70
|
+
"unplugin-isolated-decl": "^0.13.2"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
|
-
"@sxzz/eslint-config": "^
|
|
73
|
-
"@sxzz/prettier-config": "^2.2.
|
|
73
|
+
"@sxzz/eslint-config": "^6.0.1",
|
|
74
|
+
"@sxzz/prettier-config": "^2.2.1",
|
|
74
75
|
"@sxzz/test-utils": "^0.5.1",
|
|
75
76
|
"@types/debug": "^4.1.12",
|
|
76
77
|
"@types/diff": "^7.0.1",
|
|
77
|
-
"@types/node": "^22.13.
|
|
78
|
+
"@types/node": "^22.13.10",
|
|
78
79
|
"bumpp": "^10.0.3",
|
|
79
|
-
"eslint": "^9.
|
|
80
|
-
"oxc-transform": "^0.
|
|
80
|
+
"eslint": "^9.22.0",
|
|
81
|
+
"oxc-transform": "^0.56.5",
|
|
81
82
|
"prettier": "^3.5.3",
|
|
82
|
-
"publint": "^0.3.
|
|
83
|
+
"publint": "^0.3.9",
|
|
83
84
|
"tinyexec": "^0.3.2",
|
|
84
85
|
"tsup": "^8.4.0",
|
|
85
86
|
"tsx": "^4.19.3",
|
|
86
87
|
"typescript": "~5.8.2",
|
|
87
|
-
"unplugin-ast": "^0.14.
|
|
88
|
+
"unplugin-ast": "^0.14.2",
|
|
88
89
|
"unplugin-unused": "^0.4.3",
|
|
89
|
-
"vite": "^6.2.
|
|
90
|
-
"vitest": "^3.0.
|
|
90
|
+
"vite": "^6.2.1",
|
|
91
|
+
"vitest": "^3.0.8"
|
|
91
92
|
},
|
|
92
93
|
"engines": {
|
|
93
94
|
"node": ">=18.0.0"
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import Debug from "debug";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/general.ts
|
|
4
|
-
function toArray(val, defaultValue) {
|
|
5
|
-
if (Array.isArray(val)) return val;
|
|
6
|
-
else if (val == null) {
|
|
7
|
-
if (defaultValue) return [defaultValue];
|
|
8
|
-
return [];
|
|
9
|
-
} else return [val];
|
|
10
|
-
}
|
|
11
|
-
function debounce(fn, wait) {
|
|
12
|
-
let timeout;
|
|
13
|
-
return function(...args) {
|
|
14
|
-
if (timeout) clearTimeout(timeout);
|
|
15
|
-
timeout = setTimeout(() => {
|
|
16
|
-
timeout = undefined;
|
|
17
|
-
fn.apply(this, args);
|
|
18
|
-
}, wait);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/features/external.ts
|
|
24
|
-
const debug = Debug("tsdown:external");
|
|
25
|
-
function ExternalPlugin(options, pkg) {
|
|
26
|
-
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
27
|
-
return {
|
|
28
|
-
name: "tsdown:external",
|
|
29
|
-
async resolveId(id, importer, { isEntry }) {
|
|
30
|
-
if (isEntry) return;
|
|
31
|
-
const { noExternal } = options;
|
|
32
|
-
if (typeof noExternal === "function" && noExternal(id, importer)) return;
|
|
33
|
-
if (noExternal) {
|
|
34
|
-
const noExternalPatterns = toArray(noExternal);
|
|
35
|
-
if (noExternalPatterns.some((pattern) => {
|
|
36
|
-
return pattern instanceof RegExp ? pattern.test(id) : id === pattern;
|
|
37
|
-
})) return;
|
|
38
|
-
}
|
|
39
|
-
let shouldExternal = false;
|
|
40
|
-
if (options.skipNodeModulesBundle) {
|
|
41
|
-
const resolved = await this.resolve(id);
|
|
42
|
-
if (!resolved) return;
|
|
43
|
-
shouldExternal = resolved.external || /[\\/]node_modules[\\/]/.test(resolved.id);
|
|
44
|
-
}
|
|
45
|
-
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
46
|
-
if (shouldExternal) {
|
|
47
|
-
debug("External dependency:", id);
|
|
48
|
-
return {
|
|
49
|
-
id,
|
|
50
|
-
external: true
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getProductionDeps(pkg) {
|
|
57
|
-
return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
export { ExternalPlugin, debounce, toArray };
|
package/dist/package-VF4o7Lus.js
DELETED
|
File without changes
|