@rollipop/rolldown 0.0.0 → 1.0.0-rc.1

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.
Files changed (46) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +11 -1
  3. package/bin/cli.mjs +3 -0
  4. package/dist/cli-setup.d.mts +1 -0
  5. package/dist/cli-setup.mjs +17 -0
  6. package/dist/cli.d.mts +1 -0
  7. package/dist/cli.mjs +1588 -0
  8. package/dist/config.d.mts +10 -0
  9. package/dist/config.mjs +14 -0
  10. package/dist/experimental-index.d.mts +181 -0
  11. package/dist/experimental-index.mjs +266 -0
  12. package/dist/experimental-runtime-types.d.ts +103 -0
  13. package/dist/filter-index.d.mts +197 -0
  14. package/dist/filter-index.mjs +369 -0
  15. package/dist/get-log-filter.d.mts +7 -0
  16. package/dist/get-log-filter.mjs +48 -0
  17. package/dist/index.d.mts +4 -0
  18. package/dist/index.mjs +57 -0
  19. package/dist/parallel-plugin-worker.d.mts +1 -0
  20. package/dist/parallel-plugin-worker.mjs +32 -0
  21. package/dist/parallel-plugin.d.mts +14 -0
  22. package/dist/parallel-plugin.mjs +7 -0
  23. package/dist/parse-ast-index.d.mts +8 -0
  24. package/dist/parse-ast-index.mjs +4 -0
  25. package/dist/plugins-index.d.mts +30 -0
  26. package/dist/plugins-index.mjs +40 -0
  27. package/dist/shared/binding-B92Lq__Q.d.mts +1687 -0
  28. package/dist/shared/binding-tNJoEqAa.mjs +585 -0
  29. package/dist/shared/bindingify-input-options-CfhrNd_y.mjs +2233 -0
  30. package/dist/shared/constructors--k1uxZrh.d.mts +28 -0
  31. package/dist/shared/constructors-414MPkgB.mjs +61 -0
  32. package/dist/shared/define-config-BVG4QvnP.mjs +7 -0
  33. package/dist/shared/define-config-D8xP5iyL.d.mts +3463 -0
  34. package/dist/shared/load-config-Qtd9pHJ5.mjs +114 -0
  35. package/dist/shared/logging-wIy4zY9I.d.mts +50 -0
  36. package/dist/shared/logs-NH298mHo.mjs +183 -0
  37. package/dist/shared/misc-CCZIsXVO.mjs +22 -0
  38. package/dist/shared/normalize-string-or-regex-DeB7vQ75.mjs +61 -0
  39. package/dist/shared/parse-ast-index-BcP4Ts_P.mjs +99 -0
  40. package/dist/shared/prompt-tlfjalEt.mjs +847 -0
  41. package/dist/shared/rolldown-BMzJcmQ7.mjs +42 -0
  42. package/dist/shared/rolldown-build-DWeKtJOy.mjs +2371 -0
  43. package/dist/shared/watch-HmN4U4B9.mjs +379 -0
  44. package/package.json +128 -2
  45. package/.editorconfig +0 -10
  46. package/.gitattributes +0 -4
@@ -0,0 +1,197 @@
1
+ import "./shared/binding-B92Lq__Q.mjs";
2
+ import { j as withFilter } from "./shared/define-config-D8xP5iyL.mjs";
3
+
4
+ //#region ../pluginutils/dist/filter/composable-filters.d.ts
5
+ type StringOrRegExp = string | RegExp;
6
+ type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
7
+ type FilterExpressionKind = FilterExpression['kind'];
8
+ type FilterExpression = And | Or | Not | Id | ImporterId | ModuleType | Code | Query;
9
+ type TopLevelFilterExpression = Include | Exclude;
10
+ declare class And {
11
+ kind: 'and';
12
+ args: FilterExpression[];
13
+ constructor(...args: FilterExpression[]);
14
+ }
15
+ declare class Or {
16
+ kind: 'or';
17
+ args: FilterExpression[];
18
+ constructor(...args: FilterExpression[]);
19
+ }
20
+ declare class Not {
21
+ kind: 'not';
22
+ expr: FilterExpression;
23
+ constructor(expr: FilterExpression);
24
+ }
25
+ interface QueryFilterObject {
26
+ [key: string]: StringOrRegExp | boolean;
27
+ }
28
+ interface IdParams {
29
+ cleanUrl?: boolean;
30
+ }
31
+ declare class Id {
32
+ kind: 'id';
33
+ pattern: StringOrRegExp;
34
+ params: IdParams;
35
+ constructor(pattern: StringOrRegExp, params?: IdParams);
36
+ }
37
+ declare class ImporterId {
38
+ kind: 'importerId';
39
+ pattern: StringOrRegExp;
40
+ params: IdParams;
41
+ constructor(pattern: StringOrRegExp, params?: IdParams);
42
+ }
43
+ declare class ModuleType {
44
+ kind: 'moduleType';
45
+ pattern: PluginModuleType;
46
+ constructor(pattern: PluginModuleType);
47
+ }
48
+ declare class Code {
49
+ kind: 'code';
50
+ pattern: StringOrRegExp;
51
+ constructor(expr: StringOrRegExp);
52
+ }
53
+ declare class Query {
54
+ kind: 'query';
55
+ key: string;
56
+ pattern: StringOrRegExp | boolean;
57
+ constructor(key: string, pattern: StringOrRegExp | boolean);
58
+ }
59
+ declare class Include {
60
+ kind: 'include';
61
+ expr: FilterExpression;
62
+ constructor(expr: FilterExpression);
63
+ }
64
+ declare class Exclude {
65
+ kind: 'exclude';
66
+ expr: FilterExpression;
67
+ constructor(expr: FilterExpression);
68
+ }
69
+ declare function and(...args: FilterExpression[]): And;
70
+ declare function or(...args: FilterExpression[]): Or;
71
+ declare function not(expr: FilterExpression): Not;
72
+ declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
73
+ declare function importerId(pattern: StringOrRegExp, params?: IdParams): ImporterId;
74
+ declare function moduleType(pattern: PluginModuleType): ModuleType;
75
+ declare function code(pattern: StringOrRegExp): Code;
76
+ declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
77
+ declare function include(expr: FilterExpression): Include;
78
+ declare function exclude(expr: FilterExpression): Exclude;
79
+ /**
80
+ * convert a queryObject to FilterExpression like
81
+ * ```js
82
+ * and(query(k1, v1), query(k2, v2))
83
+ * ```
84
+ * @param queryFilterObject The query filter object needs to be matched.
85
+ * @returns a `And` FilterExpression
86
+ */
87
+ declare function queries(queryFilter: QueryFilterObject): And;
88
+ declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string): boolean;
89
+ interface InterpreterCtx {
90
+ urlSearchParamsCache?: URLSearchParams;
91
+ }
92
+ declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
93
+ declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
94
+ //#endregion
95
+ //#region ../pluginutils/dist/filter/filter-vite-plugins.d.ts
96
+ /**
97
+ * Filters out Vite plugins that have `apply: 'serve'` set.
98
+ *
99
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
100
+ * are intended only for Vite's dev server and should be excluded from the build process.
101
+ *
102
+ * @param plugins - Array of plugins (can include nested arrays)
103
+ * @returns Filtered array with serve-only plugins removed
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { defineConfig } from '@rollipop/rolldown';
108
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
109
+ * import viteReact from '@vitejs/plugin-react';
110
+ *
111
+ * export default defineConfig({
112
+ * plugins: filterVitePlugins([
113
+ * viteReact(),
114
+ * {
115
+ * name: 'dev-only',
116
+ * apply: 'serve', // This will be filtered out
117
+ * // ...
118
+ * }
119
+ * ])
120
+ * });
121
+ * ```
122
+ */
123
+ declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
124
+ //#endregion
125
+ //#region ../pluginutils/dist/filter/simple-filters.d.ts
126
+ /**
127
+ * Constructs a RegExp that matches the exact string specified.
128
+ *
129
+ * This is useful for plugin hook filters.
130
+ *
131
+ * @param str the string to match.
132
+ * @param flags flags for the RegExp.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * import { exactRegex } from '@rolldown/pluginutils';
137
+ * const plugin = {
138
+ * name: 'plugin',
139
+ * resolveId: {
140
+ * filter: { id: exactRegex('foo') },
141
+ * handler(id) {} // will only be called for `foo`
142
+ * }
143
+ * }
144
+ * ```
145
+ */
146
+ declare function exactRegex(str: string, flags?: string): RegExp;
147
+ /**
148
+ * Constructs a RegExp that matches a value that has the specified prefix.
149
+ *
150
+ * This is useful for plugin hook filters.
151
+ *
152
+ * @param str the string to match.
153
+ * @param flags flags for the RegExp.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { prefixRegex } from '@rolldown/pluginutils';
158
+ * const plugin = {
159
+ * name: 'plugin',
160
+ * resolveId: {
161
+ * filter: { id: prefixRegex('foo') },
162
+ * handler(id) {} // will only be called for IDs starting with `foo`
163
+ * }
164
+ * }
165
+ * ```
166
+ */
167
+ declare function prefixRegex(str: string, flags?: string): RegExp;
168
+ type WidenString<T> = T extends string ? string : T;
169
+ /**
170
+ * Converts a id filter to match with an id with a query.
171
+ *
172
+ * @param input the id filters to convert.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
177
+ * const plugin = {
178
+ * name: 'plugin',
179
+ * transform: {
180
+ * filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
181
+ * // The handler will be called for IDs like:
182
+ * // - foo.js
183
+ * // - foo.js?foo
184
+ * // - foo.txt?foo.js
185
+ * // - foo.ts
186
+ * // - foo.ts?foo
187
+ * // - foo.txt?foo.ts
188
+ * handler(code, id) {}
189
+ * }
190
+ * }
191
+ * ```
192
+ */
193
+ declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
194
+ declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
195
+ declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
196
+ //#endregion
197
+ export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
@@ -0,0 +1,369 @@
1
+ import { n as isPromiseLike, t as arraify } from "./shared/misc-CCZIsXVO.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 RolldownLog } from "./shared/logging-wIy4zY9I.mjs";
2
+
3
+ //#region src/get-log-filter.d.ts
4
+ type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
5
+ declare const getLogFilter: GetLogFilter;
6
+ //#endregion
7
+ export { GetLogFilter, type RolldownLog, type RolldownLog as 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 };
@@ -0,0 +1,4 @@
1
+ import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-wIy4zY9I.mjs";
2
+ import { P as PreRenderedChunk, s as BindingMagicString } from "./shared/binding-B92Lq__Q.mjs";
3
+ import { $ as BufferEncoding, A as TransformResult, At as MinifyOptions, B as EmittedChunk, Bt as RenderedModule, C as Plugin, Ct as ChunkingContext, D as RolldownPlugin, Dt as GeneratedCodeOptions, E as ResolvedId, Et as CodeSplittingOptions, F as SourceMapInput, Ft as PartialNull, G as PluginContextResolveOptions, Gt as SourcemapIgnoreListOption, H as EmittedPrebuiltChunk, Ht as SourceMap, I as OutputBundle, J as MinimalPluginContext, K as DefineParallelPluginResult, L as TreeshakingOptions, Lt as OutputAsset, Mt as OutputOptions, N as VERSION, Nt as PreRenderedAsset, O as RolldownPluginOption, Ot as GeneratedCodePreset, P as ExistingRawSourceMap, Q as ModuleTypeFilter, R as TransformPluginContext, Rt as OutputChunk, S as PartialResolvedId, St as ChunkFileNamesFunction, T as ResolveIdResult, Tt as CodeSplittingNameFunction, U as GetModuleInfo, V as EmittedFile, Vt as RolldownOutput, W as PluginContext, Wt as ModuleInfo, X as GeneralHookFilter, Y as PluginContextMeta, Z as HookFilter, _ as LoadResult, _t as BuildOptions, a as ExternalOption, at as NormalizedInputOptions, b as ObjectHook, bt as AdvancedChunksGroup, c as InputOptions, ct as LoggingFunction, d as WatcherOptions, dt as RolldownWatcher, et as RolldownDirectoryEntry, f as AsyncPluginHooks, ft as RolldownWatcherEvent, g as ImportKind, gt as RolldownBuild, h as HookFilterExtension, ht as rolldown, i as RolldownOptions, it as NormalizedOutputOptions, jt as ModuleFormat, k as SourceDescription, kt as GlobalsFunction, l as ModuleTypes, lt as WarningHandlerWithDefault, m as FunctionPluginHooks, mt as WatchOptions, n as RolldownOptionsFunction, nt as RolldownFsModule, o as ExternalOptionFunction, ot as TransformOptions, p as CustomPluginOptions, pt as RolldownWatcherWatcherEventMap, r as defineConfig, rt as InternalModuleFormat, s as InputOption, st as ChecksOptions, t as ConfigExport, tt as RolldownFileStats, u as OptimizationOptions, ut as watch, v as ModuleOptions, vt as build, w as ResolveIdExtraOptions, wt as CodeSplittingGroup, x as ParallelPluginHooks, xt as AdvancedChunksOptions, y as ModuleType, yt as AddonFunction, z as EmittedAsset, zt as RenderedChunk } from "./shared/define-config-D8xP5iyL.mjs";
4
+ export { AddonFunction, AdvancedChunksGroup, AdvancedChunksOptions, AsyncPluginHooks, BindingMagicString, BufferEncoding, BuildOptions, ChecksOptions, ChunkFileNamesFunction, ChunkingContext, CodeSplittingGroup, CodeSplittingNameFunction, CodeSplittingOptions, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedChunk, 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, PluginContextResolveOptions, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownError, RolldownError as RollupError, RolldownFileStats, RolldownFsModule, RolldownLog, RolldownLog as RollupLog, RolldownLogWithString, RolldownLogWithString as RollupLogWithString, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RolldownWatcherWatcherEventMap, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformOptions, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
package/dist/index.mjs ADDED
@@ -0,0 +1,57 @@
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-tNJoEqAa.mjs";
2
+ import { n as onExit, t as watch } from "./shared/watch-HmN4U4B9.mjs";
3
+ import "./shared/normalize-string-or-regex-DeB7vQ75.mjs";
4
+ import { S as VERSION } from "./shared/bindingify-input-options-CfhrNd_y.mjs";
5
+ import "./shared/rolldown-build-DWeKtJOy.mjs";
6
+ import "./shared/parse-ast-index-BcP4Ts_P.mjs";
7
+ import { t as rolldown } from "./shared/rolldown-BMzJcmQ7.mjs";
8
+ import { t as defineConfig } from "./shared/define-config-BVG4QvnP.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
+ /**
23
+ * The API similar to esbuild's `build` function.
24
+ *
25
+ * @example
26
+ * ```js
27
+ * import { build } from 'rolldown';
28
+ *
29
+ * const result = await build({
30
+ * input: 'src/main.js',
31
+ * output: {
32
+ * file: 'bundle.js',
33
+ * },
34
+ * });
35
+ * console.log(result);
36
+ * ```
37
+ *
38
+ * @experimental
39
+ * @category Programmatic APIs
40
+ */
41
+ async function build(options) {
42
+ if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
43
+ else {
44
+ const { output, write = true, ...inputOptions } = options;
45
+ const build = await rolldown(inputOptions);
46
+ try {
47
+ if (write) return await build.write(output);
48
+ else return await build.generate(output);
49
+ } finally {
50
+ await build.close();
51
+ }
52
+ }
53
+ }
54
+
55
+ //#endregion
56
+ var BindingMagicString = import_binding.BindingMagicString;
57
+ export { BindingMagicString, VERSION, build, defineConfig, rolldown, watch };
@@ -0,0 +1 @@
1
+ export { };