@rollipop/rolldown 0.0.0-beta.0
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 +25 -0
- package/README.md +11 -0
- package/bin/cli.mjs +3 -0
- package/dist/cli-setup.d.mts +1 -0
- package/dist/cli-setup.mjs +17 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1581 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +14 -0
- package/dist/experimental-index.d.mts +239 -0
- package/dist/experimental-index.mjs +299 -0
- package/dist/experimental-runtime-types.d.ts +92 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +369 -0
- package/dist/get-log-filter.d.mts +7 -0
- package/dist/get-log-filter.mjs +48 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +38 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/parallel-plugin-worker.mjs +32 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/parallel-plugin.mjs +7 -0
- package/dist/parse-ast-index.d.mts +8 -0
- package/dist/parse-ast-index.mjs +4 -0
- package/dist/plugins-index.d.mts +31 -0
- package/dist/plugins-index.mjs +40 -0
- package/dist/shared/binding-DmMMxMk0.mjs +584 -0
- package/dist/shared/binding-kAegJ1Bj.d.mts +1775 -0
- package/dist/shared/bindingify-input-options-D0BAGfk2.mjs +1622 -0
- package/dist/shared/constructors-F44lhsH3.d.mts +30 -0
- package/dist/shared/constructors-Rl_oLd2F.mjs +67 -0
- package/dist/shared/define-config-BF4P-Pum.mjs +7 -0
- package/dist/shared/define-config-DJ1-iIdx.d.mts +2562 -0
- package/dist/shared/load-config-BEpugZky.mjs +114 -0
- package/dist/shared/logging-DsnCZi19.d.mts +42 -0
- package/dist/shared/logs-cyjC0SDv.mjs +183 -0
- package/dist/shared/misc-DpjTMcQQ.mjs +22 -0
- package/dist/shared/normalize-string-or-regex-DbTZ9prS.mjs +670 -0
- package/dist/shared/parse-ast-index-BuuhACPk.mjs +99 -0
- package/dist/shared/prompt-5sWCM0jm.mjs +847 -0
- package/dist/shared/rolldown-build-viDZfkdI.mjs +2292 -0
- package/dist/shared/rolldown-il0-nWH9.mjs +11 -0
- package/dist/shared/watch-BSdMzY6q.mjs +352 -0
- package/package.json +128 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { n as isPromiseLike, t as arraify } from "./shared/misc-DpjTMcQQ.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../pluginutils/dist/utils.js
|
|
4
|
+
const postfixRE = /[?#].*$/;
|
|
5
|
+
function cleanUrl(url) {
|
|
6
|
+
return url.replace(postfixRE, "");
|
|
7
|
+
}
|
|
8
|
+
function extractQueryWithoutFragment(url) {
|
|
9
|
+
const questionMarkIndex = url.indexOf("?");
|
|
10
|
+
if (questionMarkIndex === -1) return "";
|
|
11
|
+
const fragmentIndex = url.indexOf("#", questionMarkIndex);
|
|
12
|
+
if (fragmentIndex === -1) return url.substring(questionMarkIndex);
|
|
13
|
+
else return url.substring(questionMarkIndex, fragmentIndex);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../pluginutils/dist/filter/composable-filters.js
|
|
18
|
+
var And = class {
|
|
19
|
+
kind;
|
|
20
|
+
args;
|
|
21
|
+
constructor(...args) {
|
|
22
|
+
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
|
23
|
+
this.args = args;
|
|
24
|
+
this.kind = "and";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var Or = class {
|
|
28
|
+
kind;
|
|
29
|
+
args;
|
|
30
|
+
constructor(...args) {
|
|
31
|
+
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
|
32
|
+
this.args = args;
|
|
33
|
+
this.kind = "or";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var Not = class {
|
|
37
|
+
kind;
|
|
38
|
+
expr;
|
|
39
|
+
constructor(expr) {
|
|
40
|
+
this.expr = expr;
|
|
41
|
+
this.kind = "not";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var Id = class {
|
|
45
|
+
kind;
|
|
46
|
+
pattern;
|
|
47
|
+
params;
|
|
48
|
+
constructor(pattern, params) {
|
|
49
|
+
this.pattern = pattern;
|
|
50
|
+
this.kind = "id";
|
|
51
|
+
this.params = params ?? { cleanUrl: false };
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var ImporterId = class {
|
|
55
|
+
kind;
|
|
56
|
+
pattern;
|
|
57
|
+
params;
|
|
58
|
+
constructor(pattern, params) {
|
|
59
|
+
this.pattern = pattern;
|
|
60
|
+
this.kind = "importerId";
|
|
61
|
+
this.params = params ?? { cleanUrl: false };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var ModuleType = class {
|
|
65
|
+
kind;
|
|
66
|
+
pattern;
|
|
67
|
+
constructor(pattern) {
|
|
68
|
+
this.pattern = pattern;
|
|
69
|
+
this.kind = "moduleType";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var Code = class {
|
|
73
|
+
kind;
|
|
74
|
+
pattern;
|
|
75
|
+
constructor(expr) {
|
|
76
|
+
this.pattern = expr;
|
|
77
|
+
this.kind = "code";
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var Query = class {
|
|
81
|
+
kind;
|
|
82
|
+
key;
|
|
83
|
+
pattern;
|
|
84
|
+
constructor(key, pattern) {
|
|
85
|
+
this.pattern = pattern;
|
|
86
|
+
this.key = key;
|
|
87
|
+
this.kind = "query";
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var Include = class {
|
|
91
|
+
kind;
|
|
92
|
+
expr;
|
|
93
|
+
constructor(expr) {
|
|
94
|
+
this.expr = expr;
|
|
95
|
+
this.kind = "include";
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var Exclude = class {
|
|
99
|
+
kind;
|
|
100
|
+
expr;
|
|
101
|
+
constructor(expr) {
|
|
102
|
+
this.expr = expr;
|
|
103
|
+
this.kind = "exclude";
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function and(...args) {
|
|
107
|
+
return new And(...args);
|
|
108
|
+
}
|
|
109
|
+
function or(...args) {
|
|
110
|
+
return new Or(...args);
|
|
111
|
+
}
|
|
112
|
+
function not(expr) {
|
|
113
|
+
return new Not(expr);
|
|
114
|
+
}
|
|
115
|
+
function id(pattern, params) {
|
|
116
|
+
return new Id(pattern, params);
|
|
117
|
+
}
|
|
118
|
+
function importerId(pattern, params) {
|
|
119
|
+
return new ImporterId(pattern, params);
|
|
120
|
+
}
|
|
121
|
+
function moduleType(pattern) {
|
|
122
|
+
return new ModuleType(pattern);
|
|
123
|
+
}
|
|
124
|
+
function code(pattern) {
|
|
125
|
+
return new Code(pattern);
|
|
126
|
+
}
|
|
127
|
+
function query(key, pattern) {
|
|
128
|
+
return new Query(key, pattern);
|
|
129
|
+
}
|
|
130
|
+
function include(expr) {
|
|
131
|
+
return new Include(expr);
|
|
132
|
+
}
|
|
133
|
+
function exclude(expr) {
|
|
134
|
+
return new Exclude(expr);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* convert a queryObject to FilterExpression like
|
|
138
|
+
* ```js
|
|
139
|
+
* and(query(k1, v1), query(k2, v2))
|
|
140
|
+
* ```
|
|
141
|
+
* @param queryFilterObject The query filter object needs to be matched.
|
|
142
|
+
* @returns a `And` FilterExpression
|
|
143
|
+
*/
|
|
144
|
+
function queries(queryFilter) {
|
|
145
|
+
return and(...Object.entries(queryFilter).map(([key, value]) => {
|
|
146
|
+
return new Query(key, value);
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
function interpreter(exprs, code, id, moduleType, importerId) {
|
|
150
|
+
let arr = [];
|
|
151
|
+
if (Array.isArray(exprs)) arr = exprs;
|
|
152
|
+
else arr = [exprs];
|
|
153
|
+
return interpreterImpl(arr, code, id, moduleType, importerId);
|
|
154
|
+
}
|
|
155
|
+
function interpreterImpl(expr, code, id, moduleType, importerId, ctx = {}) {
|
|
156
|
+
let hasInclude = false;
|
|
157
|
+
for (const e of expr) switch (e.kind) {
|
|
158
|
+
case "include":
|
|
159
|
+
hasInclude = true;
|
|
160
|
+
if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) return true;
|
|
161
|
+
break;
|
|
162
|
+
case "exclude":
|
|
163
|
+
if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) return false;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return !hasInclude;
|
|
167
|
+
}
|
|
168
|
+
function exprInterpreter(expr, code, id, moduleType, importerId, ctx = {}) {
|
|
169
|
+
switch (expr.kind) {
|
|
170
|
+
case "and": return expr.args.every((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
|
|
171
|
+
case "or": return expr.args.some((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
|
|
172
|
+
case "not": return !exprInterpreter(expr.expr, code, id, moduleType, importerId, ctx);
|
|
173
|
+
case "id": {
|
|
174
|
+
if (id === void 0) throw new Error("`id` is required for `id` expression");
|
|
175
|
+
let idToMatch = id;
|
|
176
|
+
if (expr.params.cleanUrl) idToMatch = cleanUrl(idToMatch);
|
|
177
|
+
return typeof expr.pattern === "string" ? idToMatch === expr.pattern : expr.pattern.test(idToMatch);
|
|
178
|
+
}
|
|
179
|
+
case "importerId": {
|
|
180
|
+
if (importerId === void 0) return false;
|
|
181
|
+
let importerIdToMatch = importerId;
|
|
182
|
+
if (expr.params.cleanUrl) importerIdToMatch = cleanUrl(importerIdToMatch);
|
|
183
|
+
return typeof expr.pattern === "string" ? importerIdToMatch === expr.pattern : expr.pattern.test(importerIdToMatch);
|
|
184
|
+
}
|
|
185
|
+
case "moduleType":
|
|
186
|
+
if (moduleType === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
|
|
187
|
+
return moduleType === expr.pattern;
|
|
188
|
+
case "code":
|
|
189
|
+
if (code === void 0) throw new Error("`code` is required for `code` expression");
|
|
190
|
+
return typeof expr.pattern === "string" ? code.includes(expr.pattern) : expr.pattern.test(code);
|
|
191
|
+
case "query": {
|
|
192
|
+
if (id === void 0) throw new Error("`id` is required for `Query` expression");
|
|
193
|
+
if (!ctx.urlSearchParamsCache) {
|
|
194
|
+
let queryString = extractQueryWithoutFragment(id);
|
|
195
|
+
ctx.urlSearchParamsCache = new URLSearchParams(queryString);
|
|
196
|
+
}
|
|
197
|
+
let urlParams = ctx.urlSearchParamsCache;
|
|
198
|
+
if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
|
|
199
|
+
else return !urlParams.has(expr.key);
|
|
200
|
+
else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
|
|
201
|
+
else return expr.pattern.test(urlParams.get(expr.key) ?? "");
|
|
202
|
+
}
|
|
203
|
+
default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region ../pluginutils/dist/filter/filter-vite-plugins.js
|
|
209
|
+
/**
|
|
210
|
+
* Filters out Vite plugins that have `apply: 'serve'` set.
|
|
211
|
+
*
|
|
212
|
+
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
|
213
|
+
* are intended only for Vite's dev server and should be excluded from the build process.
|
|
214
|
+
*
|
|
215
|
+
* @param plugins - Array of plugins (can include nested arrays)
|
|
216
|
+
* @returns Filtered array with serve-only plugins removed
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* import { defineConfig } from '@rollipop/rolldown';
|
|
221
|
+
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
|
222
|
+
* import viteReact from '@vitejs/plugin-react';
|
|
223
|
+
*
|
|
224
|
+
* export default defineConfig({
|
|
225
|
+
* plugins: filterVitePlugins([
|
|
226
|
+
* viteReact(),
|
|
227
|
+
* {
|
|
228
|
+
* name: 'dev-only',
|
|
229
|
+
* apply: 'serve', // This will be filtered out
|
|
230
|
+
* // ...
|
|
231
|
+
* }
|
|
232
|
+
* ])
|
|
233
|
+
* });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
function filterVitePlugins(plugins) {
|
|
237
|
+
if (!plugins) return [];
|
|
238
|
+
const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
|
|
239
|
+
const result = [];
|
|
240
|
+
for (const plugin of pluginArray) {
|
|
241
|
+
if (!plugin) continue;
|
|
242
|
+
if (Array.isArray(plugin)) {
|
|
243
|
+
result.push(...filterVitePlugins(plugin));
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const pluginWithApply = plugin;
|
|
247
|
+
if ("apply" in pluginWithApply) {
|
|
248
|
+
const applyValue = pluginWithApply.apply;
|
|
249
|
+
if (typeof applyValue === "function") try {
|
|
250
|
+
if (applyValue({}, {
|
|
251
|
+
command: "build",
|
|
252
|
+
mode: "production"
|
|
253
|
+
})) result.push(plugin);
|
|
254
|
+
} catch {
|
|
255
|
+
result.push(plugin);
|
|
256
|
+
}
|
|
257
|
+
else if (applyValue === "serve") continue;
|
|
258
|
+
else result.push(plugin);
|
|
259
|
+
} else result.push(plugin);
|
|
260
|
+
}
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region ../pluginutils/dist/filter/simple-filters.js
|
|
266
|
+
/**
|
|
267
|
+
* Constructs a RegExp that matches the exact string specified.
|
|
268
|
+
*
|
|
269
|
+
* This is useful for plugin hook filters.
|
|
270
|
+
*
|
|
271
|
+
* @param str the string to match.
|
|
272
|
+
* @param flags flags for the RegExp.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { exactRegex } from '@rolldown/pluginutils';
|
|
277
|
+
* const plugin = {
|
|
278
|
+
* name: 'plugin',
|
|
279
|
+
* resolveId: {
|
|
280
|
+
* filter: { id: exactRegex('foo') },
|
|
281
|
+
* handler(id) {} // will only be called for `foo`
|
|
282
|
+
* }
|
|
283
|
+
* }
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
function exactRegex(str, flags) {
|
|
287
|
+
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Constructs a RegExp that matches a value that has the specified prefix.
|
|
291
|
+
*
|
|
292
|
+
* This is useful for plugin hook filters.
|
|
293
|
+
*
|
|
294
|
+
* @param str the string to match.
|
|
295
|
+
* @param flags flags for the RegExp.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
300
|
+
* const plugin = {
|
|
301
|
+
* name: 'plugin',
|
|
302
|
+
* resolveId: {
|
|
303
|
+
* filter: { id: prefixRegex('foo') },
|
|
304
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
305
|
+
* }
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
function prefixRegex(str, flags) {
|
|
310
|
+
return new RegExp(`^${escapeRegex(str)}`, flags);
|
|
311
|
+
}
|
|
312
|
+
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
|
313
|
+
function escapeRegex(str) {
|
|
314
|
+
return str.replace(escapeRegexRE, "\\$&");
|
|
315
|
+
}
|
|
316
|
+
function makeIdFiltersToMatchWithQuery(input) {
|
|
317
|
+
if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
|
|
318
|
+
return input.map((i) => makeIdFilterToMatchWithQuery(i));
|
|
319
|
+
}
|
|
320
|
+
function makeIdFilterToMatchWithQuery(input) {
|
|
321
|
+
if (typeof input === "string") return `${input}{?*,}`;
|
|
322
|
+
return makeRegexIdFilterToMatchWithQuery(input);
|
|
323
|
+
}
|
|
324
|
+
function makeRegexIdFilterToMatchWithQuery(input) {
|
|
325
|
+
return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/plugin/with-filter.ts
|
|
330
|
+
function withFilterImpl(pluginOption, filterObjectList) {
|
|
331
|
+
if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
|
|
332
|
+
if (pluginOption == false || pluginOption == null) return pluginOption;
|
|
333
|
+
if (Array.isArray(pluginOption)) return pluginOption.map((p) => withFilter(p, filterObjectList));
|
|
334
|
+
let plugin = pluginOption;
|
|
335
|
+
let filterObjectIndex = findMatchedFilterObject(plugin.name, filterObjectList);
|
|
336
|
+
if (filterObjectIndex === -1) return plugin;
|
|
337
|
+
let filterObject = filterObjectList[filterObjectIndex];
|
|
338
|
+
Object.keys(plugin).forEach((key) => {
|
|
339
|
+
switch (key) {
|
|
340
|
+
case "transform":
|
|
341
|
+
case "resolveId":
|
|
342
|
+
case "load":
|
|
343
|
+
if (!plugin[key]) return;
|
|
344
|
+
if (typeof plugin[key] === "object") plugin[key].filter = filterObject[key] ?? plugin[key].filter;
|
|
345
|
+
else plugin[key] = {
|
|
346
|
+
handler: plugin[key],
|
|
347
|
+
filter: filterObject[key]
|
|
348
|
+
};
|
|
349
|
+
break;
|
|
350
|
+
default: break;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
return plugin;
|
|
354
|
+
}
|
|
355
|
+
function withFilter(pluginOption, filterObject) {
|
|
356
|
+
return withFilterImpl(pluginOption, arraify(filterObject));
|
|
357
|
+
}
|
|
358
|
+
function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
|
|
359
|
+
if (overrideFilterObjectList.length === 1 && overrideFilterObjectList[0].pluginNamePattern === void 0) return 0;
|
|
360
|
+
for (let i = 0; i < overrideFilterObjectList.length; i++) for (let j = 0; j < (overrideFilterObjectList[i].pluginNamePattern ?? []).length; j++) {
|
|
361
|
+
let pattern = overrideFilterObjectList[i].pluginNamePattern[j];
|
|
362
|
+
if (typeof pattern === "string" && pattern === pluginName) return i;
|
|
363
|
+
else if (pattern instanceof RegExp && pattern.test(pluginName)) return i;
|
|
364
|
+
}
|
|
365
|
+
return -1;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
//#endregion
|
|
369
|
+
export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as RollupLog } from "./shared/logging-DsnCZi19.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/get-log-filter.d.ts
|
|
4
|
+
type GetLogFilter = (filters: string[]) => (log: RollupLog) => boolean;
|
|
5
|
+
declare const getLogFilter: GetLogFilter;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { GetLogFilter, type RollupLog, getLogFilter as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/get-log-filter.ts
|
|
2
|
+
const getLogFilter = (filters) => {
|
|
3
|
+
if (filters.length === 0) return () => true;
|
|
4
|
+
const normalizedFilters = filters.map((filter) => filter.split("&").map((subFilter) => {
|
|
5
|
+
const inverted = subFilter.startsWith("!");
|
|
6
|
+
if (inverted) subFilter = subFilter.slice(1);
|
|
7
|
+
const [key, ...value] = subFilter.split(":");
|
|
8
|
+
return {
|
|
9
|
+
inverted,
|
|
10
|
+
key: key.split("."),
|
|
11
|
+
parts: value.join(":").split("*")
|
|
12
|
+
};
|
|
13
|
+
}));
|
|
14
|
+
return (log) => {
|
|
15
|
+
nextIntersectedFilter: for (const intersectedFilters of normalizedFilters) {
|
|
16
|
+
for (const { inverted, key, parts } of intersectedFilters) {
|
|
17
|
+
const isFilterSatisfied = testFilter(log, key, parts);
|
|
18
|
+
if (inverted ? isFilterSatisfied : !isFilterSatisfied) continue nextIntersectedFilter;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const testFilter = (log, key, parts) => {
|
|
26
|
+
let rawValue = log;
|
|
27
|
+
for (let index = 0; index < key.length; index++) {
|
|
28
|
+
if (!rawValue) return false;
|
|
29
|
+
const part = key[index];
|
|
30
|
+
if (!(part in rawValue)) return false;
|
|
31
|
+
rawValue = rawValue[part];
|
|
32
|
+
}
|
|
33
|
+
let value = typeof rawValue === "object" ? JSON.stringify(rawValue) : String(rawValue);
|
|
34
|
+
if (parts.length === 1) return value === parts[0];
|
|
35
|
+
if (!value.startsWith(parts[0])) return false;
|
|
36
|
+
const lastPartIndex = parts.length - 1;
|
|
37
|
+
for (let index = 1; index < lastPartIndex; index++) {
|
|
38
|
+
const part = parts[index];
|
|
39
|
+
const position = value.indexOf(part);
|
|
40
|
+
if (position === -1) return false;
|
|
41
|
+
value = value.slice(position + part.length);
|
|
42
|
+
}
|
|
43
|
+
return value.endsWith(parts[lastPartIndex]);
|
|
44
|
+
};
|
|
45
|
+
var get_log_filter_default = getLogFilter;
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { get_log_filter_default as default };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-DsnCZi19.mjs";
|
|
2
|
+
import { V as PreRenderedChunk, s as BindingMagicString } from "./shared/binding-kAegJ1Bj.mjs";
|
|
3
|
+
import { $ as RolldownFileStats, A as TransformResult, B as EmittedFile, C as Plugin, Ct as GlobalsFunction, D as RolldownPlugin, Dt as PreRenderedAsset, E as ResolvedId, Et as OutputOptions, F as SourceMapInput, Ft as RolldownOutput, H as GetModuleInfo, I as OutputBundle, It as SourceMap, J as GeneralHookFilter, K as MinimalPluginContext, L as TreeshakingOptions, Mt as OutputChunk, N as VERSION, Nt as RenderedChunk, O as RolldownPluginOption, P as ExistingRawSourceMap, Pt as RenderedModule, Q as RolldownDirectoryEntry, R as TransformPluginContext, Rt as ModuleInfo, S as PartialResolvedId, St as GeneratedCodePreset, T as ResolveIdResult, Tt as ModuleFormat, U as PluginContext, V as EmittedPrebuiltChunk, W as DefineParallelPluginResult, X as ModuleTypeFilter, Y as HookFilter, Z as BufferEncoding, _ as LoadResult, _t as AdvancedChunksGroup, a as ExternalOption, at as ChecksOptions, b as ObjectHook, bt as CodeSplittingGroup, c as InputOptions, ct as watch, d as WatcherOptions, dt as WatchOptions, et as RolldownFsModule, f as AsyncPluginHooks, ft as rolldown, g as ImportKind, gt as AddonFunction, h as HookFilterExtension, ht as build, i as RolldownOptions, it as TransformOptions, jt as OutputAsset, k as SourceDescription, kt as PartialNull, l as ModuleTypes, lt as RolldownWatcher, m as FunctionPluginHooks, mt as BuildOptions, n as RolldownOptionsFunction, nt as NormalizedOutputOptions, o as ExternalOptionFunction, ot as LoggingFunction, p as CustomPluginOptions, pt as RolldownBuild, q as PluginContextMeta, r as defineConfig, rt as NormalizedInputOptions, s as InputOption, st as WarningHandlerWithDefault, t as ConfigExport, tt as InternalModuleFormat, u as OptimizationOptions, ut as RolldownWatcherEvent, v as ModuleOptions, vt as ChunkFileNamesFunction, w as ResolveIdExtraOptions, wt as MinifyOptions, x as ParallelPluginHooks, xt as GeneratedCodeOptions, y as ModuleType, yt as ChunkingContext, z as EmittedAsset, zt as SourcemapIgnoreListOption } from "./shared/define-config-DJ1-iIdx.mjs";
|
|
4
|
+
export { AddonFunction, AdvancedChunksGroup, AsyncPluginHooks, BindingMagicString, BufferEncoding, BuildOptions, ChecksOptions, ChunkFileNamesFunction, ChunkingContext, CodeSplittingGroup, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, EmittedPrebuiltChunk, ExistingRawSourceMap, ExternalOption, ExternalOptionFunction, FunctionPluginHooks, GeneralHookFilter, GeneratedCodeOptions, GeneratedCodePreset, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OptimizationOptions, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownFileStats, RolldownFsModule, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformOptions, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./shared/binding-DmMMxMk0.mjs";
|
|
2
|
+
import { n as onExit, t as watch } from "./shared/watch-BSdMzY6q.mjs";
|
|
3
|
+
import { y as VERSION } from "./shared/normalize-string-or-regex-DbTZ9prS.mjs";
|
|
4
|
+
import "./shared/rolldown-build-viDZfkdI.mjs";
|
|
5
|
+
import "./shared/bindingify-input-options-D0BAGfk2.mjs";
|
|
6
|
+
import "./shared/parse-ast-index-BuuhACPk.mjs";
|
|
7
|
+
import { t as rolldown } from "./shared/rolldown-il0-nWH9.mjs";
|
|
8
|
+
import { t as defineConfig } from "./shared/define-config-BF4P-Pum.mjs";
|
|
9
|
+
import { isMainThread } from "node:worker_threads";
|
|
10
|
+
|
|
11
|
+
//#region src/setup.ts
|
|
12
|
+
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
13
|
+
if (isMainThread) {
|
|
14
|
+
const subscriberGuard = (0, import_binding.initTraceSubscriber)();
|
|
15
|
+
onExit(() => {
|
|
16
|
+
subscriberGuard?.close();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/api/build.ts
|
|
22
|
+
async function build(options) {
|
|
23
|
+
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
24
|
+
else {
|
|
25
|
+
const { output, write = true, ...inputOptions } = options;
|
|
26
|
+
const build = await rolldown(inputOptions);
|
|
27
|
+
try {
|
|
28
|
+
if (write) return await build.write(output);
|
|
29
|
+
else return await build.generate(output);
|
|
30
|
+
} finally {
|
|
31
|
+
await build.close();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
var BindingMagicString = import_binding.BindingMagicString;
|
|
38
|
+
export { BindingMagicString, VERSION, build, defineConfig, rolldown, watch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./shared/binding-DmMMxMk0.mjs";
|
|
2
|
+
import "./shared/normalize-string-or-regex-DbTZ9prS.mjs";
|
|
3
|
+
import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-D0BAGfk2.mjs";
|
|
4
|
+
import "./shared/parse-ast-index-BuuhACPk.mjs";
|
|
5
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
6
|
+
|
|
7
|
+
//#region src/parallel-plugin-worker.ts
|
|
8
|
+
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
9
|
+
const { registryId, pluginInfos, threadNumber } = workerData;
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
(0, import_binding.registerPlugins)(registryId, await Promise.all(pluginInfos.map(async (pluginInfo) => {
|
|
13
|
+
const definePluginImpl = (await import(pluginInfo.fileUrl)).default;
|
|
14
|
+
const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
|
|
15
|
+
return {
|
|
16
|
+
index: pluginInfo.index,
|
|
17
|
+
plugin: bindingifyPlugin(plugin, {}, {}, new PluginContextData(() => {}, {}, []), [], () => {}, "info", false)
|
|
18
|
+
};
|
|
19
|
+
})));
|
|
20
|
+
parentPort.postMessage({ type: "success" });
|
|
21
|
+
} catch (error) {
|
|
22
|
+
parentPort.postMessage({
|
|
23
|
+
type: "error",
|
|
24
|
+
error
|
|
25
|
+
});
|
|
26
|
+
} finally {
|
|
27
|
+
parentPort.unref();
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./shared/binding-kAegJ1Bj.mjs";
|
|
2
|
+
import { C as Plugin, Ot as MaybePromise } from "./shared/define-config-DJ1-iIdx.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/plugin/parallel-plugin-implementation.d.ts
|
|
5
|
+
type ParallelPluginImplementation = Plugin;
|
|
6
|
+
type Context = {
|
|
7
|
+
/**
|
|
8
|
+
* Thread number
|
|
9
|
+
*/
|
|
10
|
+
threadNumber: number;
|
|
11
|
+
};
|
|
12
|
+
declare function defineParallelPluginImplementation<Options>(plugin: (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>): (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { type Context, type ParallelPluginImplementation, defineParallelPluginImplementation };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { B as ParserOptions, z as ParseResult } from "./shared/binding-kAegJ1Bj.mjs";
|
|
2
|
+
import { Program } from "@oxc-project/types";
|
|
3
|
+
|
|
4
|
+
//#region src/parse-ast-index.d.ts
|
|
5
|
+
declare function parseAst(sourceText: string, options?: ParserOptions | null, filename?: string): Program;
|
|
6
|
+
declare function parseAstAsync(sourceText: string, options?: ParserOptions | null, filename?: string): Promise<Program>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type ParseResult, type ParserOptions, parseAst, parseAstAsync };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { u as BindingReplacePluginConfig } from "./shared/binding-kAegJ1Bj.mjs";
|
|
2
|
+
import { M as BuiltinPlugin } from "./shared/define-config-DJ1-iIdx.mjs";
|
|
3
|
+
import { t as esmExternalRequirePlugin } from "./shared/constructors-F44lhsH3.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/builtin-plugin/replace-plugin.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Replaces targeted strings in files while bundling.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Basic usage
|
|
12
|
+
* ```js
|
|
13
|
+
* replacePlugin({
|
|
14
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
15
|
+
* __buildVersion: 15
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
* @example
|
|
19
|
+
* // With options
|
|
20
|
+
* ```js
|
|
21
|
+
* replacePlugin({
|
|
22
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
23
|
+
* __buildVersion: 15
|
|
24
|
+
* }, {
|
|
25
|
+
* preventAssignment: false,
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { esmExternalRequirePlugin, replacePlugin };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "./shared/binding-DmMMxMk0.mjs";
|
|
2
|
+
import { n as BuiltinPlugin, s as makeBuiltinPluginCallable } from "./shared/normalize-string-or-regex-DbTZ9prS.mjs";
|
|
3
|
+
import { t as esmExternalRequirePlugin } from "./shared/constructors-Rl_oLd2F.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/builtin-plugin/replace-plugin.ts
|
|
6
|
+
/**
|
|
7
|
+
* Replaces targeted strings in files while bundling.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Basic usage
|
|
11
|
+
* ```js
|
|
12
|
+
* replacePlugin({
|
|
13
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
14
|
+
* __buildVersion: 15
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
* @example
|
|
18
|
+
* // With options
|
|
19
|
+
* ```js
|
|
20
|
+
* replacePlugin({
|
|
21
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
22
|
+
* __buildVersion: 15
|
|
23
|
+
* }, {
|
|
24
|
+
* preventAssignment: false,
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function replacePlugin(values = {}, options = {}) {
|
|
29
|
+
Object.keys(values).forEach((key) => {
|
|
30
|
+
const value = values[key];
|
|
31
|
+
if (typeof value !== "string") values[key] = String(value);
|
|
32
|
+
});
|
|
33
|
+
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
|
|
34
|
+
...options,
|
|
35
|
+
values
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { esmExternalRequirePlugin, replacePlugin };
|