rolldown 0.13.2 → 0.14.0-snapshot-18ee4d3-20241107003320

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 (63) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/cli.cjs +390 -96
  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 +389 -95
  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-5gly_SB-.cjs +2772 -0
  16. package/dist/shared/src_index-p85M6ERL.mjs +2773 -0
  17. package/dist/shared/watcher-worker.js +1 -0
  18. package/dist/types/binding.d.ts +155 -67
  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 +3 -6
  22. package/dist/types/cli/arguments/schema.d.ts +136 -51
  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 +7 -6
  27. package/dist/types/log/logger.d.ts +10 -3
  28. package/dist/types/log/logging.d.ts +6 -3
  29. package/dist/types/options/input-options.d.ts +227 -58
  30. package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -2
  31. package/dist/types/options/normalized-input-options.d.ts +1 -1
  32. package/dist/types/options/normalized-output-options.d.ts +3 -12
  33. package/dist/types/options/output-options.d.ts +34 -173
  34. package/dist/types/options/watch-option.d.ts +5 -0
  35. package/dist/types/plugin/bindingify-hook-filter.d.ts +2 -0
  36. package/dist/types/plugin/bindingify-output-hooks.d.ts +1 -0
  37. package/dist/types/plugin/bindingify-watch-hooks.d.ts +7 -0
  38. package/dist/types/plugin/hook-filter.d.ts +48 -0
  39. package/dist/types/plugin/index.d.ts +9 -15
  40. package/dist/types/plugin/plugin-context-data.d.ts +3 -5
  41. package/dist/types/plugin/plugin-context.d.ts +2 -6
  42. package/dist/types/plugin/plugin-driver.d.ts +1 -0
  43. package/dist/types/rolldown-build.d.ts +3 -3
  44. package/dist/types/rolldown.d.ts +4 -1
  45. package/dist/types/types/input-options.d.ts +92 -0
  46. package/dist/types/types/output-options.d.ts +53 -0
  47. package/dist/types/types/rolldown-options.d.ts +2 -2
  48. package/dist/types/types/utils.d.ts +2 -0
  49. package/dist/types/utils/create-bundler.d.ts +5 -4
  50. package/dist/types/utils/normalize-input-options.d.ts +1 -1
  51. package/dist/types/utils/normalize-output-options.d.ts +1 -1
  52. package/dist/types/utils/normalize-plugin-option.d.ts +1 -1
  53. package/dist/types/utils/normalize-tree-shake.d.ts +1 -1
  54. package/dist/types/utils/transform-to-rollup-output.d.ts +8 -3
  55. package/dist/types/watcher.d.ts +31 -0
  56. package/package.json +19 -17
  57. package/dist/shared/package-8qJYyGdm.cjs +0 -11
  58. package/dist/shared/package-unZcnfG9.mjs +0 -9
  59. package/dist/shared/plugin-context-data-F1I9ytXp.cjs +0 -1435
  60. package/dist/shared/plugin-context-data-iKSAvmTX.mjs +0 -1442
  61. package/dist/shared/rolldown-ESzFTeqV.cjs +0 -1087
  62. package/dist/shared/rolldown-Hf7txSlh.mjs +0 -1071
  63. /package/dist/shared/{chunk-gQ4GMlVi.cjs → chunk-JoMxl5V2.cjs} +0 -0
@@ -1,10 +1,11 @@
1
- import type { PreRenderedChunk, RenderedChunk } from '../binding';
2
1
  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">]>>;
4
- declare const outputOptionsSchema: z.ZodObject<{
2
+ import type { RenderedChunk, PreRenderedChunk } from '../binding';
3
+ import type { SourcemapIgnoreListOption, SourcemapPathTransformOption } from '../rollup';
4
+ export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
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,212 +62,72 @@ 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
- }, "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;
73
- name?: string | undefined;
74
- exports?: "auto" | "named" | "default" | "none" | undefined;
75
- dir?: string | undefined;
76
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
77
- sourcemap?: boolean | "inline" | "hidden" | undefined;
78
- sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | undefined;
79
- sourcemapPathTransform?: SourcemapPathTransformOption | undefined;
80
- extend?: boolean | undefined;
81
- 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
- assetFileNames?: string | undefined;
85
- minify?: boolean | undefined;
86
- globals?: Record<string, string> | undefined;
87
- externalLiveBindings?: boolean | undefined;
88
- inlineDynamicImports?: boolean | undefined;
89
- advancedChunks?: {
90
- minSize?: number | undefined;
91
- minShareCount?: number | undefined;
92
- groups?: {
93
- name: string;
94
- minSize?: number | undefined;
95
- minShareCount?: number | undefined;
96
- test?: string | undefined;
97
- priority?: number | undefined;
98
- }[] | undefined;
99
- } | undefined;
100
69
  }, {
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;
105
- name?: string | undefined;
106
- exports?: "auto" | "named" | "default" | "none" | undefined;
107
- dir?: string | undefined;
108
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
109
- sourcemap?: boolean | "inline" | "hidden" | undefined;
110
- sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | undefined;
111
- sourcemapPathTransform?: SourcemapPathTransformOption | undefined;
112
- extend?: boolean | undefined;
113
- 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;
116
- assetFileNames?: string | undefined;
117
- minify?: boolean | undefined;
118
- globals?: Record<string, string> | undefined;
119
- externalLiveBindings?: boolean | undefined;
120
- inlineDynamicImports?: boolean | undefined;
121
- advancedChunks?: {
122
- minSize?: number | undefined;
123
- minShareCount?: number | undefined;
124
- groups?: {
125
- name: string;
126
- minSize?: number | undefined;
127
- minShareCount?: number | undefined;
128
- test?: string | undefined;
129
- priority?: number | undefined;
130
- }[] | undefined;
131
- } | undefined;
132
- }>;
133
- export declare const outputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
134
- dir: z.ZodOptional<z.ZodString>;
135
- 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">]>>;
137
- sourcemap: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"inline">]>, z.ZodLiteral<"hidden">]>>;
138
- sourcemapIgnoreList: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodType<SourcemapIgnoreListOption, z.ZodTypeDef, SourcemapIgnoreListOption>]>>;
139
- sourcemapPathTransform: z.ZodOptional<z.ZodType<SourcemapPathTransformOption, z.ZodTypeDef, SourcemapPathTransformOption>>;
140
- banner: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<RenderedChunk, z.ZodTypeDef, RenderedChunk>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
141
- footer: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<RenderedChunk, z.ZodTypeDef, RenderedChunk>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
142
- intro: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<RenderedChunk, z.ZodTypeDef, RenderedChunk>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
143
- outro: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<RenderedChunk, z.ZodTypeDef, RenderedChunk>], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>]>>;
144
- extend: z.ZodOptional<z.ZodBoolean>;
145
- esModule: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"if-default-prop">, z.ZodBoolean]>>;
146
- entryFileNames: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<PreRenderedChunk, z.ZodTypeDef, PreRenderedChunk>], z.ZodUnknown>, z.ZodString>]>>;
147
- chunkFileNames: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<PreRenderedChunk, z.ZodTypeDef, PreRenderedChunk>], z.ZodUnknown>, z.ZodString>]>>;
148
- assetFileNames: z.ZodOptional<z.ZodString>;
149
- minify: z.ZodOptional<z.ZodBoolean>;
150
- name: z.ZodOptional<z.ZodString>;
151
- globals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
152
- externalLiveBindings: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
153
- inlineDynamicImports: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
70
+ banner: z.ZodOptional<z.ZodString>;
71
+ footer: z.ZodOptional<z.ZodString>;
72
+ intro: z.ZodOptional<z.ZodString>;
73
+ outro: z.ZodOptional<z.ZodString>;
74
+ esModule: z.ZodOptional<z.ZodBoolean>;
154
75
  advancedChunks: z.ZodOptional<z.ZodObject<{
155
76
  minSize: z.ZodOptional<z.ZodNumber>;
156
77
  minShareCount: z.ZodOptional<z.ZodNumber>;
157
- groups: z.ZodOptional<z.ZodArray<z.ZodObject<{
158
- name: z.ZodString;
159
- test: z.ZodOptional<z.ZodString>;
160
- priority: z.ZodOptional<z.ZodNumber>;
161
- minSize: z.ZodOptional<z.ZodNumber>;
162
- minShareCount: z.ZodOptional<z.ZodNumber>;
163
- }, "strict", z.ZodTypeAny, {
164
- name: string;
165
- minSize?: number | undefined;
166
- minShareCount?: number | undefined;
167
- test?: string | undefined;
168
- priority?: number | undefined;
169
- }, {
170
- name: string;
171
- minSize?: number | undefined;
172
- minShareCount?: number | undefined;
173
- test?: string | undefined;
174
- priority?: number | undefined;
175
- }>, "many">>;
176
78
  }, "strict", z.ZodTypeAny, {
177
79
  minSize?: number | undefined;
178
80
  minShareCount?: number | undefined;
179
- groups?: {
180
- name: string;
181
- minSize?: number | undefined;
182
- minShareCount?: number | undefined;
183
- test?: string | undefined;
184
- priority?: number | undefined;
185
- }[] | undefined;
186
81
  }, {
187
82
  minSize?: number | undefined;
188
83
  minShareCount?: number | undefined;
189
- groups?: {
190
- name: string;
191
- minSize?: number | undefined;
192
- minShareCount?: number | undefined;
193
- test?: string | undefined;
194
- priority?: number | undefined;
195
- }[] | undefined;
196
84
  }>>;
197
- }, {
198
- banner: z.ZodOptional<z.ZodString>;
199
- footer: z.ZodOptional<z.ZodString>;
200
- intro: z.ZodOptional<z.ZodString>;
201
- outro: z.ZodOptional<z.ZodString>;
202
- esModule: z.ZodOptional<z.ZodBoolean>;
203
- sourcemapIgnoreList: z.ZodOptional<z.ZodBoolean>;
204
- sourcemapPathTransform: z.ZodOptional<z.ZodUndefined>;
205
- }>, "sourcemapPathTransform">, "strict", z.ZodTypeAny, {
85
+ }>, "sourcemapIgnoreList" | "sourcemapPathTransform">, "strict", z.ZodTypeAny, {
206
86
  footer?: string | undefined;
207
87
  banner?: string | undefined;
208
88
  intro?: string | undefined;
209
89
  outro?: string | undefined;
90
+ file?: string | undefined;
210
91
  name?: string | undefined;
211
92
  exports?: "auto" | "named" | "default" | "none" | undefined;
93
+ esModule?: boolean | undefined;
94
+ advancedChunks?: {
95
+ minSize?: number | undefined;
96
+ minShareCount?: number | undefined;
97
+ } | undefined;
212
98
  dir?: string | undefined;
213
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
99
+ format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd" | undefined;
214
100
  sourcemap?: boolean | "inline" | "hidden" | undefined;
215
- sourcemapIgnoreList?: boolean | undefined;
216
101
  extend?: boolean | undefined;
217
- 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;
102
+ entryFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
103
+ chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
220
104
  assetFileNames?: string | undefined;
221
105
  minify?: boolean | undefined;
222
106
  globals?: Record<string, string> | undefined;
223
107
  externalLiveBindings?: boolean | undefined;
224
108
  inlineDynamicImports?: boolean | undefined;
225
- advancedChunks?: {
226
- minSize?: number | undefined;
227
- 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
- } | undefined;
236
109
  }, {
237
110
  footer?: string | undefined;
238
111
  banner?: string | undefined;
239
112
  intro?: string | undefined;
240
113
  outro?: string | undefined;
114
+ file?: string | undefined;
241
115
  name?: string | undefined;
242
116
  exports?: "auto" | "named" | "default" | "none" | undefined;
117
+ esModule?: boolean | undefined;
118
+ advancedChunks?: {
119
+ minSize?: number | undefined;
120
+ minShareCount?: number | undefined;
121
+ } | undefined;
243
122
  dir?: string | undefined;
244
- format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | undefined;
123
+ format?: "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd" | undefined;
245
124
  sourcemap?: boolean | "inline" | "hidden" | undefined;
246
- sourcemapIgnoreList?: boolean | undefined;
247
125
  extend?: boolean | undefined;
248
- 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;
126
+ entryFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
127
+ chunkFileNames?: string | ((args_0: PreRenderedChunk, ...args: unknown[]) => string) | undefined;
251
128
  assetFileNames?: string | undefined;
252
129
  minify?: boolean | undefined;
253
130
  globals?: Record<string, string> | undefined;
254
131
  externalLiveBindings?: boolean | undefined;
255
132
  inlineDynamicImports?: boolean | undefined;
256
- advancedChunks?: {
257
- minSize?: number | undefined;
258
- 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
- } | undefined;
267
133
  }>;
268
- export type OutputOptions = z.infer<typeof outputOptionsSchema>;
269
- export type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
270
- export type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
271
- export type ModuleFormat = z.infer<typeof ModuleFormatSchema>;
272
- export {};
@@ -0,0 +1,5 @@
1
+ import { InputOptions } from '../types/input-options';
2
+ import { OutputOptions } from '../types/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
  };
@@ -1,15 +1,13 @@
1
1
  import { BindingPluginContext } from '../binding';
2
- import { ModuleInfo, ModuleOptions } from '..';
2
+ import { ModuleOptions } from '..';
3
3
  import { PluginContextResolveOptions } from './plugin-context';
4
4
  export declare class PluginContextData {
5
- modules: Map<string, ModuleInfo>;
6
- moduleIds: Array<string> | null;
7
5
  moduleOptionMap: Map<string, ModuleOptions>;
8
6
  resolveOptionsMap: Map<number, PluginContextResolveOptions>;
9
7
  updateModuleOption(id: string, option: ModuleOptions): void;
10
8
  getModuleOption(id: string): ModuleOptions | undefined;
11
- getModuleInfo(id: string, context: BindingPluginContext): ModuleInfo | null;
12
- getModuleIds(context: BindingPluginContext): IterableIterator<string>;
9
+ getModuleInfo(id: string, context: BindingPluginContext): import("..").ModuleInfo | null;
10
+ getModuleIds(context: BindingPluginContext): ArrayIterator<string>;
13
11
  saveResolveOptions(options: PluginContextResolveOptions): number;
14
12
  getSavedResolveOptions(receipt: number): PluginContextResolveOptions | undefined;
15
13
  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[];
@@ -1,10 +1,10 @@
1
- import type { OutputOptions } from './options/output-options';
1
+ import type { InputOptions } from './types/input-options';
2
+ import type { OutputOptions } from './types/output-options';
2
3
  import type { RolldownOutput } from './types/rolldown-output';
3
- import type { InputOptions } from './options/input-options';
4
4
  export declare class RolldownBuild {
5
5
  #private;
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
- import type { InputOptions } from './options/input-options';
1
+ import type { InputOptions } from './types/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.
@@ -0,0 +1,92 @@
1
+ import { RolldownPluginRec } from '../plugin';
2
+ import { LogLevel, LogLevelOption, LogLevelWithError, RollupLog, RollupLogWithString } from '../log/logging';
3
+ import { TreeshakingOptions } from '../treeshake';
4
+ import { NullValue, StringOrRegExp } from './utils';
5
+ export type InputOption = string | string[] | Record<string, string>;
6
+ export type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
7
+ export type ModuleTypes = Record<string, 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | 'css'>;
8
+ export interface JsxOptions {
9
+ mode?: 'classic' | 'automatic';
10
+ factory?: string;
11
+ fragment?: string;
12
+ importSource?: string;
13
+ jsxImportSource?: string;
14
+ refresh?: boolean;
15
+ development?: boolean;
16
+ }
17
+ export interface WatchOptions {
18
+ skipWrite?: boolean;
19
+ notify?: {
20
+ pollInterval?: number;
21
+ compareContents?: boolean;
22
+ };
23
+ include?: StringOrRegExp | StringOrRegExp[];
24
+ exclude?: StringOrRegExp | StringOrRegExp[];
25
+ chokidar?: any;
26
+ }
27
+ export interface InputOptions {
28
+ input?: InputOption;
29
+ plugins?: RolldownPluginRec[];
30
+ external?: ExternalOption;
31
+ resolve?: {
32
+ alias?: Record<string, string>;
33
+ aliasFields?: string[][];
34
+ conditionNames?: string[];
35
+ extensionAlias?: Record<string, string[]>;
36
+ exportsFields?: string[][];
37
+ extensions?: string[];
38
+ mainFields?: string[];
39
+ mainFiles?: string[];
40
+ modules?: string[];
41
+ symlinks?: boolean;
42
+ tsconfigFilename?: string;
43
+ };
44
+ cwd?: string;
45
+ platform?: 'node' | 'browser' | 'neutral';
46
+ shimMissingExports?: boolean;
47
+ treeshake?: boolean | TreeshakingOptions;
48
+ logLevel?: LogLevelOption;
49
+ onLog?: (level: LogLevel, log: RollupLog, defaultHandler: (level: LogLevelWithError, log: RollupLogWithString) => void) => void;
50
+ onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
51
+ moduleTypes?: ModuleTypes;
52
+ experimental?: {
53
+ enableComposingJsPlugins?: boolean;
54
+ strictExecutionOrder?: boolean;
55
+ disableLiveBindings?: boolean;
56
+ };
57
+ define?: Record<string, string>;
58
+ /**
59
+ * Inject import statements on demand.
60
+ *
61
+ * ## Supported patterns
62
+ * ```js
63
+ * {
64
+ * // import { Promise } from 'es6-promise'
65
+ * Promise: ['es6-promise', 'Promise'],
66
+ *
67
+ * // import { Promise as P } from 'es6-promise'
68
+ * P: ['es6-promise', 'Promise'],
69
+ *
70
+ * // import $ from 'jquery'
71
+ * $: 'jquery',
72
+ *
73
+ * // import * as fs from 'node:fs'
74
+ * fs: ['node:fs', '*'],
75
+ *
76
+ * // Inject shims for property access pattern
77
+ * 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
78
+ * }
79
+ * ```
80
+ */
81
+ inject?: Record<string, string | [string, string]>;
82
+ profilerNames?: boolean;
83
+ jsx?: JsxOptions;
84
+ watch?: WatchOptions | false;
85
+ }
86
+ interface OverwriteInputOptionsForCli {
87
+ external?: string[];
88
+ inject?: Record<string, string>;
89
+ treeshake?: boolean;
90
+ }
91
+ export type InputCliOptions = Omit<InputOptions, keyof OverwriteInputOptionsForCli | 'input' | 'plugins' | 'onwarn' | 'onLog' | 'resolve' | 'experimental' | 'profilerNames' | 'watch'> & OverwriteInputOptionsForCli;
92
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { StringOrRegExp } from './utils';
2
+ import type { RenderedChunk, PreRenderedChunk } from '../binding';
3
+ import { SourcemapIgnoreListOption, SourcemapPathTransformOption } from '../rollup';
4
+ export type ModuleFormat = 'es' | 'cjs' | 'esm' | 'module' | 'commonjs' | 'iife' | 'umd';
5
+ export type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
6
+ export type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
7
+ export interface OutputOptions {
8
+ dir?: string;
9
+ file?: string;
10
+ exports?: 'auto' | 'named' | 'default' | 'none';
11
+ format?: ModuleFormat;
12
+ sourcemap?: boolean | 'inline' | 'hidden';
13
+ sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
14
+ sourcemapPathTransform?: SourcemapPathTransformOption;
15
+ banner?: string | AddonFunction;
16
+ footer?: string | AddonFunction;
17
+ intro?: string | AddonFunction;
18
+ outro?: string | AddonFunction;
19
+ extend?: boolean;
20
+ esModule?: boolean | 'if-default-prop';
21
+ entryFileNames?: string | ChunkFileNamesFunction;
22
+ chunkFileNames?: string | ChunkFileNamesFunction;
23
+ assetFileNames?: string;
24
+ minify?: boolean;
25
+ name?: string;
26
+ globals?: Record<string, string>;
27
+ externalLiveBindings?: boolean;
28
+ inlineDynamicImports?: boolean;
29
+ advancedChunks?: {
30
+ minSize?: number;
31
+ minShareCount?: number;
32
+ groups?: {
33
+ name: string;
34
+ test?: StringOrRegExp;
35
+ priority?: number;
36
+ minSize?: number;
37
+ minShareCount?: number;
38
+ }[];
39
+ };
40
+ }
41
+ interface OverwriteOutputOptionsForCli {
42
+ banner?: string;
43
+ footer?: string;
44
+ intro?: string;
45
+ outro?: string;
46
+ esModule?: boolean;
47
+ advancedChunks?: {
48
+ minSize?: number;
49
+ minShareCount?: number;
50
+ };
51
+ }
52
+ export type OutputCliOptions = Omit<OutputOptions, keyof OverwriteOutputOptionsForCli | 'sourcemapIgnoreList' | 'sourcemapPathTransform'> & OverwriteOutputOptionsForCli;
53
+ export {};
@@ -1,5 +1,5 @@
1
- import type { InputOptions } from '../options/input-options';
2
- import type { OutputOptions } from '../options/output-options';
1
+ import type { InputOptions } from '../types/input-options';
2
+ import type { OutputOptions } from '../types/output-options';
3
3
  export interface RolldownOptions extends InputOptions {
4
4
  output?: OutputOptions;
5
5
  }