rolldown 0.13.2 → 0.14.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.
Files changed (54) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/cli.cjs +388 -95
  3. package/dist/cjs/experimental-index.cjs +2 -3
  4. package/dist/cjs/index.cjs +2 -13
  5. package/dist/cjs/parallel-plugin-worker.cjs +2 -2
  6. package/dist/esm/cli.mjs +387 -94
  7. package/dist/esm/experimental-index.mjs +1 -2
  8. package/dist/esm/index.mjs +2 -14
  9. package/dist/esm/parallel-plugin-worker.mjs +1 -1
  10. package/dist/shared/{consola.36c0034f-eps_ogJv.cjs → consola.36c0034f-HcmWcfPe.cjs} +2 -2
  11. package/dist/shared/{consola.36c0034f-m5cABVv4.mjs → consola.36c0034f-Xyw7SC_7.mjs} +1 -1
  12. package/dist/shared/{prompt-Ah5G71p-.cjs → prompt-9Ij3R3TG.cjs} +2 -2
  13. package/dist/shared/{prompt-9VjtYvi_.mjs → prompt-hoPhcrA-.mjs} +1 -1
  14. package/dist/shared/rolldown-binding.wasi.cjs +82 -73
  15. package/dist/shared/src_index-3pqhEViJ.cjs +2785 -0
  16. package/dist/shared/src_index-ywYMd4vB.mjs +2786 -0
  17. package/dist/shared/watcher-worker.js +1 -0
  18. package/dist/types/binding.d.ts +154 -66
  19. package/dist/types/cli/arguments/alias.d.ts +1 -0
  20. package/dist/types/cli/arguments/index.d.ts +1 -1
  21. package/dist/types/cli/arguments/normalize.d.ts +1 -0
  22. package/dist/types/cli/arguments/schema.d.ts +120 -35
  23. package/dist/types/constants/plugin.d.ts +1 -1
  24. package/dist/types/constants/types.d.ts +1 -0
  25. package/dist/types/experimental-index.d.ts +1 -0
  26. package/dist/types/index.d.ts +6 -5
  27. package/dist/types/log/logger.d.ts +9 -2
  28. package/dist/types/options/input-options.d.ts +241 -13
  29. package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -2
  30. package/dist/types/options/normalized-output-options.d.ts +1 -1
  31. package/dist/types/options/output-options.d.ts +52 -54
  32. package/dist/types/options/watch-option.d.ts +5 -0
  33. package/dist/types/plugin/bindingify-hook-filter.d.ts +2 -0
  34. package/dist/types/plugin/bindingify-output-hooks.d.ts +1 -0
  35. package/dist/types/plugin/bindingify-watch-hooks.d.ts +7 -0
  36. package/dist/types/plugin/hook-filter.d.ts +48 -0
  37. package/dist/types/plugin/index.d.ts +9 -15
  38. package/dist/types/plugin/plugin-context-data.d.ts +1 -1
  39. package/dist/types/plugin/plugin-context.d.ts +2 -6
  40. package/dist/types/plugin/plugin-driver.d.ts +1 -0
  41. package/dist/types/rolldown-build.d.ts +1 -1
  42. package/dist/types/rolldown.d.ts +3 -0
  43. package/dist/types/types/utils.d.ts +1 -0
  44. package/dist/types/utils/create-bundler.d.ts +3 -2
  45. package/dist/types/utils/transform-to-rollup-output.d.ts +8 -3
  46. package/dist/types/watcher.d.ts +31 -0
  47. package/package.json +19 -17
  48. package/dist/shared/package-8qJYyGdm.cjs +0 -11
  49. package/dist/shared/package-unZcnfG9.mjs +0 -9
  50. package/dist/shared/plugin-context-data-F1I9ytXp.cjs +0 -1435
  51. package/dist/shared/plugin-context-data-iKSAvmTX.mjs +0 -1442
  52. package/dist/shared/rolldown-ESzFTeqV.cjs +0 -1087
  53. package/dist/shared/rolldown-Hf7txSlh.mjs +0 -1071
  54. /package/dist/shared/{chunk-gQ4GMlVi.cjs → chunk-JoMxl5V2.cjs} +0 -0
@@ -1,10 +1,11 @@
1
1
  import type { PreRenderedChunk, RenderedChunk } from '../binding';
2
2
  import { z } from 'zod';
3
- declare const ModuleFormatSchema: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"cjs">]>, z.ZodLiteral<"esm">]>, z.ZodLiteral<"module">]>, z.ZodLiteral<"commonjs">]>, z.ZodLiteral<"iife">]>>;
3
+ declare const ModuleFormatSchema: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"cjs">]>, z.ZodLiteral<"esm">]>, z.ZodLiteral<"module">]>, z.ZodLiteral<"commonjs">]>, z.ZodLiteral<"iife">]>, z.ZodLiteral<"umd">]>>;
4
4
  declare const outputOptionsSchema: z.ZodObject<{
5
5
  dir: z.ZodOptional<z.ZodString>;
6
+ file: z.ZodOptional<z.ZodString>;
6
7
  exports: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"named">]>, z.ZodLiteral<"default">]>, z.ZodLiteral<"none">]>>;
7
- format: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"cjs">]>, z.ZodLiteral<"esm">]>, z.ZodLiteral<"module">]>, z.ZodLiteral<"commonjs">]>, z.ZodLiteral<"iife">]>>;
8
+ format: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"cjs">]>, z.ZodLiteral<"esm">]>, z.ZodLiteral<"module">]>, z.ZodLiteral<"commonjs">]>, z.ZodLiteral<"iife">]>, z.ZodLiteral<"umd">]>>;
8
9
  sourcemap: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"inline">]>, z.ZodLiteral<"hidden">]>>;
9
10
  sourcemapIgnoreList: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodType<SourcemapIgnoreListOption, z.ZodTypeDef, SourcemapIgnoreListOption>]>>;
10
11
  sourcemapPathTransform: z.ZodOptional<z.ZodType<SourcemapPathTransformOption, z.ZodTypeDef, SourcemapPathTransformOption>>;
@@ -27,7 +28,7 @@ declare const outputOptionsSchema: z.ZodObject<{
27
28
  minShareCount: z.ZodOptional<z.ZodNumber>;
28
29
  groups: z.ZodOptional<z.ZodArray<z.ZodObject<{
29
30
  name: z.ZodString;
30
- test: z.ZodOptional<z.ZodString>;
31
+ test: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>;
31
32
  priority: z.ZodOptional<z.ZodNumber>;
32
33
  minSize: z.ZodOptional<z.ZodNumber>;
33
34
  minShareCount: z.ZodOptional<z.ZodNumber>;
@@ -35,13 +36,13 @@ declare const outputOptionsSchema: z.ZodObject<{
35
36
  name: string;
36
37
  minSize?: number | undefined;
37
38
  minShareCount?: number | undefined;
38
- test?: string | undefined;
39
+ test?: string | RegExp | undefined;
39
40
  priority?: number | undefined;
40
41
  }, {
41
42
  name: string;
42
43
  minSize?: number | undefined;
43
44
  minShareCount?: number | undefined;
44
- test?: string | undefined;
45
+ test?: string | RegExp | undefined;
45
46
  priority?: number | undefined;
46
47
  }>, "many">>;
47
48
  }, "strict", z.ZodTypeAny, {
@@ -51,7 +52,7 @@ declare const outputOptionsSchema: z.ZodObject<{
51
52
  name: string;
52
53
  minSize?: number | undefined;
53
54
  minShareCount?: number | undefined;
54
- test?: string | undefined;
55
+ test?: string | RegExp | undefined;
55
56
  priority?: number | undefined;
56
57
  }[] | undefined;
57
58
  }, {
@@ -61,26 +62,27 @@ declare const outputOptionsSchema: z.ZodObject<{
61
62
  name: string;
62
63
  minSize?: number | undefined;
63
64
  minShareCount?: number | undefined;
64
- test?: string | undefined;
65
+ test?: string | RegExp | undefined;
65
66
  priority?: number | undefined;
66
67
  }[] | undefined;
67
68
  }>>;
68
69
  }, "strict", z.ZodTypeAny, {
69
- footer?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
70
- banner?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
71
- intro?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
72
- outro?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
70
+ footer?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
71
+ banner?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
72
+ intro?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
73
+ outro?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
74
+ file?: string | undefined;
73
75
  name?: string | undefined;
74
76
  exports?: "auto" | "named" | "default" | "none" | undefined;
75
77
  dir?: string | undefined;
76
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
78
+ format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd" | undefined;
77
79
  sourcemap?: boolean | "inline" | "hidden" | undefined;
78
80
  sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | undefined;
79
81
  sourcemapPathTransform?: SourcemapPathTransformOption | undefined;
80
82
  extend?: boolean | undefined;
81
83
  esModule?: boolean | "if-default-prop" | undefined;
82
- entryFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
83
- chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
84
+ entryFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
85
+ chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
84
86
  assetFileNames?: string | undefined;
85
87
  minify?: boolean | undefined;
86
88
  globals?: Record<string, string> | undefined;
@@ -93,26 +95,27 @@ declare const outputOptionsSchema: z.ZodObject<{
93
95
  name: string;
94
96
  minSize?: number | undefined;
95
97
  minShareCount?: number | undefined;
96
- test?: string | undefined;
98
+ test?: string | RegExp | undefined;
97
99
  priority?: number | undefined;
98
100
  }[] | undefined;
99
101
  } | undefined;
100
102
  }, {
101
- footer?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
102
- banner?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
103
- intro?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
104
- outro?: string | ((args_0: RenderedChunk, ...args_1: unknown[]) => string | Promise<string>) | undefined;
103
+ footer?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
104
+ banner?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
105
+ intro?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
106
+ outro?: string | ((args_0: RenderedChunk, ...args: unknown[]) => string | Promise<string>) | undefined;
107
+ file?: string | undefined;
105
108
  name?: string | undefined;
106
109
  exports?: "auto" | "named" | "default" | "none" | undefined;
107
110
  dir?: string | undefined;
108
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
111
+ format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd" | undefined;
109
112
  sourcemap?: boolean | "inline" | "hidden" | undefined;
110
113
  sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | undefined;
111
114
  sourcemapPathTransform?: SourcemapPathTransformOption | undefined;
112
115
  extend?: boolean | undefined;
113
116
  esModule?: boolean | "if-default-prop" | undefined;
114
- entryFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
115
- chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
117
+ entryFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
118
+ chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
116
119
  assetFileNames?: string | undefined;
117
120
  minify?: boolean | undefined;
118
121
  globals?: Record<string, string> | undefined;
@@ -125,15 +128,16 @@ declare const outputOptionsSchema: z.ZodObject<{
125
128
  name: string;
126
129
  minSize?: number | undefined;
127
130
  minShareCount?: number | undefined;
128
- test?: string | undefined;
131
+ test?: string | RegExp | undefined;
129
132
  priority?: number | undefined;
130
133
  }[] | undefined;
131
134
  } | undefined;
132
135
  }>;
133
136
  export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
134
137
  dir: z.ZodOptional<z.ZodString>;
138
+ file: z.ZodOptional<z.ZodString>;
135
139
  exports: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"named">]>, z.ZodLiteral<"default">]>, z.ZodLiteral<"none">]>>;
136
- format: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"cjs">]>, z.ZodLiteral<"esm">]>, z.ZodLiteral<"module">]>, z.ZodLiteral<"commonjs">]>, z.ZodLiteral<"iife">]>>;
140
+ format: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"cjs">]>, z.ZodLiteral<"esm">]>, z.ZodLiteral<"module">]>, z.ZodLiteral<"commonjs">]>, z.ZodLiteral<"iife">]>, z.ZodLiteral<"umd">]>>;
137
141
  sourcemap: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"inline">]>, z.ZodLiteral<"hidden">]>>;
138
142
  sourcemapIgnoreList: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodType<SourcemapIgnoreListOption, z.ZodTypeDef, SourcemapIgnoreListOption>]>>;
139
143
  sourcemapPathTransform: z.ZodOptional<z.ZodType<SourcemapPathTransformOption, z.ZodTypeDef, SourcemapPathTransformOption>>;
@@ -156,7 +160,7 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
156
160
  minShareCount: z.ZodOptional<z.ZodNumber>;
157
161
  groups: z.ZodOptional<z.ZodArray<z.ZodObject<{
158
162
  name: z.ZodString;
159
- test: z.ZodOptional<z.ZodString>;
163
+ test: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>;
160
164
  priority: z.ZodOptional<z.ZodNumber>;
161
165
  minSize: z.ZodOptional<z.ZodNumber>;
162
166
  minShareCount: z.ZodOptional<z.ZodNumber>;
@@ -164,13 +168,13 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
164
168
  name: string;
165
169
  minSize?: number | undefined;
166
170
  minShareCount?: number | undefined;
167
- test?: string | undefined;
171
+ test?: string | RegExp | undefined;
168
172
  priority?: number | undefined;
169
173
  }, {
170
174
  name: string;
171
175
  minSize?: number | undefined;
172
176
  minShareCount?: number | undefined;
173
- test?: string | undefined;
177
+ test?: string | RegExp | undefined;
174
178
  priority?: number | undefined;
175
179
  }>, "many">>;
176
180
  }, "strict", z.ZodTypeAny, {
@@ -180,7 +184,7 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
180
184
  name: string;
181
185
  minSize?: number | undefined;
182
186
  minShareCount?: number | undefined;
183
- test?: string | undefined;
187
+ test?: string | RegExp | undefined;
184
188
  priority?: number | undefined;
185
189
  }[] | undefined;
186
190
  }, {
@@ -190,7 +194,7 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
190
194
  name: string;
191
195
  minSize?: number | undefined;
192
196
  minShareCount?: number | undefined;
193
- test?: string | undefined;
197
+ test?: string | RegExp | undefined;
194
198
  priority?: number | undefined;
195
199
  }[] | undefined;
196
200
  }>>;
@@ -200,23 +204,31 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
200
204
  intro: z.ZodOptional<z.ZodString>;
201
205
  outro: z.ZodOptional<z.ZodString>;
202
206
  esModule: z.ZodOptional<z.ZodBoolean>;
203
- sourcemapIgnoreList: z.ZodOptional<z.ZodBoolean>;
204
- sourcemapPathTransform: z.ZodOptional<z.ZodUndefined>;
205
- }>, "sourcemapPathTransform">, "strict", z.ZodTypeAny, {
207
+ advancedChunks: z.ZodOptional<z.ZodObject<{
208
+ minSize: z.ZodOptional<z.ZodNumber>;
209
+ minShareCount: z.ZodOptional<z.ZodNumber>;
210
+ }, "strict", z.ZodTypeAny, {
211
+ minSize?: number | undefined;
212
+ minShareCount?: number | undefined;
213
+ }, {
214
+ minSize?: number | undefined;
215
+ minShareCount?: number | undefined;
216
+ }>>;
217
+ }>, "sourcemapIgnoreList" | "sourcemapPathTransform">, "strict", z.ZodTypeAny, {
206
218
  footer?: string | undefined;
207
219
  banner?: string | undefined;
208
220
  intro?: string | undefined;
209
221
  outro?: string | undefined;
222
+ file?: string | undefined;
210
223
  name?: string | undefined;
211
224
  exports?: "auto" | "named" | "default" | "none" | undefined;
212
225
  dir?: string | undefined;
213
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
226
+ format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd" | undefined;
214
227
  sourcemap?: boolean | "inline" | "hidden" | undefined;
215
- sourcemapIgnoreList?: boolean | undefined;
216
228
  extend?: boolean | undefined;
217
229
  esModule?: boolean | undefined;
218
- entryFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
219
- chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
230
+ entryFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
231
+ chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
220
232
  assetFileNames?: string | undefined;
221
233
  minify?: boolean | undefined;
222
234
  globals?: Record<string, string> | undefined;
@@ -225,29 +237,22 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
225
237
  advancedChunks?: {
226
238
  minSize?: number | undefined;
227
239
  minShareCount?: number | undefined;
228
- groups?: {
229
- name: string;
230
- minSize?: number | undefined;
231
- minShareCount?: number | undefined;
232
- test?: string | undefined;
233
- priority?: number | undefined;
234
- }[] | undefined;
235
240
  } | undefined;
236
241
  }, {
237
242
  footer?: string | undefined;
238
243
  banner?: string | undefined;
239
244
  intro?: string | undefined;
240
245
  outro?: string | undefined;
246
+ file?: string | undefined;
241
247
  name?: string | undefined;
242
248
  exports?: "auto" | "named" | "default" | "none" | undefined;
243
249
  dir?: string | undefined;
244
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
250
+ format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd" | undefined;
245
251
  sourcemap?: boolean | "inline" | "hidden" | undefined;
246
- sourcemapIgnoreList?: boolean | undefined;
247
252
  extend?: boolean | undefined;
248
253
  esModule?: boolean | undefined;
249
- entryFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
250
- chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args_1: unknown[]) => string) | undefined;
254
+ entryFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
255
+ chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
251
256
  assetFileNames?: string | undefined;
252
257
  minify?: boolean | undefined;
253
258
  globals?: Record<string, string> | undefined;
@@ -256,13 +261,6 @@ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.exten
256
261
  advancedChunks?: {
257
262
  minSize?: number | undefined;
258
263
  minShareCount?: number | undefined;
259
- groups?: {
260
- name: string;
261
- minSize?: number | undefined;
262
- minShareCount?: number | undefined;
263
- test?: string | undefined;
264
- priority?: number | undefined;
265
- }[] | undefined;
266
264
  } | undefined;
267
265
  }>;
268
266
  export type OutputOptions = z.infer<typeof outputOptionsSchema>;
@@ -0,0 +1,5 @@
1
+ import { InputOptions } from './input-options';
2
+ import { OutputOptions } from './output-options';
3
+ export interface WatchOptions extends InputOptions {
4
+ output?: OutputOptions;
5
+ }
@@ -1,5 +1,7 @@
1
1
  import { BindingGeneralHookFilter, BindingTransformHookFilter } from '../binding.d';
2
2
  import { hookFilterExtension } from '.';
3
+ import type { StringFilter } from './hook-filter';
4
+ export declare function bindingifyStringFilter(matcher: StringFilter): BindingGeneralHookFilter;
3
5
  export declare function bindingifyResolveIdFilter(filterOption?: hookFilterExtension<'resolveId'>['filter']): BindingGeneralHookFilter | undefined;
4
6
  export declare function bindingifyLoadFilter(filterOption?: hookFilterExtension<'load'>['filter']): BindingGeneralHookFilter | undefined;
5
7
  export declare function bindingifyTransformFilter(filterOption?: hookFilterExtension<'transform'>['filter']): BindingTransformHookFilter | undefined;
@@ -10,6 +10,7 @@ export declare function bindingifyAugmentChunkHash(plugin: Plugin, options: Norm
10
10
  export declare function bindingifyRenderError(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['renderError']>;
11
11
  export declare function bindingifyGenerateBundle(plugin: Plugin, options: NormalizedInputOptions, outputOptions: NormalizedOutputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['generateBundle']>;
12
12
  export declare function bindingifyWriteBundle(plugin: Plugin, options: NormalizedInputOptions, outputOptions: NormalizedOutputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['writeBundle']>;
13
+ export declare function bindingifyCloseBundle(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['closeBundle']>;
13
14
  export declare function bindingifyBanner(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['banner']>;
14
15
  export declare function bindingifyFooter(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['footer']>;
15
16
  export declare function bindingifyIntro(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['intro']>;
@@ -0,0 +1,7 @@
1
+ import type { BindingPluginOptions } from '../binding';
2
+ import type { NormalizedInputOptions } from '../options/normalized-input-options';
3
+ import type { Plugin } from './index';
4
+ import { PluginContextData } from './plugin-context-data';
5
+ import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
6
+ export declare function bindingifyWatchChange(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['watchChange']>;
7
+ export declare function bindingifyCloseWatcher(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['closeWatcher']>;
@@ -0,0 +1,48 @@
1
+ import type { MaybeArray } from '../types/utils';
2
+ import type { StringOrRegExp } from '../constants/types';
3
+ import type { ModuleType } from '../index';
4
+ export type StringFilter = MaybeArray<StringOrRegExp> | {
5
+ include?: MaybeArray<StringOrRegExp>;
6
+ exclude?: MaybeArray<StringOrRegExp>;
7
+ };
8
+ interface FormalModuleTypeFilter {
9
+ include?: ModuleType[];
10
+ }
11
+ type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
12
+ export interface HookFilter {
13
+ /**
14
+ * This filter is used to do a pre-test to determine whether the hook should be called.
15
+ * @example
16
+ * // Filter out all `id`s that contain `node_modules` in the path.
17
+ * ```js
18
+ * { id: 'node_modules' }
19
+ * ```
20
+ * @example
21
+ * // Filter out all `id`s that contain `node_modules` or `src` in the path.
22
+ * ```js
23
+ * { id: ['node_modules', 'src'] }
24
+ * ```
25
+ * @example
26
+ * // Filter out all `id`s that start with `http`
27
+ * ```js
28
+ * { id: /^http/ }
29
+ * ```
30
+ * @example
31
+ * // Exclude all `id`s that contain `node_modules` in the path.
32
+ * ```js
33
+ * { id: { exclude: 'node_modules' } }
34
+ * ```
35
+ * @example
36
+ * // Formal pattern
37
+ * ```
38
+ * { id : {
39
+ * include: ["foo", /bar/],
40
+ * exclude: ["baz", /qux/]
41
+ * }}
42
+ * ```
43
+ */
44
+ id?: StringFilter;
45
+ moduleType?: ModuleTypeFilter;
46
+ code?: StringFilter;
47
+ }
48
+ export {};
@@ -16,6 +16,7 @@ import { ParallelPlugin } from './parallel-plugin';
16
16
  import type { DefinedHookNames } from '../constants/plugin';
17
17
  import { DEFINED_HOOK_NAMES } from '../constants/plugin';
18
18
  import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
19
+ import { HookFilter } from './hook-filter';
19
20
  export type ModuleSideEffects = boolean | 'no-treeshake' | null;
20
21
  export type ModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
21
22
  export type ImportKind = BindingHookResolveIdExtraArgs['kind'];
@@ -76,7 +77,13 @@ export interface FunctionPluginHooks {
76
77
  [DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
77
78
  [DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
78
79
  [DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
80
+ [DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
81
+ [DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
82
+ event: ChangeEvent;
83
+ }) => void;
84
+ [DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
79
85
  }
86
+ export type ChangeEvent = 'create' | 'update' | 'delete';
80
87
  export type PluginOrder = 'pre' | 'post' | null;
81
88
  export type ObjectHookMeta<O = {}> = {
82
89
  order?: PluginOrder;
@@ -92,23 +99,10 @@ export type AddonHooks = DefinedHookNames['banner' | 'footer' | 'intro' | 'outro
92
99
  export type OutputPluginHooks = DefinedHookNames['augmentChunkHash' | 'generateBundle' | 'outputOptions' | 'renderChunk' | 'renderError' | 'renderStart' | 'writeBundle'];
93
100
  export type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
94
101
  export type hookFilterExtension<K extends keyof FunctionPluginHooks> = K extends 'transform' ? {
95
- filter?: BaseHookFilter;
102
+ filter?: HookFilter;
96
103
  } : K extends 'load' | 'resolveId' ? {
97
- filter?: Omit<BaseHookFilter, 'code' | 'moduleType'>;
104
+ filter?: Pick<HookFilter, 'id'>;
98
105
  } : {};
99
- export type BaseHookFilter = {
100
- id?: {
101
- include?: (string | RegExp)[];
102
- exclude?: (string | RegExp)[];
103
- };
104
- moduleType?: ModuleType[] | {
105
- include?: ModuleType[];
106
- };
107
- code?: {
108
- include?: (string | RegExp)[];
109
- exclude?: (string | RegExp)[];
110
- };
111
- };
112
106
  export type PluginHooks = {
113
107
  [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], hookFilterExtension<K>>;
114
108
  };
@@ -9,7 +9,7 @@ export declare class PluginContextData {
9
9
  updateModuleOption(id: string, option: ModuleOptions): void;
10
10
  getModuleOption(id: string): ModuleOptions | undefined;
11
11
  getModuleInfo(id: string, context: BindingPluginContext): ModuleInfo | null;
12
- getModuleIds(context: BindingPluginContext): IterableIterator<string>;
12
+ getModuleIds(context: BindingPluginContext): ArrayIterator<string>;
13
13
  saveResolveOptions(options: PluginContextResolveOptions): number;
14
14
  getSavedResolveOptions(receipt: number): PluginContextResolveOptions | undefined;
15
15
  removeSavedResolveOptions(receipt: number): void;
@@ -1,7 +1,7 @@
1
- import type { RollupError, LoggingFunction } from '../rollup';
2
1
  import type { BindingPluginContext } from '../binding';
3
2
  import type { NormalizedInputOptions } from '../options/normalized-input-options';
4
3
  import type { CustomPluginOptions, Plugin, ResolvedId } from './index';
4
+ import { MinimalPluginContext } from '../log/logger';
5
5
  import { AssetSource } from '../utils/asset-source';
6
6
  import { ModuleInfo } from '../types/module-info';
7
7
  import { PluginContextData } from './plugin-context-data';
@@ -21,11 +21,7 @@ export interface PluginContextResolveOptions {
21
21
  export interface PrivatePluginContextResolveOptions extends PluginContextResolveOptions {
22
22
  [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]?: symbol;
23
23
  }
24
- export declare class PluginContext {
25
- debug: LoggingFunction;
26
- info: LoggingFunction;
27
- warn: LoggingFunction;
28
- readonly error: (error: RollupError | string) => never;
24
+ export declare class PluginContext extends MinimalPluginContext {
29
25
  readonly resolve: (source: string, importer?: string, options?: PluginContextResolveOptions) => Promise<ResolvedId | null>;
30
26
  readonly emitFile: (file: EmittedAsset) => string;
31
27
  readonly getFileName: (referenceId: string) => string;
@@ -6,3 +6,4 @@ export declare class PluginDriver {
6
6
  callOutputOptionsHook(inputOptions: NormalizedInputOptions, outputOptions: OutputOptions): OutputOptions;
7
7
  }
8
8
  export declare function getObjectPlugins(plugins: RolldownPluginRec[]): Plugin[];
9
+ export declare function getSortedPlugins(hookName: 'options' | 'outputOptions' | 'onLog', plugins: readonly Plugin[]): Plugin[];
@@ -6,5 +6,5 @@ export declare class RolldownBuild {
6
6
  constructor(inputOptions: InputOptions);
7
7
  generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
8
8
  write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
9
- destroy(): Promise<void>;
9
+ close(): Promise<void>;
10
10
  }
@@ -1,6 +1,9 @@
1
1
  import type { InputOptions } from './options/input-options';
2
2
  import { RolldownBuild } from './rolldown-build';
3
+ import { Watcher } from './watcher';
4
+ import { WatchOptions } from './options/watch-option';
3
5
  export declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
6
+ export declare const watch: (input: WatchOptions) => Promise<Watcher>;
4
7
  /**
5
8
  * @description
6
9
  * This is an experimental API. It's behavior may change in the future.
@@ -9,3 +9,4 @@ export type PartialNull<T> = {
9
9
  [P in keyof T]: T[P] | null;
10
10
  };
11
11
  export type MakeAsync<Function_> = Function_ extends (this: infer This, ...parameters: infer Arguments) => infer Return ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
12
+ export type MaybeArray<T> = T | T[];
@@ -1,7 +1,8 @@
1
1
  import { Bundler } from '../binding';
2
2
  import type { InputOptions } from '../options/input-options';
3
3
  import type { OutputOptions } from '../options/output-options';
4
- export declare function createBundler(inputOptions: InputOptions, outputOptions: OutputOptions): Promise<{
4
+ export declare function createBundler(inputOptions: InputOptions, outputOptions: OutputOptions): Promise<BundlerWithStopWorker>;
5
+ export interface BundlerWithStopWorker {
5
6
  bundler: Bundler;
6
7
  stopWorkers?: () => Promise<void>;
7
- }>;
8
+ }
@@ -1,5 +1,10 @@
1
1
  import type { RolldownOutput } from '../types/rolldown-output';
2
2
  import type { OutputBundle } from '../types/output-bundle';
3
- import type { BindingOutputs, FinalBindingOutputs } from '../binding';
4
- export declare function transformToRollupOutput(output: BindingOutputs | FinalBindingOutputs): RolldownOutput;
5
- export declare function transformToOutputBundle(output: BindingOutputs): OutputBundle;
3
+ import type { BindingOutputs, JsChangedOutputs } from '../binding';
4
+ export declare function transformToRollupOutput(output: BindingOutputs, changed?: ChangedOutputs): RolldownOutput;
5
+ export declare function transformToOutputBundle(output: BindingOutputs, changed: ChangedOutputs): OutputBundle;
6
+ export interface ChangedOutputs {
7
+ updated: Set<string>;
8
+ deleted: Set<string>;
9
+ }
10
+ export declare function collectChangedBundle(changed: ChangedOutputs, bundle: OutputBundle): JsChangedOutputs;
@@ -0,0 +1,31 @@
1
+ import { BindingWatcher } from './binding';
2
+ import { MaybePromise } from './types/utils';
3
+ export declare class Watcher {
4
+ closed: boolean;
5
+ controller: AbortController;
6
+ inner: BindingWatcher;
7
+ stopWorkers?: () => Promise<void>;
8
+ constructor(inner: BindingWatcher, stopWorkers?: () => Promise<void>);
9
+ close(): Promise<void>;
10
+ on(event: 'change', listener: (id: string, change: {
11
+ event: ChangeEvent;
12
+ }) => MaybePromise<void>): this;
13
+ on(event: 'event', listener: (data: RollupWatcherEvent) => MaybePromise<void>): this;
14
+ on(event: 'restart' | 'close', listener: () => MaybePromise<void>): this;
15
+ watch(): void;
16
+ }
17
+ export type WatcherEvent = 'close' | 'event' | 'restart' | 'change';
18
+ export type ChangeEvent = 'create' | 'update' | 'delete';
19
+ export type RollupWatcherEvent = {
20
+ code: 'START';
21
+ } | {
22
+ code: 'BUNDLE_START';
23
+ } | {
24
+ code: 'BUNDLE_END';
25
+ duration: number;
26
+ output: readonly string[];
27
+ } | {
28
+ code: 'END';
29
+ } | {
30
+ code: 'ERROR'; /** error: RollupError; result: RollupBuild | null **/
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
5
5
  "homepage": "https://rolldown.rs/",
6
6
  "repository": {
@@ -44,6 +44,7 @@
44
44
  "require": "./dist/cjs/parallel-plugin.cjs",
45
45
  "import": "./dist/esm/parallel-plugin.mjs"
46
46
  },
47
+ "./watcher-worker": "./dist/shared/watcher-worker.js",
47
48
  "./package.json": "./package.json"
48
49
  },
49
50
  "imports": {
@@ -76,7 +77,7 @@
76
77
  "fs": true
77
78
  }
78
79
  },
79
- "dtsHeader": "type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\n"
80
+ "dtsHeader": "type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\nexport type BindingStringOrRegex = string | RegExp\n\n"
80
81
  },
81
82
  "dependencies": {
82
83
  "zod": "^3.23.8"
@@ -93,9 +94,10 @@
93
94
  "fs-extra": "^11.2.0",
94
95
  "glob": "^11.0.0",
95
96
  "locate-character": "^3.0.0",
96
- "npm-run-all2": "^6.2.0",
97
+ "npm-run-all2": "^7.0.0",
97
98
  "remeda": "^2.10.0",
98
99
  "rollup": "^4.18.0",
100
+ "signal-exit": "4.1.0",
99
101
  "type-fest": "^4.20.0",
100
102
  "unbuild": "^2.0.0",
101
103
  "vite": "^5.2.13",
@@ -103,21 +105,21 @@
103
105
  "why-is-node-running": "^3.0.0",
104
106
  "zod-to-json-schema": "^3.23.2",
105
107
  "@rolldown/testing": "0.0.1",
106
- "rolldown": "0.13.2"
108
+ "rolldown": "0.14.0"
107
109
  },
108
110
  "optionalDependencies": {
109
- "@rolldown/binding-darwin-arm64": "0.13.2",
110
- "@rolldown/binding-darwin-x64": "0.13.2",
111
- "@rolldown/binding-freebsd-x64": "0.13.2",
112
- "@rolldown/binding-linux-arm64-gnu": "0.13.2",
113
- "@rolldown/binding-linux-arm-gnueabihf": "0.13.2",
114
- "@rolldown/binding-linux-arm64-musl": "0.13.2",
115
- "@rolldown/binding-linux-x64-gnu": "0.13.2",
116
- "@rolldown/binding-linux-x64-musl": "0.13.2",
117
- "@rolldown/binding-wasm32-wasi": "0.13.2",
118
- "@rolldown/binding-win32-arm64-msvc": "0.13.2",
119
- "@rolldown/binding-win32-ia32-msvc": "0.13.2",
120
- "@rolldown/binding-win32-x64-msvc": "0.13.2"
111
+ "@rolldown/binding-darwin-arm64": "0.14.0",
112
+ "@rolldown/binding-darwin-x64": "0.14.0",
113
+ "@rolldown/binding-linux-arm-gnueabihf": "0.14.0",
114
+ "@rolldown/binding-linux-arm64-musl": "0.14.0",
115
+ "@rolldown/binding-freebsd-x64": "0.14.0",
116
+ "@rolldown/binding-linux-arm64-gnu": "0.14.0",
117
+ "@rolldown/binding-linux-x64-musl": "0.14.0",
118
+ "@rolldown/binding-linux-x64-gnu": "0.14.0",
119
+ "@rolldown/binding-win32-arm64-msvc": "0.14.0",
120
+ "@rolldown/binding-win32-ia32-msvc": "0.14.0",
121
+ "@rolldown/binding-win32-x64-msvc": "0.14.0",
122
+ "@rolldown/binding-wasm32-wasi": "0.14.0"
121
123
  },
122
124
  "scripts": {
123
125
  "# Scrips for binding #": "_",
@@ -136,7 +138,7 @@
136
138
  "build-wasi:debug": "run-s build-binding:wasi build-node",
137
139
  "build-wasi:release": "run-s build-binding:wasi:release build-node",
138
140
  "# Scrips for checking #": "_",
139
- "test": "cross-env ROLLDOWN_TEST=1 vitest run --reporter verbose --hideSkippedTests",
141
+ "test": "cross-env RUST_BACKTRACE=1 ROLLDOWN_TEST=1 vitest run --reporter verbose --hideSkippedTests",
140
142
  "test:update": "vitest run -u",
141
143
  "type-check": "tsc"
142
144
  }
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
-
4
- //#region package.json
5
- const version = "0.13.2";
6
- const description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
7
-
8
- //#endregion
9
- exports.description = description;
10
- exports.version = version;
11
-
@@ -1,9 +0,0 @@
1
- import __node_module__ from 'node:module';
2
- const require = __node_module__.createRequire(import.meta.url)
3
-
4
- //#region package.json
5
- const version = "0.13.2";
6
- const description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
7
-
8
- //#endregion
9
- export { description, version };