rolldown 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.10

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 (73) hide show
  1. package/README.md +11 -0
  2. package/dist/cli.mjs +962 -1551
  3. package/dist/config.d.mts +9 -7
  4. package/dist/config.mjs +10 -11
  5. package/dist/experimental-index.d.mts +225 -68
  6. package/dist/experimental-index.mjs +277 -57
  7. package/dist/experimental-runtime-types.d.ts +98 -0
  8. package/dist/filter-index.d.mts +195 -4
  9. package/dist/filter-index.mjs +347 -6
  10. package/dist/get-log-filter.d.mts +3 -0
  11. package/dist/get-log-filter.mjs +68 -0
  12. package/dist/index.d.mts +4 -4
  13. package/dist/index.mjs +54 -6
  14. package/dist/parallel-plugin-worker.mjs +28 -35
  15. package/dist/parallel-plugin.d.mts +6 -8
  16. package/dist/parallel-plugin.mjs +1 -2
  17. package/dist/parse-ast-index.d.mts +27 -4
  18. package/dist/parse-ast-index.mjs +61 -4
  19. package/dist/plugins-index.d.mts +33 -0
  20. package/dist/plugins-index.mjs +41 -0
  21. package/dist/shared/binding-BV_UWDF3.mjs +582 -0
  22. package/dist/shared/binding-Dsq9Azhm.d.mts +1851 -0
  23. package/dist/shared/bindingify-input-options-DoaqRULI.mjs +2170 -0
  24. package/dist/shared/constructors-DfpIbfMG.d.mts +37 -0
  25. package/dist/shared/constructors-DqC7XSXy.mjs +68 -0
  26. package/dist/shared/define-config-CV9D_Qea.d.mts +3781 -0
  27. package/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
  28. package/dist/shared/error-BO4SlZV_.mjs +85 -0
  29. package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
  30. package/dist/shared/{load-config-Dll-92l5.mjs → load-config-ezHg7sBf.mjs} +32 -36
  31. package/dist/shared/logging-C6h4g8dA.d.mts +50 -0
  32. package/dist/shared/logs-D80CXhvg.mjs +180 -0
  33. package/dist/shared/{misc-DGAe2XOW.mjs → misc-DJYbNKZX.mjs} +1 -8
  34. package/dist/shared/normalize-string-or-regex-D7wlw16t.mjs +58 -0
  35. package/dist/shared/parse-nWsWXhOL.mjs +74 -0
  36. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-BYQIwEjg.mjs} +301 -310
  37. package/dist/shared/resolve-tsconfig-C3OzszY-.mjs +113 -0
  38. package/dist/shared/rolldown-BOb3gBhW.mjs +40 -0
  39. package/dist/shared/rolldown-build-yQC7KN8K.mjs +3319 -0
  40. package/dist/shared/transform-B5D1aA1B.d.mts +149 -0
  41. package/dist/shared/watch-CzsahzPN.mjs +374 -0
  42. package/dist/utils-index.d.mts +376 -0
  43. package/dist/utils-index.mjs +2416 -0
  44. package/package.json +93 -99
  45. package/dist/cli.cjs +0 -1748
  46. package/dist/cli.d.cts +0 -1
  47. package/dist/config.cjs +0 -12
  48. package/dist/config.d.cts +0 -12
  49. package/dist/experimental-index.cjs +0 -132
  50. package/dist/experimental-index.d.cts +0 -96
  51. package/dist/filter-index.cjs +0 -105
  52. package/dist/filter-index.d.cts +0 -5
  53. package/dist/index.cjs +0 -9
  54. package/dist/index.d.cts +0 -4
  55. package/dist/parallel-plugin-worker.cjs +0 -33
  56. package/dist/parallel-plugin-worker.d.cts +0 -1
  57. package/dist/parallel-plugin.cjs +0 -8
  58. package/dist/parallel-plugin.d.cts +0 -15
  59. package/dist/parse-ast-index.cjs +0 -4
  60. package/dist/parse-ast-index.d.cts +0 -9
  61. package/dist/shared/binding.d-Dz3qQrbl.d.mts +0 -1682
  62. package/dist/shared/binding.d-QXzDcVmm.d.cts +0 -1682
  63. package/dist/shared/chunk--iN_1bjD.mjs +0 -33
  64. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  65. package/dist/shared/define-config.d-CUcDq_vm.d.cts +0 -1080
  66. package/dist/shared/define-config.d-qV1PzX_C.d.mts +0 -1080
  67. package/dist/shared/load-config-Bx9W9x2a.cjs +0 -125
  68. package/dist/shared/misc-BKp5iIef.cjs +0 -67
  69. package/dist/shared/parse-ast-index-0m6JgGc9.mjs +0 -655
  70. package/dist/shared/parse-ast-index-Cn_efzjO.cjs +0 -697
  71. package/dist/shared/prompt-uGrwvyp0.mjs +0 -854
  72. package/dist/shared/src-B4EklR3U.mjs +0 -4704
  73. package/dist/shared/src-BzFe16tX.cjs +0 -4654
@@ -1,8 +1,327 @@
1
- import { arraify, init_misc, isPromiseLike } from "./shared/misc-DGAe2XOW.mjs";
2
- import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
3
-
1
+ import { n as isPromiseLike, t as arraify } from "./shared/misc-DJYbNKZX.mjs";
2
+ //#region ../pluginutils/dist/utils.js
3
+ const postfixRE = /[?#].*$/;
4
+ function cleanUrl(url) {
5
+ return url.replace(postfixRE, "");
6
+ }
7
+ function extractQueryWithoutFragment(url) {
8
+ const questionMarkIndex = url.indexOf("?");
9
+ if (questionMarkIndex === -1) return "";
10
+ const fragmentIndex = url.indexOf("#", questionMarkIndex);
11
+ if (fragmentIndex === -1) return url.substring(questionMarkIndex);
12
+ else return url.substring(questionMarkIndex, fragmentIndex);
13
+ }
14
+ //#endregion
15
+ //#region ../pluginutils/dist/filter/composable-filters.js
16
+ var And = class {
17
+ kind;
18
+ args;
19
+ constructor(...args) {
20
+ if (args.length === 0) throw new Error("`And` expects at least one operand");
21
+ this.args = args;
22
+ this.kind = "and";
23
+ }
24
+ };
25
+ var Or = class {
26
+ kind;
27
+ args;
28
+ constructor(...args) {
29
+ if (args.length === 0) throw new Error("`Or` expects at least one operand");
30
+ this.args = args;
31
+ this.kind = "or";
32
+ }
33
+ };
34
+ var Not = class {
35
+ kind;
36
+ expr;
37
+ constructor(expr) {
38
+ this.expr = expr;
39
+ this.kind = "not";
40
+ }
41
+ };
42
+ var Id = class {
43
+ kind;
44
+ pattern;
45
+ params;
46
+ constructor(pattern, params) {
47
+ this.pattern = pattern;
48
+ this.kind = "id";
49
+ this.params = params ?? { cleanUrl: false };
50
+ }
51
+ };
52
+ var ImporterId = class {
53
+ kind;
54
+ pattern;
55
+ params;
56
+ constructor(pattern, params) {
57
+ this.pattern = pattern;
58
+ this.kind = "importerId";
59
+ this.params = params ?? { cleanUrl: false };
60
+ }
61
+ };
62
+ var ModuleType = class {
63
+ kind;
64
+ pattern;
65
+ constructor(pattern) {
66
+ this.pattern = pattern;
67
+ this.kind = "moduleType";
68
+ }
69
+ };
70
+ var Code = class {
71
+ kind;
72
+ pattern;
73
+ constructor(expr) {
74
+ this.pattern = expr;
75
+ this.kind = "code";
76
+ }
77
+ };
78
+ var Query = class {
79
+ kind;
80
+ key;
81
+ pattern;
82
+ constructor(key, pattern) {
83
+ this.pattern = pattern;
84
+ this.key = key;
85
+ this.kind = "query";
86
+ }
87
+ };
88
+ var Include = class {
89
+ kind;
90
+ expr;
91
+ constructor(expr) {
92
+ this.expr = expr;
93
+ this.kind = "include";
94
+ }
95
+ };
96
+ var Exclude = class {
97
+ kind;
98
+ expr;
99
+ constructor(expr) {
100
+ this.expr = expr;
101
+ this.kind = "exclude";
102
+ }
103
+ };
104
+ function and(...args) {
105
+ return new And(...args);
106
+ }
107
+ function or(...args) {
108
+ return new Or(...args);
109
+ }
110
+ function not(expr) {
111
+ return new Not(expr);
112
+ }
113
+ function id(pattern, params) {
114
+ return new Id(pattern, params);
115
+ }
116
+ function importerId(pattern, params) {
117
+ return new ImporterId(pattern, params);
118
+ }
119
+ function moduleType(pattern) {
120
+ return new ModuleType(pattern);
121
+ }
122
+ function code(pattern) {
123
+ return new Code(pattern);
124
+ }
125
+ function query(key, pattern) {
126
+ return new Query(key, pattern);
127
+ }
128
+ function include(expr) {
129
+ return new Include(expr);
130
+ }
131
+ function exclude(expr) {
132
+ return new Exclude(expr);
133
+ }
134
+ /**
135
+ * convert a queryObject to FilterExpression like
136
+ * ```js
137
+ * and(query(k1, v1), query(k2, v2))
138
+ * ```
139
+ * @param queryFilterObject The query filter object needs to be matched.
140
+ * @returns a `And` FilterExpression
141
+ */
142
+ function queries(queryFilter) {
143
+ return and(...Object.entries(queryFilter).map(([key, value]) => {
144
+ return new Query(key, value);
145
+ }));
146
+ }
147
+ function interpreter(exprs, code, id, moduleType, importerId) {
148
+ let arr = [];
149
+ if (Array.isArray(exprs)) arr = exprs;
150
+ else arr = [exprs];
151
+ return interpreterImpl(arr, code, id, moduleType, importerId);
152
+ }
153
+ function interpreterImpl(expr, code, id, moduleType, importerId, ctx = {}) {
154
+ let hasInclude = false;
155
+ for (const e of expr) switch (e.kind) {
156
+ case "include":
157
+ hasInclude = true;
158
+ if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) return true;
159
+ break;
160
+ case "exclude":
161
+ if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) return false;
162
+ break;
163
+ }
164
+ return !hasInclude;
165
+ }
166
+ function exprInterpreter(expr, code, id, moduleType, importerId, ctx = {}) {
167
+ switch (expr.kind) {
168
+ case "and": return expr.args.every((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
169
+ case "or": return expr.args.some((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
170
+ case "not": return !exprInterpreter(expr.expr, code, id, moduleType, importerId, ctx);
171
+ case "id": {
172
+ if (id === void 0) throw new Error("`id` is required for `id` expression");
173
+ let idToMatch = id;
174
+ if (expr.params.cleanUrl) idToMatch = cleanUrl(idToMatch);
175
+ return typeof expr.pattern === "string" ? idToMatch === expr.pattern : expr.pattern.test(idToMatch);
176
+ }
177
+ case "importerId": {
178
+ if (importerId === void 0) return false;
179
+ let importerIdToMatch = importerId;
180
+ if (expr.params.cleanUrl) importerIdToMatch = cleanUrl(importerIdToMatch);
181
+ return typeof expr.pattern === "string" ? importerIdToMatch === expr.pattern : expr.pattern.test(importerIdToMatch);
182
+ }
183
+ case "moduleType":
184
+ if (moduleType === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
185
+ return moduleType === expr.pattern;
186
+ case "code":
187
+ if (code === void 0) throw new Error("`code` is required for `code` expression");
188
+ return typeof expr.pattern === "string" ? code.includes(expr.pattern) : expr.pattern.test(code);
189
+ case "query": {
190
+ if (id === void 0) throw new Error("`id` is required for `Query` expression");
191
+ if (!ctx.urlSearchParamsCache) {
192
+ let queryString = extractQueryWithoutFragment(id);
193
+ ctx.urlSearchParamsCache = new URLSearchParams(queryString);
194
+ }
195
+ let urlParams = ctx.urlSearchParamsCache;
196
+ if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
197
+ else return !urlParams.has(expr.key);
198
+ else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
199
+ else return expr.pattern.test(urlParams.get(expr.key) ?? "");
200
+ }
201
+ default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
202
+ }
203
+ }
204
+ //#endregion
205
+ //#region ../pluginutils/dist/filter/filter-vite-plugins.js
206
+ /**
207
+ * Filters out Vite plugins that have `apply: 'serve'` set.
208
+ *
209
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
210
+ * are intended only for Vite's dev server and should be excluded from the build process.
211
+ *
212
+ * @param plugins - Array of plugins (can include nested arrays)
213
+ * @returns Filtered array with serve-only plugins removed
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * import { defineConfig } from 'rolldown';
218
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
219
+ * import viteReact from '@vitejs/plugin-react';
220
+ *
221
+ * export default defineConfig({
222
+ * plugins: filterVitePlugins([
223
+ * viteReact(),
224
+ * {
225
+ * name: 'dev-only',
226
+ * apply: 'serve', // This will be filtered out
227
+ * // ...
228
+ * }
229
+ * ])
230
+ * });
231
+ * ```
232
+ */
233
+ function filterVitePlugins(plugins) {
234
+ if (!plugins) return [];
235
+ const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
236
+ const result = [];
237
+ for (const plugin of pluginArray) {
238
+ if (!plugin) continue;
239
+ if (Array.isArray(plugin)) {
240
+ result.push(...filterVitePlugins(plugin));
241
+ continue;
242
+ }
243
+ const pluginWithApply = plugin;
244
+ if ("apply" in pluginWithApply) {
245
+ const applyValue = pluginWithApply.apply;
246
+ if (typeof applyValue === "function") try {
247
+ if (applyValue({}, {
248
+ command: "build",
249
+ mode: "production"
250
+ })) result.push(plugin);
251
+ } catch {
252
+ result.push(plugin);
253
+ }
254
+ else if (applyValue === "serve") continue;
255
+ else result.push(plugin);
256
+ } else result.push(plugin);
257
+ }
258
+ return result;
259
+ }
260
+ //#endregion
261
+ //#region ../pluginutils/dist/filter/simple-filters.js
262
+ /**
263
+ * Constructs a RegExp that matches the exact string specified.
264
+ *
265
+ * This is useful for plugin hook filters.
266
+ *
267
+ * @param str the string to match.
268
+ * @param flags flags for the RegExp.
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * import { exactRegex } from '@rolldown/pluginutils';
273
+ * const plugin = {
274
+ * name: 'plugin',
275
+ * resolveId: {
276
+ * filter: { id: exactRegex('foo') },
277
+ * handler(id) {} // will only be called for `foo`
278
+ * }
279
+ * }
280
+ * ```
281
+ */
282
+ function exactRegex(str, flags) {
283
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
284
+ }
285
+ /**
286
+ * Constructs a RegExp that matches a value that has the specified prefix.
287
+ *
288
+ * This is useful for plugin hook filters.
289
+ *
290
+ * @param str the string to match.
291
+ * @param flags flags for the RegExp.
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * import { prefixRegex } from '@rolldown/pluginutils';
296
+ * const plugin = {
297
+ * name: 'plugin',
298
+ * resolveId: {
299
+ * filter: { id: prefixRegex('foo') },
300
+ * handler(id) {} // will only be called for IDs starting with `foo`
301
+ * }
302
+ * }
303
+ * ```
304
+ */
305
+ function prefixRegex(str, flags) {
306
+ return new RegExp(`^${escapeRegex(str)}`, flags);
307
+ }
308
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
309
+ function escapeRegex(str) {
310
+ return str.replace(escapeRegexRE, "\\$&");
311
+ }
312
+ function makeIdFiltersToMatchWithQuery(input) {
313
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
314
+ return input.map((i) => makeIdFilterToMatchWithQuery(i));
315
+ }
316
+ function makeIdFilterToMatchWithQuery(input) {
317
+ if (typeof input === "string") return `${input}{?*,}`;
318
+ return makeRegexIdFilterToMatchWithQuery(input);
319
+ }
320
+ function makeRegexIdFilterToMatchWithQuery(input) {
321
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
322
+ }
323
+ //#endregion
4
324
  //#region src/plugin/with-filter.ts
5
- init_misc();
6
325
  function withFilterImpl(pluginOption, filterObjectList) {
7
326
  if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
8
327
  if (pluginOption == false || pluginOption == null) return pluginOption;
@@ -28,6 +347,29 @@ function withFilterImpl(pluginOption, filterObjectList) {
28
347
  });
29
348
  return plugin;
30
349
  }
350
+ /**
351
+ * A helper function to add plugin hook filters to a plugin or an array of plugins.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * import yaml from '@rollup/plugin-yaml';
356
+ * import { defineConfig } from 'rolldown';
357
+ * import { withFilter } from 'rolldown/filter';
358
+ *
359
+ * export default defineConfig({
360
+ * plugins: [
361
+ * // Run the transform hook of the `yaml` plugin
362
+ * // only for modules which end in `.yaml`
363
+ * withFilter(
364
+ * yaml({}),
365
+ * { transform: { id: /\.yaml$/ } },
366
+ * ),
367
+ * ],
368
+ * });
369
+ * ```
370
+ *
371
+ * @category Config
372
+ */
31
373
  function withFilter(pluginOption, filterObject) {
32
374
  return withFilterImpl(pluginOption, arraify(filterObject));
33
375
  }
@@ -40,6 +382,5 @@ function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
40
382
  }
41
383
  return -1;
42
384
  }
43
-
44
385
  //#endregion
45
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
386
+ export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
@@ -0,0 +1,3 @@
1
+ import { a as RolldownLog } from "./shared/logging-C6h4g8dA.mjs";
2
+ import { n as getLogFilter, t as GetLogFilter } from "./shared/get-log-filter-semyr3Lj.mjs";
3
+ export { GetLogFilter, RolldownLog, RolldownLog as RollupLog, getLogFilter as default };
@@ -0,0 +1,68 @@
1
+ //#region src/get-log-filter.ts
2
+ /**
3
+ * A helper function to generate log filters using the same syntax as the CLI.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { defineConfig } from 'rolldown';
8
+ * import { getLogFilter } from 'rolldown/getLogFilter';
9
+ *
10
+ * const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
11
+ *
12
+ * export default defineConfig({
13
+ * input: 'main.js',
14
+ * onLog(level, log, handler) {
15
+ * if (logFilter(log)) {
16
+ * handler(level, log);
17
+ * }
18
+ * }
19
+ * });
20
+ * ```
21
+ *
22
+ * @category Config
23
+ */
24
+ const getLogFilter = (filters) => {
25
+ if (filters.length === 0) return () => true;
26
+ const normalizedFilters = filters.map((filter) => filter.split("&").map((subFilter) => {
27
+ const inverted = subFilter.startsWith("!");
28
+ if (inverted) subFilter = subFilter.slice(1);
29
+ const [key, ...value] = subFilter.split(":");
30
+ return {
31
+ inverted,
32
+ key: key.split("."),
33
+ parts: value.join(":").split("*")
34
+ };
35
+ }));
36
+ return (log) => {
37
+ nextIntersectedFilter: for (const intersectedFilters of normalizedFilters) {
38
+ for (const { inverted, key, parts } of intersectedFilters) {
39
+ const isFilterSatisfied = testFilter(log, key, parts);
40
+ if (inverted ? isFilterSatisfied : !isFilterSatisfied) continue nextIntersectedFilter;
41
+ }
42
+ return true;
43
+ }
44
+ return false;
45
+ };
46
+ };
47
+ const testFilter = (log, key, parts) => {
48
+ let rawValue = log;
49
+ for (let index = 0; index < key.length; index++) {
50
+ if (!rawValue) return false;
51
+ const part = key[index];
52
+ if (!(part in rawValue)) return false;
53
+ rawValue = rawValue[part];
54
+ }
55
+ let value = typeof rawValue === "object" ? JSON.stringify(rawValue) : String(rawValue);
56
+ if (parts.length === 1) return value === parts[0];
57
+ if (!value.startsWith(parts[0])) return false;
58
+ const lastPartIndex = parts.length - 1;
59
+ for (let index = 1; index < lastPartIndex; index++) {
60
+ const part = parts[index];
61
+ const position = value.indexOf(part);
62
+ if (position === -1) return false;
63
+ value = value.slice(position + part.length);
64
+ }
65
+ return value.endsWith(parts[lastPartIndex]);
66
+ };
67
+ //#endregion
68
+ export { getLogFilter as default };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { PreRenderedChunk } from "./shared/binding.d-Dz3qQrbl.mjs";
2
- import { AddonFunction, AsyncPluginHooks, BuildOptions, ChunkFileNamesFunction, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION$1 as VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build$1 as build, defineConfig$1 as defineConfig, rolldown$1 as rolldown, watch$1 as watch } from "./shared/define-config.d-qV1PzX_C.mjs";
3
-
4
- export { AddonFunction, AsyncPluginHooks, BuildOptions, ChunkFileNamesFunction, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
1
+ import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-C6h4g8dA.mjs";
2
+ import { z as PreRenderedChunk } from "./shared/binding-Dsq9Azhm.mjs";
3
+ import { $ as GeneralHookFilter, A as SourceDescription, At as CodeSplittingOptions, B as TreeshakingOptions, Bt as PartialNull, C as PartialResolvedId, Ct as AddonFunction, D as ResolvedId, Dt as ChunkingContext, E as ResolveIdResult, Et as ChunkFileNamesFunction, F as VERSION, Ft as MinifyOptions, G as EmittedPrebuiltChunk, Gt as RenderedModule, H as EmittedAsset, Ht as OutputAsset, I as BundleError, It as ModuleFormat, J as PluginContextResolveOptions, K as GetModuleInfo, Kt as RolldownOutput, L as ExistingRawSourceMap, Lt as OutputOptions, Mt as GeneratedCodeOptions, Nt as GeneratedCodePreset, O as RolldownPlugin, Ot as CodeSplittingGroup, P as RUNTIME_MODULE_ID, Pt as GlobalsFunction, Q as PluginContextMeta, R as SourceMapInput, Rt as PreRenderedAsset, S as ParallelPluginHooks, St as build, T as ResolveIdExtraOptions, Tt as AdvancedChunksOptions, U as EmittedChunk, Ut as OutputChunk, V as TransformPluginContext, W as EmittedFile, Wt as RenderedChunk, Xt as SourcemapIgnoreListOption, Y as DefineParallelPluginResult, Yt as ModuleInfo, Z as MinimalPluginContext, _ as ImportKind, _t as RolldownWatcherWatcherEventMap, a as ExternalOption, at as RolldownFsModule, b as ModuleType, bt as RolldownBuild, c as InputOptions, ct as NormalizedInputOptions, d as WatcherFileWatcherOptions, dt as LoggingFunction, et as HookFilter, f as WatcherOptions, ft as WarningHandlerWithDefault, g as HookFilterExtension, gt as RolldownWatcherEvent, h as FunctionPluginHooks, ht as RolldownWatcher, i as RolldownOptions, it as RolldownFileStats, j as TransformResult, jt as CommentsOptions, k as RolldownPluginOption, kt as CodeSplittingNameFunction, l as ModuleTypes, lt as TransformOptions, m as CustomPluginOptions, mt as watch, n as RolldownOptionsFunction, nt as BufferEncoding, o as ExternalOptionFunction, ot as InternalModuleFormat, p as AsyncPluginHooks, pt as RolldownMagicString, q as PluginContext, qt as SourceMap, r as defineConfig, rt as RolldownDirectoryEntry, s as InputOption, st as NormalizedOutputOptions, t as ConfigExport, tt as ModuleTypeFilter, u as OptimizationOptions, ut as ChecksOptions, v as LoadResult, vt as WatchOptions, w as Plugin, wt as AdvancedChunksGroup, x as ObjectHook, xt as BuildOptions, y as ModuleOptions, yt as rolldown, z as OutputBundle } from "./shared/define-config-CV9D_Qea.mjs";
4
+ export { AddonFunction, AdvancedChunksGroup, AdvancedChunksOptions, AsyncPluginHooks, BufferEncoding, BuildOptions, BundleError, ChecksOptions, ChunkFileNamesFunction, ChunkingContext, CodeSplittingGroup, CodeSplittingNameFunction, CodeSplittingOptions, CommentsOptions, 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, RUNTIME_MODULE_ID, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownError, RolldownError as RollupError, RolldownFileStats, RolldownFsModule, RolldownLog, RolldownLog as RollupLog, RolldownLogWithString, RolldownLogWithString as RollupLogWithString, RolldownMagicString, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RolldownWatcherWatcherEventMap, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformOptions, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherFileWatcherOptions, WatcherOptions, build, defineConfig, rolldown, watch };
package/dist/index.mjs CHANGED
@@ -1,6 +1,54 @@
1
- import { VERSION, build, defineConfig, init_src, rolldown, watch } from "./shared/src-B4EklR3U.mjs";
2
- import "./shared/parse-ast-index-0m6JgGc9.mjs";
3
- import "./shared/misc-DGAe2XOW.mjs";
4
-
5
- init_src();
6
- export { VERSION, build, defineConfig, rolldown, watch };
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-BV_UWDF3.mjs";
2
+ import { n as onExit, t as watch } from "./shared/watch-CzsahzPN.mjs";
3
+ import "./shared/normalize-string-or-regex-D7wlw16t.mjs";
4
+ import { a as RolldownMagicString, b as RUNTIME_MODULE_ID, x as VERSION } from "./shared/bindingify-input-options-DoaqRULI.mjs";
5
+ import "./shared/rolldown-build-yQC7KN8K.mjs";
6
+ import "./shared/error-BO4SlZV_.mjs";
7
+ import "./shared/parse-nWsWXhOL.mjs";
8
+ import { t as rolldown } from "./shared/rolldown-BOb3gBhW.mjs";
9
+ import { t as defineConfig } from "./shared/define-config-DJOr6Iwt.mjs";
10
+ import { isMainThread } from "node:worker_threads";
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
+ //#endregion
20
+ //#region src/api/build.ts
21
+ /**
22
+ * The API similar to esbuild's `build` function.
23
+ *
24
+ * @example
25
+ * ```js
26
+ * import { build } from 'rolldown';
27
+ *
28
+ * const result = await build({
29
+ * input: 'src/main.js',
30
+ * output: {
31
+ * file: 'bundle.js',
32
+ * },
33
+ * });
34
+ * console.log(result);
35
+ * ```
36
+ *
37
+ * @experimental
38
+ * @category Programmatic APIs
39
+ */
40
+ async function build(options) {
41
+ if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
42
+ else {
43
+ const { output, write = true, ...inputOptions } = options;
44
+ const build = await rolldown(inputOptions);
45
+ try {
46
+ if (write) return await build.write(output);
47
+ else return await build.generate(output);
48
+ } finally {
49
+ await build.close();
50
+ }
51
+ }
52
+ }
53
+ //#endregion
54
+ export { RUNTIME_MODULE_ID, RolldownMagicString, VERSION, build, defineConfig, rolldown, watch };
@@ -1,38 +1,31 @@
1
- import { __commonJS, __toESM } from "./shared/chunk--iN_1bjD.mjs";
2
- import { PluginContextData, bindingifyPlugin, init_bindingify_plugin, init_plugin_context_data } from "./shared/src-B4EklR3U.mjs";
3
- import { require_binding } from "./shared/parse-ast-index-0m6JgGc9.mjs";
4
- import "./shared/misc-DGAe2XOW.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-BV_UWDF3.mjs";
2
+ import "./shared/normalize-string-or-regex-D7wlw16t.mjs";
3
+ import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-DoaqRULI.mjs";
4
+ import "./shared/error-BO4SlZV_.mjs";
5
+ import "./shared/parse-nWsWXhOL.mjs";
5
6
  import { parentPort, workerData } from "node:worker_threads";
6
-
7
7
  //#region src/parallel-plugin-worker.ts
8
- var require_parallel_plugin_worker = __commonJS({ "src/parallel-plugin-worker.ts"() {
9
- var import_binding = __toESM(require_binding());
10
- init_bindingify_plugin();
11
- init_plugin_context_data();
12
- const { registryId, pluginInfos, threadNumber } = workerData;
13
- (async () => {
14
- try {
15
- const plugins = await Promise.all(pluginInfos.map(async (pluginInfo) => {
16
- const pluginModule = await import(pluginInfo.fileUrl);
17
- const definePluginImpl = pluginModule.default;
18
- const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
19
- return {
20
- index: pluginInfo.index,
21
- plugin: bindingifyPlugin(plugin, {}, {}, new PluginContextData(), [], () => {}, "info", false)
22
- };
23
- }));
24
- (0, import_binding.registerPlugins)(registryId, plugins);
25
- parentPort.postMessage({ type: "success" });
26
- } catch (error) {
27
- parentPort.postMessage({
28
- type: "error",
29
- error
30
- });
31
- } finally {
32
- parentPort.unref();
33
- }
34
- })();
35
- } });
36
-
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
+ })();
37
30
  //#endregion
38
- export default require_parallel_plugin_worker();
31
+ export {};
@@ -1,15 +1,13 @@
1
- import "./shared/binding.d-Dz3qQrbl.mjs";
2
- import { MaybePromise, Plugin } from "./shared/define-config.d-qV1PzX_C.mjs";
1
+ import { w as Plugin, zt as MaybePromise } from "./shared/define-config-CV9D_Qea.mjs";
3
2
 
4
3
  //#region src/plugin/parallel-plugin-implementation.d.ts
5
4
  type ParallelPluginImplementation = Plugin;
6
5
  type Context = {
7
- /**
8
- * Thread number
9
- */
10
- threadNumber: number
6
+ /**
7
+ * Thread number
8
+ */
9
+ threadNumber: number;
11
10
  };
12
11
  declare function defineParallelPluginImplementation<Options>(plugin: (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>): (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>;
13
-
14
12
  //#endregion
15
- export { Context, ParallelPluginImplementation, defineParallelPluginImplementation };
13
+ export { type Context, type ParallelPluginImplementation, defineParallelPluginImplementation };
@@ -2,6 +2,5 @@
2
2
  function defineParallelPluginImplementation(plugin) {
3
3
  return plugin;
4
4
  }
5
-
6
5
  //#endregion
7
- export { defineParallelPluginImplementation };
6
+ export { defineParallelPluginImplementation };
@@ -1,9 +1,32 @@
1
- import { ParseResult, ParserOptions } from "./shared/binding.d-Dz3qQrbl.mjs";
1
+ import { L as ParseResult$1, R as ParserOptions$1 } from "./shared/binding-Dsq9Azhm.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
 
4
4
  //#region src/parse-ast-index.d.ts
5
- declare function parseAst(sourceText: string, options?: ParserOptions | undefined | null, filename?: string): Program;
6
- declare function parseAstAsync(sourceText: string, options?: ParserOptions | undefined | null, filename?: string): Promise<Program>;
7
-
5
+ /**
6
+ * @hidden
7
+ */
8
+ type ParseResult = ParseResult$1;
9
+ /**
10
+ * @hidden
11
+ */
12
+ type ParserOptions = ParserOptions$1;
13
+ /**
14
+ * Parse code synchronously and return the AST.
15
+ *
16
+ * This function is similar to Rollup's `parseAst` function.
17
+ * Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
18
+ *
19
+ * @category Utilities
20
+ */
21
+ declare function parseAst(sourceText: string, options?: ParserOptions | null, filename?: string): Program;
22
+ /**
23
+ * Parse code asynchronously and return the AST.
24
+ *
25
+ * This function is similar to Rollup's `parseAstAsync` function.
26
+ * Prefer using {@linkcode parseAsync} instead of this function as it has more information in the return value.
27
+ *
28
+ * @category Utilities
29
+ */
30
+ declare function parseAstAsync(sourceText: string, options?: ParserOptions | null, filename?: string): Promise<Program>;
8
31
  //#endregion
9
32
  export { ParseResult, ParserOptions, parseAst, parseAstAsync };