@powerlines/unplugin 0.0.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/LICENSE +201 -0
- package/README.md +305 -0
- package/dist/_virtual/_rolldown/runtime.cjs +45 -0
- package/dist/_virtual/_rolldown/runtime.mjs +36 -0
- package/dist/astro.cjs +37 -0
- package/dist/astro.d.cts +27 -0
- package/dist/astro.d.cts.map +1 -0
- package/dist/astro.d.mts +27 -0
- package/dist/astro.d.mts.map +1 -0
- package/dist/astro.mjs +36 -0
- package/dist/astro.mjs.map +1 -0
- package/dist/esbuild.cjs +155 -0
- package/dist/esbuild.d.cts +69 -0
- package/dist/esbuild.d.cts.map +1 -0
- package/dist/esbuild.d.mts +69 -0
- package/dist/esbuild.d.mts.map +1 -0
- package/dist/esbuild.mjs +149 -0
- package/dist/esbuild.mjs.map +1 -0
- package/dist/farm.cjs +56 -0
- package/dist/farm.d.cts +51 -0
- package/dist/farm.d.cts.map +1 -0
- package/dist/farm.d.mts +51 -0
- package/dist/farm.d.mts.map +1 -0
- package/dist/farm.mjs +54 -0
- package/dist/farm.mjs.map +1 -0
- package/dist/index.cjs +46 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +39 -0
- package/dist/index.mjs.map +1 -0
- package/dist/next.cjs +37 -0
- package/dist/next.d.cts +25 -0
- package/dist/next.d.cts.map +1 -0
- package/dist/next.d.mts +25 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +36 -0
- package/dist/next.mjs.map +1 -0
- package/dist/nuxt.cjs +44 -0
- package/dist/nuxt.d.cts +28 -0
- package/dist/nuxt.d.cts.map +1 -0
- package/dist/nuxt.d.mts +29 -0
- package/dist/nuxt.d.mts.map +1 -0
- package/dist/nuxt.mjs +44 -0
- package/dist/nuxt.mjs.map +1 -0
- package/dist/package.cjs +18 -0
- package/dist/package.mjs +7 -0
- package/dist/package.mjs.map +1 -0
- package/dist/rolldown.cjs +161 -0
- package/dist/rolldown.d.cts +65 -0
- package/dist/rolldown.d.cts.map +1 -0
- package/dist/rolldown.d.mts +65 -0
- package/dist/rolldown.d.mts.map +1 -0
- package/dist/rolldown.mjs +153 -0
- package/dist/rolldown.mjs.map +1 -0
- package/dist/rollup.cjs +159 -0
- package/dist/rollup.d.cts +64 -0
- package/dist/rollup.d.cts.map +1 -0
- package/dist/rollup.d.mts +64 -0
- package/dist/rollup.d.mts.map +1 -0
- package/dist/rollup.mjs +149 -0
- package/dist/rollup.mjs.map +1 -0
- package/dist/rspack.cjs +95 -0
- package/dist/rspack.d.cts +58 -0
- package/dist/rspack.d.cts.map +1 -0
- package/dist/rspack.d.mts +58 -0
- package/dist/rspack.d.mts.map +1 -0
- package/dist/rspack.mjs +90 -0
- package/dist/rspack.mjs.map +1 -0
- package/dist/tsdown.cjs +217 -0
- package/dist/tsdown.d.cts +63 -0
- package/dist/tsdown.d.cts.map +1 -0
- package/dist/tsdown.d.mts +63 -0
- package/dist/tsdown.d.mts.map +1 -0
- package/dist/tsdown.mjs +209 -0
- package/dist/tsdown.mjs.map +1 -0
- package/dist/tsup.cjs +116 -0
- package/dist/tsup.d.cts +49 -0
- package/dist/tsup.d.cts.map +1 -0
- package/dist/tsup.d.mts +49 -0
- package/dist/tsup.d.mts.map +1 -0
- package/dist/tsup.mjs +110 -0
- package/dist/tsup.mjs.map +1 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +12 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +12 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/unloader.cjs +52 -0
- package/dist/unloader.d.cts +46 -0
- package/dist/unloader.d.cts.map +1 -0
- package/dist/unloader.d.mts +46 -0
- package/dist/unloader.d.mts.map +1 -0
- package/dist/unloader.mjs +49 -0
- package/dist/unloader.mjs.map +1 -0
- package/dist/unplugin.cjs +239 -0
- package/dist/unplugin.d.cts +60 -0
- package/dist/unplugin.d.cts.map +1 -0
- package/dist/unplugin.d.mts +60 -0
- package/dist/unplugin.d.mts.map +1 -0
- package/dist/unplugin.mjs +234 -0
- package/dist/unplugin.mjs.map +1 -0
- package/dist/vite.cjs +161 -0
- package/dist/vite.d.cts +59 -0
- package/dist/vite.d.cts.map +1 -0
- package/dist/vite.d.mts +59 -0
- package/dist/vite.d.mts.map +1 -0
- package/dist/vite.mjs +155 -0
- package/dist/vite.mjs.map +1 -0
- package/dist/webpack.cjs +94 -0
- package/dist/webpack.d.cts +58 -0
- package/dist/webpack.d.cts.map +1 -0
- package/dist/webpack.d.mts +58 -0
- package/dist/webpack.d.mts.map +1 -0
- package/dist/webpack.mjs +89 -0
- package/dist/webpack.mjs.map +1 -0
- package/package.json +163 -0
package/dist/tsdown.cjs
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_rolldown = require('./rolldown.cjs');
|
|
4
|
+
let _stryke_path_append = require("@stryke/path/append");
|
|
5
|
+
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
6
|
+
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
7
|
+
let defu = require("defu");
|
|
8
|
+
defu = require_runtime.__toESM(defu, 1);
|
|
9
|
+
let _stryke_path_replace = require("@stryke/path/replace");
|
|
10
|
+
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
11
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
12
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
13
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
14
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
15
|
+
let _stryke_path_glob_to_regex = require("@stryke/path/glob-to-regex");
|
|
16
|
+
|
|
17
|
+
//#region src/tsdown.ts
|
|
18
|
+
/**
|
|
19
|
+
* Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.
|
|
20
|
+
*
|
|
21
|
+
* @param context - The build context.
|
|
22
|
+
* @returns The dependency configuration.
|
|
23
|
+
*/
|
|
24
|
+
function getDependencyConfig(context) {
|
|
25
|
+
const { external, noExternal } = (0, _powerlines_core_plugin_utils.getDependencyConfig)(context);
|
|
26
|
+
return {
|
|
27
|
+
external: !external || external.length === 0 ? void 0 : external.map((ext) => (0, _stryke_type_checks_is_set_string.isSetString)(ext) && ext.includes("*") ? (0, _stryke_path_glob_to_regex.globToRegex)(ext) : ext),
|
|
28
|
+
noExternal: !noExternal || noExternal.length === 0 ? void 0 : noExternal.map((noExt) => (0, _stryke_type_checks_is_set_string.isSetString)(noExt) && noExt.includes("*") ? (0, _stryke_path_glob_to_regex.globToRegex)(noExt) : noExt)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const DEFAULT_OPTIONS = {
|
|
32
|
+
platform: "neutral",
|
|
33
|
+
target: "esnext",
|
|
34
|
+
fixedExtension: true,
|
|
35
|
+
nodeProtocol: true,
|
|
36
|
+
clean: false
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
40
|
+
*
|
|
41
|
+
* @param formats - The formats to resolve.
|
|
42
|
+
* @returns The resolved entry options.
|
|
43
|
+
*/
|
|
44
|
+
function resolveFormat(formats) {
|
|
45
|
+
return (0, _stryke_convert_to_array.toArray)(formats).map((format) => {
|
|
46
|
+
switch (format) {
|
|
47
|
+
case "cjs": return "cjs";
|
|
48
|
+
case "iife": return "iife";
|
|
49
|
+
default: return "esm";
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
55
|
+
*
|
|
56
|
+
* @param formats - The formats to resolve.
|
|
57
|
+
* @returns The resolved entry options.
|
|
58
|
+
*/
|
|
59
|
+
function resolveFromFormat(formats) {
|
|
60
|
+
return (0, _stryke_convert_to_array.toArray)(formats).map((format) => {
|
|
61
|
+
switch (format) {
|
|
62
|
+
case "cjs":
|
|
63
|
+
case "commonjs": return "cjs";
|
|
64
|
+
case "iife": return "iife";
|
|
65
|
+
default: return "esm";
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const formatMessage = (context, ...msgs) => msgs.filter(Boolean).join(" ").trim().replace(new RegExp(`\\[${context.config.name}\\]`, "g"), "").replaceAll(/^\s+/g, "").replaceAll(/\s+$/g, "").trim();
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the options for [tsdown](https://github.com/rolldown/tsdown).
|
|
72
|
+
*
|
|
73
|
+
* @param context - The build context.
|
|
74
|
+
* @returns The resolved options.
|
|
75
|
+
*/
|
|
76
|
+
function resolveOptions(context) {
|
|
77
|
+
const { external, noExternal } = getDependencyConfig(context);
|
|
78
|
+
return (0, defu.default)({
|
|
79
|
+
name: context.config.name,
|
|
80
|
+
cwd: (0, _stryke_path_append.appendPath)(context.config.root, context.config.cwd),
|
|
81
|
+
entry: context.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(context.entry.filter((entry) => entry?.file).map((entry) => [entry.output || (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(entry.file, (0, _stryke_path_join_paths.joinPaths)(context.config.root, "src")), context.entryPath)), entry.file])) : [(0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root, "src", "**/*.ts"), (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root, "src", "**/*.tsx")],
|
|
82
|
+
exports: { customExports: (exports) => {
|
|
83
|
+
const result = Object.fromEntries(Object.entries(exports).map(([key, value]) => {
|
|
84
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(value)) return [key, value];
|
|
85
|
+
const currentExport = {};
|
|
86
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(value.require)) currentExport.require = {
|
|
87
|
+
types: (0, _stryke_path_replace.replaceExtension)(value.require, ".d.cts", { fullExtension: true }),
|
|
88
|
+
default: value.require
|
|
89
|
+
};
|
|
90
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(value.import)) currentExport.import = {
|
|
91
|
+
types: (0, _stryke_path_replace.replaceExtension)(value.import, ".d.mts", { fullExtension: true }),
|
|
92
|
+
default: value.import
|
|
93
|
+
};
|
|
94
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value.default)) {
|
|
95
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(currentExport.import)) currentExport.default = currentExport.import;
|
|
96
|
+
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(currentExport.require)) currentExport.default = currentExport.require;
|
|
97
|
+
}
|
|
98
|
+
return [key, currentExport];
|
|
99
|
+
}));
|
|
100
|
+
return Object.keys(result).sort().reduce((ret, key) => {
|
|
101
|
+
ret[key] = result[key];
|
|
102
|
+
return ret;
|
|
103
|
+
}, {});
|
|
104
|
+
} },
|
|
105
|
+
define: context.config.define,
|
|
106
|
+
inputOptions: { transform: {
|
|
107
|
+
define: context.config.define,
|
|
108
|
+
inject: context.config.inject,
|
|
109
|
+
typescript: { target: context.tsconfig.tsconfigJson?.compilerOptions?.target }
|
|
110
|
+
} },
|
|
111
|
+
deps: {
|
|
112
|
+
neverBundle: external,
|
|
113
|
+
alwaysBundle: context.config.resolve.skipNodeModulesBundle ? void 0 : noExternal,
|
|
114
|
+
onlyBundle: context.config.resolve.skipNodeModulesBundle ? noExternal : void 0,
|
|
115
|
+
skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle
|
|
116
|
+
},
|
|
117
|
+
alias: context.alias,
|
|
118
|
+
resolve: { alias: context.alias },
|
|
119
|
+
platform: context.config.platform,
|
|
120
|
+
dts: context.config.output.dts,
|
|
121
|
+
outDir: (0, _stryke_path_file_path_fns.relativePath)((0, _stryke_path_append.appendPath)(context.config.root, context.config.cwd), context.config.output.path),
|
|
122
|
+
tsconfig: (0, _stryke_path_append.appendPath)(context.tsconfig.tsconfigFilePath, context.config.cwd),
|
|
123
|
+
format: resolveFormat(context.config.output.format).filter(Boolean),
|
|
124
|
+
mode: context.config.mode,
|
|
125
|
+
minify: context.config.output.minify,
|
|
126
|
+
metafile: context.config.mode === "development",
|
|
127
|
+
sourcemap: context.config.output.sourceMap,
|
|
128
|
+
debug: context.config.mode === "development",
|
|
129
|
+
silent: context.config.logLevel.general === "silent" || context.config.mode === "production",
|
|
130
|
+
logLevel: context.config.logLevel.general === "trace" ? "debug" : "error",
|
|
131
|
+
customLogger: {
|
|
132
|
+
level: context.config.logLevel.general === "trace" ? "debug" : "error",
|
|
133
|
+
info: (...msgs) => (0, _stryke_type_checks_is_set_string.isSetString)(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.trace(formatMessage(context, ...msgs)),
|
|
134
|
+
warn: (...msgs) => (0, _stryke_type_checks_is_set_string.isSetString)(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.warn(formatMessage(context, ...msgs)),
|
|
135
|
+
warnOnce: (...msgs) => (0, _stryke_type_checks_is_set_string.isSetString)(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.warn(formatMessage(context, ...msgs)),
|
|
136
|
+
error: (...msgs) => (0, _stryke_type_checks_is_set_string.isSetString)(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.error(formatMessage(context, ...msgs)),
|
|
137
|
+
success: (...msgs) => (0, _stryke_type_checks_is_set_string.isSetString)(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.trace(formatMessage(context, ...msgs))
|
|
138
|
+
}
|
|
139
|
+
}, DEFAULT_OPTIONS);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A Tsdown configuration function that integrates Powerlines into the build process.
|
|
143
|
+
*
|
|
144
|
+
* @see https://github.com/rolldown/tsdown
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* // tsdown.config.ts
|
|
149
|
+
* import withPowerlines from "@powerlines/unplugin/tsdown";
|
|
150
|
+
*
|
|
151
|
+
* export default withPowerlines({
|
|
152
|
+
* entry: ["src/index.ts"],
|
|
153
|
+
* format: ["cjs", "esm"],
|
|
154
|
+
* dts: true,
|
|
155
|
+
* sourcemap: true,
|
|
156
|
+
* clean: true,
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @param options - The Tsdown options to merge with the Powerlines configuration.
|
|
162
|
+
* @returns The merged Tsdown configuration options.
|
|
163
|
+
*/
|
|
164
|
+
function plugin(options = {}) {
|
|
165
|
+
return {
|
|
166
|
+
...options,
|
|
167
|
+
entry: options.entry,
|
|
168
|
+
plugins: [require_rolldown.default({
|
|
169
|
+
...options,
|
|
170
|
+
output: {
|
|
171
|
+
path: options.outDir,
|
|
172
|
+
format: resolveFromFormat(options.format),
|
|
173
|
+
copy: {
|
|
174
|
+
path: options.outDir,
|
|
175
|
+
assets: (0, _stryke_convert_to_array.toArray)(options.copy).map((copy) => {
|
|
176
|
+
if (!copy) return;
|
|
177
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(copy)) return copy;
|
|
178
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(copy)) {
|
|
179
|
+
console.warn("Function-based copy options are not supported in Powerlines.");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
input: copy.from,
|
|
184
|
+
output: copy.to
|
|
185
|
+
};
|
|
186
|
+
}).filter(Boolean)
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
resolve: {
|
|
190
|
+
external: options.external ? (0, _stryke_convert_to_array.toArray)(options.external).map((external) => {
|
|
191
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(external)) {
|
|
192
|
+
console.warn("Function-based external options are not supported in Powerlines.");
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
return external;
|
|
196
|
+
}).filter(Boolean) : void 0,
|
|
197
|
+
noExternal: options.noExternal ? (0, _stryke_convert_to_array.toArray)(options.noExternal).map((noExternal) => {
|
|
198
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(noExternal)) {
|
|
199
|
+
console.warn("Function-based noExternal options are not supported in Powerlines.");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
return noExternal;
|
|
203
|
+
}).filter(Boolean) : void 0
|
|
204
|
+
},
|
|
205
|
+
tsconfig: (0, _stryke_type_checks_is_set_string.isSetString)(options.tsconfig) ? options.tsconfig : void 0
|
|
206
|
+
})]
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
|
|
212
|
+
exports.default = plugin;
|
|
213
|
+
exports.plugin = plugin;
|
|
214
|
+
exports.getDependencyConfig = getDependencyConfig;
|
|
215
|
+
exports.resolveFormat = resolveFormat;
|
|
216
|
+
exports.resolveFromFormat = resolveFromFormat;
|
|
217
|
+
exports.resolveOptions = resolveOptions;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Context } from "@powerlines/core";
|
|
2
|
+
import { GetDependencyConfigResult } from "@powerlines/core/plugin-utils";
|
|
3
|
+
import { Format } from "@storm-software/build-tools/types";
|
|
4
|
+
import { Format as Format$1, UserConfig as UserConfig$1 } from "tsdown";
|
|
5
|
+
import { UserConfig as UserConfig$2 } from "tsdown/config";
|
|
6
|
+
|
|
7
|
+
//#region src/tsdown.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.
|
|
10
|
+
*
|
|
11
|
+
* @param context - The build context.
|
|
12
|
+
* @returns The dependency configuration.
|
|
13
|
+
*/
|
|
14
|
+
declare function getDependencyConfig(context: Context): GetDependencyConfigResult;
|
|
15
|
+
declare const DEFAULT_OPTIONS: Partial<UserConfig$1>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
18
|
+
*
|
|
19
|
+
* @param formats - The formats to resolve.
|
|
20
|
+
* @returns The resolved entry options.
|
|
21
|
+
*/
|
|
22
|
+
declare function resolveFormat(formats?: Format | Format[]): Format$1[];
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
25
|
+
*
|
|
26
|
+
* @param formats - The formats to resolve.
|
|
27
|
+
* @returns The resolved entry options.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveFromFormat(formats?: Format$1 | Format$1[]): Format[];
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the options for [tsdown](https://github.com/rolldown/tsdown).
|
|
32
|
+
*
|
|
33
|
+
* @param context - The build context.
|
|
34
|
+
* @returns The resolved options.
|
|
35
|
+
*/
|
|
36
|
+
declare function resolveOptions(context: Context): UserConfig$1;
|
|
37
|
+
/**
|
|
38
|
+
* A Tsdown configuration function that integrates Powerlines into the build process.
|
|
39
|
+
*
|
|
40
|
+
* @see https://github.com/rolldown/tsdown
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // tsdown.config.ts
|
|
45
|
+
* import withPowerlines from "@powerlines/unplugin/tsdown";
|
|
46
|
+
*
|
|
47
|
+
* export default withPowerlines({
|
|
48
|
+
* entry: ["src/index.ts"],
|
|
49
|
+
* format: ["cjs", "esm"],
|
|
50
|
+
* dts: true,
|
|
51
|
+
* sourcemap: true,
|
|
52
|
+
* clean: true,
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param options - The Tsdown options to merge with the Powerlines configuration.
|
|
58
|
+
* @returns The merged Tsdown configuration options.
|
|
59
|
+
*/
|
|
60
|
+
declare function plugin(options?: UserConfig$2): UserConfig$2;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { DEFAULT_OPTIONS, plugin as default, plugin, getDependencyConfig, resolveFormat, resolveFromFormat, resolveOptions };
|
|
63
|
+
//# sourceMappingURL=tsdown.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsdown.d.cts","names":[],"sources":["../src/tsdown.ts"],"mappings":";;;;;;;;;AA2CA;;;;iBAAgB,mBAAA,CACd,OAAA,EAAS,OAAA,GACR,yBAAA;AAAA,cAqBU,eAAA,EAAiB,OAAA,CAAQ,YAAA;;;;AAAtC;;;iBAcgB,aAAA,CAAc,OAAA,GAAU,MAAA,GAAS,MAAA,KAAW,QAAA;;AAA5D;;;;;iBAoBgB,iBAAA,CACd,OAAA,GAAU,QAAA,GAAe,QAAA,KACxB,MAAA;;;;;;;iBAkCa,cAAA,CAAe,OAAA,EAAS,OAAA,GAAU,YAAA;;AApClD;;;;;;;;;;;;;;AAoCA;;;;;;;;iBAoLgB,MAAA,CAAO,OAAA,GAAS,YAAA,GAAkB,YAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Context } from "@powerlines/core";
|
|
2
|
+
import { GetDependencyConfigResult } from "@powerlines/core/plugin-utils";
|
|
3
|
+
import { Format } from "@storm-software/build-tools/types";
|
|
4
|
+
import { Format as Format$1, UserConfig as UserConfig$1 } from "tsdown";
|
|
5
|
+
import { UserConfig as UserConfig$2 } from "tsdown/config";
|
|
6
|
+
|
|
7
|
+
//#region src/tsdown.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.
|
|
10
|
+
*
|
|
11
|
+
* @param context - The build context.
|
|
12
|
+
* @returns The dependency configuration.
|
|
13
|
+
*/
|
|
14
|
+
declare function getDependencyConfig(context: Context): GetDependencyConfigResult;
|
|
15
|
+
declare const DEFAULT_OPTIONS: Partial<UserConfig$1>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
18
|
+
*
|
|
19
|
+
* @param formats - The formats to resolve.
|
|
20
|
+
* @returns The resolved entry options.
|
|
21
|
+
*/
|
|
22
|
+
declare function resolveFormat(formats?: Format | Format[]): Format$1[];
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
25
|
+
*
|
|
26
|
+
* @param formats - The formats to resolve.
|
|
27
|
+
* @returns The resolved entry options.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveFromFormat(formats?: Format$1 | Format$1[]): Format[];
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the options for [tsdown](https://github.com/rolldown/tsdown).
|
|
32
|
+
*
|
|
33
|
+
* @param context - The build context.
|
|
34
|
+
* @returns The resolved options.
|
|
35
|
+
*/
|
|
36
|
+
declare function resolveOptions(context: Context): UserConfig$1;
|
|
37
|
+
/**
|
|
38
|
+
* A Tsdown configuration function that integrates Powerlines into the build process.
|
|
39
|
+
*
|
|
40
|
+
* @see https://github.com/rolldown/tsdown
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // tsdown.config.ts
|
|
45
|
+
* import withPowerlines from "@powerlines/unplugin/tsdown";
|
|
46
|
+
*
|
|
47
|
+
* export default withPowerlines({
|
|
48
|
+
* entry: ["src/index.ts"],
|
|
49
|
+
* format: ["cjs", "esm"],
|
|
50
|
+
* dts: true,
|
|
51
|
+
* sourcemap: true,
|
|
52
|
+
* clean: true,
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param options - The Tsdown options to merge with the Powerlines configuration.
|
|
58
|
+
* @returns The merged Tsdown configuration options.
|
|
59
|
+
*/
|
|
60
|
+
declare function plugin(options?: UserConfig$2): UserConfig$2;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { DEFAULT_OPTIONS, plugin as default, plugin, getDependencyConfig, resolveFormat, resolveFromFormat, resolveOptions };
|
|
63
|
+
//# sourceMappingURL=tsdown.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsdown.d.mts","names":[],"sources":["../src/tsdown.ts"],"mappings":";;;;;;;;;AA2CA;;;;iBAAgB,mBAAA,CACd,OAAA,EAAS,OAAA,GACR,yBAAA;AAAA,cAqBU,eAAA,EAAiB,OAAA,CAAQ,YAAA;;;;AAAtC;;;iBAcgB,aAAA,CAAc,OAAA,GAAU,MAAA,GAAS,MAAA,KAAW,QAAA;;AAA5D;;;;;iBAoBgB,iBAAA,CACd,OAAA,GAAU,QAAA,GAAe,QAAA,KACxB,MAAA;;;;;;;iBAkCa,cAAA,CAAe,OAAA,EAAS,OAAA,GAAU,YAAA;;AApClD;;;;;;;;;;;;;;AAoCA;;;;;;;;iBAoLgB,MAAA,CAAO,OAAA,GAAS,YAAA,GAAkB,YAAA"}
|
package/dist/tsdown.mjs
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import plugin$1 from "./rolldown.mjs";
|
|
2
|
+
import { appendPath } from "@stryke/path/append";
|
|
3
|
+
import { relativePath } from "@stryke/path/file-path-fns";
|
|
4
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
|
+
import defu from "defu";
|
|
6
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
7
|
+
import { getDependencyConfig as getDependencyConfig$1 } from "@powerlines/core/plugin-utils";
|
|
8
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
9
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
10
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
11
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
12
|
+
import { globToRegex } from "@stryke/path/glob-to-regex";
|
|
13
|
+
|
|
14
|
+
//#region src/tsdown.ts
|
|
15
|
+
/**
|
|
16
|
+
* Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.
|
|
17
|
+
*
|
|
18
|
+
* @param context - The build context.
|
|
19
|
+
* @returns The dependency configuration.
|
|
20
|
+
*/
|
|
21
|
+
function getDependencyConfig(context) {
|
|
22
|
+
const { external, noExternal } = getDependencyConfig$1(context);
|
|
23
|
+
return {
|
|
24
|
+
external: !external || external.length === 0 ? void 0 : external.map((ext) => isSetString(ext) && ext.includes("*") ? globToRegex(ext) : ext),
|
|
25
|
+
noExternal: !noExternal || noExternal.length === 0 ? void 0 : noExternal.map((noExt) => isSetString(noExt) && noExt.includes("*") ? globToRegex(noExt) : noExt)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const DEFAULT_OPTIONS = {
|
|
29
|
+
platform: "neutral",
|
|
30
|
+
target: "esnext",
|
|
31
|
+
fixedExtension: true,
|
|
32
|
+
nodeProtocol: true,
|
|
33
|
+
clean: false
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
37
|
+
*
|
|
38
|
+
* @param formats - The formats to resolve.
|
|
39
|
+
* @returns The resolved entry options.
|
|
40
|
+
*/
|
|
41
|
+
function resolveFormat(formats) {
|
|
42
|
+
return toArray(formats).map((format) => {
|
|
43
|
+
switch (format) {
|
|
44
|
+
case "cjs": return "cjs";
|
|
45
|
+
case "iife": return "iife";
|
|
46
|
+
default: return "esm";
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).
|
|
52
|
+
*
|
|
53
|
+
* @param formats - The formats to resolve.
|
|
54
|
+
* @returns The resolved entry options.
|
|
55
|
+
*/
|
|
56
|
+
function resolveFromFormat(formats) {
|
|
57
|
+
return toArray(formats).map((format) => {
|
|
58
|
+
switch (format) {
|
|
59
|
+
case "cjs":
|
|
60
|
+
case "commonjs": return "cjs";
|
|
61
|
+
case "iife": return "iife";
|
|
62
|
+
default: return "esm";
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const formatMessage = (context, ...msgs) => msgs.filter(Boolean).join(" ").trim().replace(new RegExp(`\\[${context.config.name}\\]`, "g"), "").replaceAll(/^\s+/g, "").replaceAll(/\s+$/g, "").trim();
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the options for [tsdown](https://github.com/rolldown/tsdown).
|
|
69
|
+
*
|
|
70
|
+
* @param context - The build context.
|
|
71
|
+
* @returns The resolved options.
|
|
72
|
+
*/
|
|
73
|
+
function resolveOptions(context) {
|
|
74
|
+
const { external, noExternal } = getDependencyConfig(context);
|
|
75
|
+
return defu({
|
|
76
|
+
name: context.config.name,
|
|
77
|
+
cwd: appendPath(context.config.root, context.config.cwd),
|
|
78
|
+
entry: context.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(context.entry.filter((entry) => entry?.file).map((entry) => [entry.output || replaceExtension(replacePath(replacePath(entry.file, joinPaths(context.config.root, "src")), context.entryPath)), entry.file])) : [joinPaths(context.config.cwd, context.config.root, "src", "**/*.ts"), joinPaths(context.config.cwd, context.config.root, "src", "**/*.tsx")],
|
|
79
|
+
exports: { customExports: (exports) => {
|
|
80
|
+
const result = Object.fromEntries(Object.entries(exports).map(([key, value]) => {
|
|
81
|
+
if (isSetString(value)) return [key, value];
|
|
82
|
+
const currentExport = {};
|
|
83
|
+
if (isSetString(value.require)) currentExport.require = {
|
|
84
|
+
types: replaceExtension(value.require, ".d.cts", { fullExtension: true }),
|
|
85
|
+
default: value.require
|
|
86
|
+
};
|
|
87
|
+
if (isSetString(value.import)) currentExport.import = {
|
|
88
|
+
types: replaceExtension(value.import, ".d.mts", { fullExtension: true }),
|
|
89
|
+
default: value.import
|
|
90
|
+
};
|
|
91
|
+
if (!isSetObject(value.default)) {
|
|
92
|
+
if (isSetObject(currentExport.import)) currentExport.default = currentExport.import;
|
|
93
|
+
else if (isSetObject(currentExport.require)) currentExport.default = currentExport.require;
|
|
94
|
+
}
|
|
95
|
+
return [key, currentExport];
|
|
96
|
+
}));
|
|
97
|
+
return Object.keys(result).sort().reduce((ret, key) => {
|
|
98
|
+
ret[key] = result[key];
|
|
99
|
+
return ret;
|
|
100
|
+
}, {});
|
|
101
|
+
} },
|
|
102
|
+
define: context.config.define,
|
|
103
|
+
inputOptions: { transform: {
|
|
104
|
+
define: context.config.define,
|
|
105
|
+
inject: context.config.inject,
|
|
106
|
+
typescript: { target: context.tsconfig.tsconfigJson?.compilerOptions?.target }
|
|
107
|
+
} },
|
|
108
|
+
deps: {
|
|
109
|
+
neverBundle: external,
|
|
110
|
+
alwaysBundle: context.config.resolve.skipNodeModulesBundle ? void 0 : noExternal,
|
|
111
|
+
onlyBundle: context.config.resolve.skipNodeModulesBundle ? noExternal : void 0,
|
|
112
|
+
skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle
|
|
113
|
+
},
|
|
114
|
+
alias: context.alias,
|
|
115
|
+
resolve: { alias: context.alias },
|
|
116
|
+
platform: context.config.platform,
|
|
117
|
+
dts: context.config.output.dts,
|
|
118
|
+
outDir: relativePath(appendPath(context.config.root, context.config.cwd), context.config.output.path),
|
|
119
|
+
tsconfig: appendPath(context.tsconfig.tsconfigFilePath, context.config.cwd),
|
|
120
|
+
format: resolveFormat(context.config.output.format).filter(Boolean),
|
|
121
|
+
mode: context.config.mode,
|
|
122
|
+
minify: context.config.output.minify,
|
|
123
|
+
metafile: context.config.mode === "development",
|
|
124
|
+
sourcemap: context.config.output.sourceMap,
|
|
125
|
+
debug: context.config.mode === "development",
|
|
126
|
+
silent: context.config.logLevel.general === "silent" || context.config.mode === "production",
|
|
127
|
+
logLevel: context.config.logLevel.general === "trace" ? "debug" : "error",
|
|
128
|
+
customLogger: {
|
|
129
|
+
level: context.config.logLevel.general === "trace" ? "debug" : "error",
|
|
130
|
+
info: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.trace(formatMessage(context, ...msgs)),
|
|
131
|
+
warn: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.warn(formatMessage(context, ...msgs)),
|
|
132
|
+
warnOnce: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.warn(formatMessage(context, ...msgs)),
|
|
133
|
+
error: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.error(formatMessage(context, ...msgs)),
|
|
134
|
+
success: (...msgs) => isSetString(formatMessage(context, ...msgs).replace(/\s+/g, "")) && context.trace(formatMessage(context, ...msgs))
|
|
135
|
+
}
|
|
136
|
+
}, DEFAULT_OPTIONS);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A Tsdown configuration function that integrates Powerlines into the build process.
|
|
140
|
+
*
|
|
141
|
+
* @see https://github.com/rolldown/tsdown
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* // tsdown.config.ts
|
|
146
|
+
* import withPowerlines from "@powerlines/unplugin/tsdown";
|
|
147
|
+
*
|
|
148
|
+
* export default withPowerlines({
|
|
149
|
+
* entry: ["src/index.ts"],
|
|
150
|
+
* format: ["cjs", "esm"],
|
|
151
|
+
* dts: true,
|
|
152
|
+
* sourcemap: true,
|
|
153
|
+
* clean: true,
|
|
154
|
+
* });
|
|
155
|
+
*
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @param options - The Tsdown options to merge with the Powerlines configuration.
|
|
159
|
+
* @returns The merged Tsdown configuration options.
|
|
160
|
+
*/
|
|
161
|
+
function plugin(options = {}) {
|
|
162
|
+
return {
|
|
163
|
+
...options,
|
|
164
|
+
entry: options.entry,
|
|
165
|
+
plugins: [plugin$1({
|
|
166
|
+
...options,
|
|
167
|
+
output: {
|
|
168
|
+
path: options.outDir,
|
|
169
|
+
format: resolveFromFormat(options.format),
|
|
170
|
+
copy: {
|
|
171
|
+
path: options.outDir,
|
|
172
|
+
assets: toArray(options.copy).map((copy) => {
|
|
173
|
+
if (!copy) return;
|
|
174
|
+
if (isSetString(copy)) return copy;
|
|
175
|
+
if (isFunction(copy)) {
|
|
176
|
+
console.warn("Function-based copy options are not supported in Powerlines.");
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
input: copy.from,
|
|
181
|
+
output: copy.to
|
|
182
|
+
};
|
|
183
|
+
}).filter(Boolean)
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
resolve: {
|
|
187
|
+
external: options.external ? toArray(options.external).map((external) => {
|
|
188
|
+
if (isFunction(external)) {
|
|
189
|
+
console.warn("Function-based external options are not supported in Powerlines.");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
return external;
|
|
193
|
+
}).filter(Boolean) : void 0,
|
|
194
|
+
noExternal: options.noExternal ? toArray(options.noExternal).map((noExternal) => {
|
|
195
|
+
if (isFunction(noExternal)) {
|
|
196
|
+
console.warn("Function-based noExternal options are not supported in Powerlines.");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
return noExternal;
|
|
200
|
+
}).filter(Boolean) : void 0
|
|
201
|
+
},
|
|
202
|
+
tsconfig: isSetString(options.tsconfig) ? options.tsconfig : void 0
|
|
203
|
+
})]
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
export { DEFAULT_OPTIONS, plugin as default, plugin, getDependencyConfig, resolveFormat, resolveFromFormat, resolveOptions };
|
|
209
|
+
//# sourceMappingURL=tsdown.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsdown.mjs","names":["_getDependencyConfig","rolldown"],"sources":["../src/tsdown.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Context, CopyConfig, ResolveConfig } from \"@powerlines/core\";\nimport type { GetDependencyConfigResult } from \"@powerlines/core/plugin-utils\";\nimport { getDependencyConfig as _getDependencyConfig } from \"@powerlines/core/plugin-utils\";\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { ModuleFormat } from \"rolldown\";\nimport { UserConfig as BuildOptions, Format as TsdownFormat } from \"tsdown\";\nimport type { UserConfig } from \"tsdown/config\";\nimport rolldown from \"./rolldown\";\n\n/**\n * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.\n *\n * @param context - The build context.\n * @returns The dependency configuration.\n */\nexport function getDependencyConfig(\n context: Context\n): GetDependencyConfigResult {\n const { external, noExternal } = _getDependencyConfig(context);\n\n return {\n external:\n !external || external.length === 0\n ? undefined\n : external.map(ext =>\n isSetString(ext) && ext.includes(\"*\") ? globToRegex(ext) : ext\n ),\n noExternal:\n !noExternal || noExternal.length === 0\n ? undefined\n : noExternal.map(noExt =>\n isSetString(noExt) && noExt.includes(\"*\")\n ? globToRegex(noExt)\n : noExt\n )\n };\n}\n\nexport const DEFAULT_OPTIONS: Partial<BuildOptions> = {\n platform: \"neutral\",\n target: \"esnext\",\n fixedExtension: true,\n nodeProtocol: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFormat(formats?: Format | Format[]): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = (context: Context, ...msgs: any[]) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .trim()\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .replaceAll(/^\\s+/g, \"\")\n .replaceAll(/\\s+$/g, \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions(context: Context): BuildOptions {\n const { external, noExternal } = getDependencyConfig(context);\n\n return defu(\n {\n name: context.config.name,\n cwd: appendPath(context.config.root, context.config.cwd),\n entry:\n context.entry.filter(entry => entry?.file).length > 0\n ? Object.fromEntries(\n context.entry\n .filter(entry => entry?.file)\n .map(entry => [\n entry.output ||\n replaceExtension(\n replacePath(\n replacePath(\n entry.file,\n joinPaths(context.config.root, \"src\")\n ),\n context.entryPath\n )\n ),\n entry.file\n ])\n )\n : [\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.ts\"\n ),\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.tsx\"\n )\n ],\n exports: {\n customExports: (exports: Record<string, any>) => {\n const result = Object.fromEntries(\n Object.entries(exports).map(([key, value]) => {\n if (isSetString(value)) {\n return [key, value];\n }\n\n const currentExport = {} as Record<string, any>;\n if (isSetString(value.require)) {\n currentExport.require = {\n types: replaceExtension(value.require, \".d.cts\", {\n fullExtension: true\n }),\n default: value.require\n };\n }\n\n if (isSetString(value.import)) {\n currentExport.import = {\n types: replaceExtension(value.import, \".d.mts\", {\n fullExtension: true\n }),\n default: value.import\n };\n }\n\n if (!isSetObject(value.default)) {\n if (isSetObject(currentExport.import)) {\n currentExport.default = currentExport.import;\n } else if (isSetObject(currentExport.require)) {\n currentExport.default = currentExport.require;\n }\n }\n\n return [key, currentExport];\n })\n );\n\n return Object.keys(result)\n .sort()\n .reduce(\n (ret, key) => {\n ret[key] = result[key];\n return ret;\n },\n {} as Record<string, any>\n );\n }\n },\n define: context.config.define,\n inputOptions: {\n transform: {\n define: context.config.define,\n inject: context.config.inject,\n typescript: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target\n }\n }\n },\n deps: {\n neverBundle: external,\n alwaysBundle: context.config.resolve.skipNodeModulesBundle\n ? undefined\n : noExternal,\n onlyBundle: context.config.resolve.skipNodeModulesBundle\n ? noExternal\n : undefined,\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle\n },\n alias: context.alias,\n resolve: {\n alias: context.alias\n },\n platform: context.config.platform,\n dts: context.config.output.dts,\n outDir: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n format: resolveFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n logLevel: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n customLogger: {\n level: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs))\n }\n },\n DEFAULT_OPTIONS\n ) as BuildOptions;\n}\n\n/**\n * A Tsdown configuration function that integrates Powerlines into the build process.\n *\n * @see https://github.com/rolldown/tsdown\n *\n * @example\n * ```ts\n * // tsdown.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsdown\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsdown options to merge with the Powerlines configuration.\n * @returns The merged Tsdown configuration options.\n */\nexport function plugin(options: UserConfig = {}): UserConfig {\n return {\n ...options,\n entry: options.entry,\n plugins: [\n rolldown({\n ...options,\n output: {\n path: options.outDir,\n format: resolveFromFormat(\n options.format as ModuleFormat | ModuleFormat[]\n ),\n copy: {\n path: options.outDir!,\n assets: toArray(options.copy)\n .map(copy => {\n if (!copy) {\n return undefined;\n }\n if (isSetString(copy)) {\n return copy;\n }\n if (isFunction(copy)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based copy options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return {\n input: copy.from,\n output: copy.to\n };\n })\n .filter(Boolean) as CopyConfig[\"assets\"]\n }\n },\n resolve: {\n external: options.external\n ? (toArray(options.external)\n .map(external => {\n if (isFunction(external)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based external options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return external;\n })\n .filter(Boolean) as ResolveConfig[\"external\"])\n : undefined,\n noExternal: options.noExternal\n ? (toArray(options.noExternal)\n .map(noExternal => {\n if (isFunction(noExternal)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based noExternal options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return noExternal;\n })\n .filter(Boolean) as ResolveConfig[\"noExternal\"])\n : undefined\n },\n tsconfig: isSetString(options.tsconfig) ? options.tsconfig : undefined\n })\n ]\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,oBACd,SAC2B;CAC3B,MAAM,EAAE,UAAU,eAAeA,sBAAqB,QAAQ;CAE9D,OAAO;EACL,UACE,CAAC,YAAY,SAAS,WAAW,IAC7B,SACA,SAAS,KAAI,QACX,YAAY,IAAI,IAAI,IAAI,SAAS,IAAI,GAAG,YAAY,IAAI,GAAG,IAC5D;EACP,YACE,CAAC,cAAc,WAAW,WAAW,IACjC,SACA,WAAW,KAAI,UACb,YAAY,MAAM,IAAI,MAAM,SAAS,IAAI,GACrC,YAAY,MAAM,GAClB,MACL;EACR;;AAGH,MAAa,kBAAyC;CACpD,UAAU;CACV,QAAQ;CACR,gBAAgB;CAChB,cAAc;CACd,OAAO;CACR;;;;;;;AAQD,SAAgB,cAAc,SAA6C;CACzE,OAAO,QAAQ,QAAQ,CAAC,KAAI,WAAU;EACpC,QAAQ,QAAR;GACE,KAAK,OACH,OAAO;GACT,KAAK,QACH,OAAO;GA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