@rolldown/browser 1.0.0-beta.10-commit.229c919 → 1.0.0-beta.11

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 (37) hide show
  1. package/dist/cli.cjs +2 -2
  2. package/dist/cli.mjs +2 -2
  3. package/dist/config.cjs +2 -2
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +2 -2
  7. package/dist/experimental-index.browser.mjs +1 -1
  8. package/dist/experimental-index.cjs +1 -1
  9. package/dist/experimental-index.d.cts +2 -2
  10. package/dist/experimental-index.d.mts +2 -2
  11. package/dist/experimental-index.mjs +1 -1
  12. package/dist/filter-index.d.cts +2 -2
  13. package/dist/filter-index.d.mts +2 -2
  14. package/dist/index.browser.mjs +1 -1
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.mjs +1 -1
  19. package/dist/parallel-plugin-worker.cjs +1 -1
  20. package/dist/parallel-plugin-worker.mjs +1 -1
  21. package/dist/parallel-plugin.d.cts +2 -2
  22. package/dist/parallel-plugin.d.mts +2 -2
  23. package/dist/parse-ast-index.d.cts +1 -1
  24. package/dist/parse-ast-index.d.mts +1 -1
  25. package/dist/rolldown-binding.wasi-browser.js +20 -20
  26. package/dist/rolldown-binding.wasi.cjs +20 -20
  27. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  28. package/dist/shared/{binding-BYafUgFF.d.cts → binding-B_dRhqIG.d.cts} +1506 -1525
  29. package/dist/shared/{binding-CHPrEDXp.d.mts → binding-DTvNTuqj.d.mts} +1506 -1525
  30. package/dist/shared/{define-config-BIXBk1MV.d.mts → define-config-B0QE1WB_.d.cts} +1 -1
  31. package/dist/shared/{define-config-BetvTt9D.d.cts → define-config-D3wMRbHt.d.mts} +1 -1
  32. package/dist/shared/{load-config-AyxhfXuF.mjs → load-config-D5Qts1xk.mjs} +1 -1
  33. package/dist/shared/{load-config-qrciC9CF.cjs → load-config-gkfV4a73.cjs} +1 -1
  34. package/dist/shared/{src-6zdIkToV.mjs → src-DwpSoqgV.mjs} +1 -1
  35. package/dist/shared/{src-0Fe4vIDB.cjs → src-j8EWZeP5.cjs} +1 -1
  36. package/dist/{src-BMyIPdVN.js → src-B_dlJdRC.js} +1 -1
  37. package/package.json +1 -1
@@ -5,1648 +5,1629 @@ type MaybePromise<T> = T | Promise<T>;
5
5
  type Nullable<T> = T | null | undefined;
6
6
  type VoidNullable<T = void> = T | null | undefined | void;
7
7
  type BindingStringOrRegex = string | RegExp;
8
- declare class BindingBundleEndEventData {
9
- output: string;
10
- duration: number;
11
- get result(): Bundler;
8
+ interface Comment {
9
+ type: 'Line' | 'Block';
10
+ value: string;
11
+ start: number;
12
+ end: number;
12
13
  }
13
- declare class BindingBundleErrorEventData {
14
- get result(): Bundler;
15
- get error(): Array<Error | BindingError>;
14
+ interface ErrorLabel {
15
+ message?: string;
16
+ start: number;
17
+ end: number;
16
18
  }
17
- declare class BindingError {
18
- kind: string;
19
+ interface OxcError {
20
+ severity: Severity;
19
21
  message: string;
22
+ labels: Array<ErrorLabel>;
23
+ helpMessage?: string;
24
+ codeframe?: string;
20
25
  }
21
- declare class BindingModuleInfo {
22
- id: string;
23
- importers: Array<string>;
24
- dynamicImporters: Array<string>;
25
- importedIds: Array<string>;
26
- dynamicallyImportedIds: Array<string>;
27
- exports: Array<string>;
28
- isEntry: boolean;
29
- get code(): string | null;
30
- }
31
- declare class BindingNormalizedOptions {
32
- get input(): Array<string> | Record<string, string>;
33
- get cwd(): string | null;
34
- get platform(): 'node' | 'browser' | 'neutral';
35
- get shimMissingExports(): boolean;
36
- get name(): string | null;
37
- get cssEntryFilenames(): string | undefined;
38
- get cssChunkFilenames(): string | undefined;
39
- get entryFilenames(): string | undefined;
40
- get chunkFilenames(): string | undefined;
41
- get assetFilenames(): string | undefined;
42
- get dir(): string | null;
43
- get file(): string | null;
44
- get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd';
45
- get exports(): 'default' | 'named' | 'none' | 'auto';
46
- get esModule(): boolean | 'if-default-prop';
47
- get inlineDynamicImports(): boolean;
48
- get sourcemap(): boolean | 'inline' | 'hidden';
49
- get banner(): string | undefined | null | undefined;
50
- get footer(): string | undefined | null | undefined;
51
- get intro(): string | undefined | null | undefined;
52
- get outro(): string | undefined | null | undefined;
53
- get externalLiveBindings(): boolean;
54
- get extend(): boolean;
55
- get globals(): Record<string, string> | undefined;
56
- get hashCharacters(): 'base64' | 'base36' | 'hex';
57
- get sourcemapDebugIds(): boolean;
58
- get minify(): false | BindingMinifyOptions;
59
- get polyfillRequire(): boolean;
60
- get legalComments(): 'none' | 'inline';
61
- }
62
- declare class BindingOutputAsset {
63
- get fileName(): string;
64
- get originalFileName(): string | null;
65
- get originalFileNames(): Array<string>;
66
- get source(): BindingAssetSource;
67
- get name(): string | null;
68
- get names(): Array<string>;
69
- }
70
- declare class BindingOutputChunk {
71
- get isEntry(): boolean;
72
- get isDynamicEntry(): boolean;
73
- get facadeModuleId(): string | null;
74
- get moduleIds(): Array<string>;
75
- get exports(): Array<string>;
76
- get fileName(): string;
77
- get modules(): BindingModules;
78
- get imports(): Array<string>;
79
- get dynamicImports(): Array<string>;
80
- get code(): string;
81
- get map(): string | null;
82
- get sourcemapFileName(): string | null;
83
- get preliminaryFileName(): string;
84
- get name(): string;
85
- }
86
- declare class BindingOutputs {
87
- get chunks(): Array<BindingOutputChunk>;
88
- get assets(): Array<BindingOutputAsset>;
89
- get errors(): Array<Error | BindingError>;
90
- }
91
- declare class BindingPluginContext {
92
- load(specifier: string, sideEffects: BindingHookSideEffects | undefined): Promise<void>;
93
- resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>;
94
- emitFile(file: BindingEmittedAsset, assetFilename?: string | undefined | null, fnSanitizedFileName?: string | undefined | null): string;
95
- emitChunk(file: BindingEmittedChunk): string;
96
- getFileName(referenceId: string): string;
97
- getModuleInfo(moduleId: string): BindingModuleInfo | null;
98
- getModuleIds(): Array<string>;
99
- addWatchFile(file: string): void;
100
- }
101
- declare class BindingRenderedChunk {
102
- get name(): string;
103
- get isEntry(): boolean;
104
- get isDynamicEntry(): boolean;
105
- get facadeModuleId(): string | null;
106
- get moduleIds(): Array<string>;
107
- get exports(): Array<string>;
108
- get fileName(): string;
109
- get modules(): BindingModules;
110
- get imports(): Array<string>;
111
- get dynamicImports(): Array<string>;
112
- }
113
- declare class BindingRenderedChunkMeta {
114
- get chunks(): Record<string, BindingRenderedChunk>;
115
- }
116
- declare class BindingRenderedModule {
117
- get code(): string | null;
118
- get renderedExports(): Array<string>;
119
- }
120
- declare class BindingTransformPluginContext {
121
- getCombinedSourcemap(): string;
122
- inner(): BindingPluginContext;
123
- }
124
- declare class BindingWatcherChangeData {
125
- path: string;
126
- kind: string;
127
- }
128
- declare class BindingWatcherEvent {
129
- eventKind(): string;
130
- watchChangeData(): BindingWatcherChangeData;
131
- bundleEndData(): BindingBundleEndEventData;
132
- bundleEventKind(): string;
133
- bundleErrorData(): BindingBundleErrorEventData;
134
- }
135
- declare class Bundler {
136
- constructor(option: BindingBundlerOptions);
137
- write(): Promise<BindingOutputs>;
138
- generate(): Promise<BindingOutputs>;
139
- scan(): Promise<BindingOutputs>;
140
- close(): Promise<void>;
141
- get closed(): boolean;
142
- getWatchFiles(): Promise<Array<string>>;
143
- generateHmrPatch(changedFiles: Array<string>): Promise<BindingHmrOutput>;
144
- hmrInvalidate(file: string, firstInvalidatedBy?: string | undefined | null): Promise<BindingHmrOutput>;
145
- }
146
- declare class ParallelJsPluginRegistry {
147
- id: number;
148
- workerCount: number;
149
- constructor(workerCount: number);
150
- }
26
+ type Severity = 'Error' | 'Warning' | 'Advice';
151
27
  declare class ParseResult {
152
28
  get program(): _oxc_project_types0.Program;
153
29
  get module(): EcmaScriptModule;
154
30
  get comments(): Array<Comment>;
155
31
  get errors(): Array<OxcError>;
156
32
  }
157
- declare class ResolverFactory {
158
- constructor(options?: NapiResolveOptions | undefined | null);
159
- static default(): ResolverFactory;
160
- /** Clone the resolver using the same underlying cache. */
161
- cloneWithOptions(options: NapiResolveOptions): ResolverFactory;
162
- /** Clear the underlying cache. */
163
- clearCache(): void;
164
- /** Synchronously resolve `specifier` at an absolute path to a `directory`. */
165
- sync(directory: string, request: string): ResolveResult;
166
- /** Asynchronously resolve `specifier` at an absolute path to a `directory`. */
167
- async(directory: string, request: string): Promise<ResolveResult>;
33
+ interface DynamicImport {
34
+ start: number;
35
+ end: number;
36
+ moduleRequest: Span;
168
37
  }
169
- interface AliasItem {
170
- find: string;
171
- replacements: Array<string>;
38
+ interface EcmaScriptModule {
39
+ /**
40
+ * Has ESM syntax.
41
+ *
42
+ * i.e. `import` and `export` statements, and `import.meta`.
43
+ *
44
+ * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
45
+ */
46
+ hasModuleSyntax: boolean;
47
+ /** Import statements. */
48
+ staticImports: Array<StaticImport>;
49
+ /** Export statements. */
50
+ staticExports: Array<StaticExport>;
51
+ /** Dynamic import expressions. */
52
+ dynamicImports: Array<DynamicImport>;
53
+ /** Span positions` of `import.meta` */
54
+ importMetas: Array<Span>;
172
55
  }
173
- interface BindingAdvancedChunksOptions {
174
- minSize?: number;
175
- minShareCount?: number;
176
- groups?: Array<BindingMatchGroup>;
177
- maxSize?: number;
178
- minModuleSize?: number;
179
- maxModuleSize?: number;
56
+ interface ExportExportName {
57
+ kind: ExportExportNameKind;
58
+ name?: string;
59
+ start?: number;
60
+ end?: number;
180
61
  }
181
- interface BindingAssetPluginConfig {
182
- isServer?: boolean;
183
- urlBase?: string;
184
- publicDir?: string;
185
- assetsInclude?: Array<BindingStringOrRegex>;
62
+ type ExportExportNameKind = /** `export { name } */
63
+ 'Name' | /** `export default expression` */
64
+ 'Default' | /** `export * from "mod" */
65
+ 'None';
66
+ interface ExportImportName {
67
+ kind: ExportImportNameKind;
68
+ name?: string;
69
+ start?: number;
70
+ end?: number;
186
71
  }
187
- interface BindingAssetSource {
188
- inner: string | Uint8Array;
72
+ type ExportImportNameKind = /** `export { name } */
73
+ 'Name' | /** `export * as ns from "mod"` */
74
+ 'All' | /** `export * from "mod"` */
75
+ 'AllButDefault' | /** Does not have a specifier. */
76
+ 'None';
77
+ interface ExportLocalName {
78
+ kind: ExportLocalNameKind;
79
+ name?: string;
80
+ start?: number;
81
+ end?: number;
189
82
  }
190
- interface BindingBuildImportAnalysisPluginConfig {
191
- preloadCode: string;
192
- insertPreload: boolean;
193
- optimizeModulePreloadRelativePaths: boolean;
194
- renderBuiltUrl: boolean;
195
- isRelativeBase: boolean;
83
+ type ExportLocalNameKind = /** `export { name } */
84
+ 'Name' | /** `export default expression` */
85
+ 'Default' |
86
+ /**
87
+ * If the exported value is not locally accessible from within the module.
88
+ * `export default function () {}`
89
+ */
90
+ 'None';
91
+
92
+ /**
93
+ * Get offset within a `Uint8Array` which is aligned on 4 GiB.
94
+ *
95
+ * Does not check that the offset is within bounds of `buffer`.
96
+ * To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
97
+ */
98
+
99
+ interface ImportName {
100
+ kind: ImportNameKind;
101
+ name?: string;
102
+ start?: number;
103
+ end?: number;
196
104
  }
197
- interface BindingBuiltinPlugin {
198
- __name: BindingBuiltinPluginName;
199
- options?: unknown;
200
- }
201
- type BindingBuiltinPluginName = 'builtin:alias' | 'builtin:asset' | 'builtin:asset-import-meta-url' | 'builtin:build-import-analysis' | 'builtin:dynamic-import-vars' | 'builtin:import-glob' | 'builtin:isolated-declaration' | 'builtin:json' | 'builtin:load-fallback' | 'builtin:manifest' | 'builtin:module-federation' | 'builtin:module-preload-polyfill' | 'builtin:oxc-runtime' | 'builtin:reporter' | 'builtin:replace' | 'builtin:transform' | 'builtin:vite-resolve' | 'builtin:wasm-fallback' | 'builtin:wasm-helper' | 'builtin:web-worker-post';
202
- interface BindingBundlerOptions {
203
- inputOptions: BindingInputOptions;
204
- outputOptions: BindingOutputOptions;
205
- parallelPluginsRegistry?: ParallelJsPluginRegistry;
206
- }
207
- interface BindingChecksOptions {
208
- circularDependency?: boolean;
209
- eval?: boolean;
210
- missingGlobalName?: boolean;
211
- missingNameOptionForIifeExport?: boolean;
212
- mixedExport?: boolean;
213
- unresolvedEntry?: boolean;
214
- unresolvedImport?: boolean;
215
- filenameConflict?: boolean;
216
- commonJsVariableInEsm?: boolean;
217
- importIsUndefined?: boolean;
218
- configurationFieldConflict?: boolean;
219
- }
220
- interface BindingDebugOptions {
221
- sessionId?: string;
222
- }
223
- interface BindingDeferSyncScanData {
224
- /** ModuleId */
225
- id: string;
226
- sideEffects?: BindingHookSideEffects;
227
- }
228
- interface BindingDynamicImportVarsPluginConfig {
229
- include?: Array<BindingStringOrRegex>;
230
- exclude?: Array<BindingStringOrRegex>;
231
- resolver?: (id: string, importer: string) => MaybePromise<string | undefined>;
232
- }
233
- interface BindingEmittedAsset {
234
- name?: string;
235
- fileName?: string;
236
- originalFileName?: string;
237
- source: BindingAssetSource;
238
- }
239
- interface BindingEmittedChunk {
240
- name?: string;
241
- fileName?: string;
242
- id: string;
243
- importer?: string;
244
- }
245
- interface BindingExperimentalHmrOptions {
246
- host?: string;
247
- port?: number;
248
- implement?: string;
249
- }
250
- interface BindingExperimentalOptions {
251
- strictExecutionOrder?: boolean;
252
- disableLiveBindings?: boolean;
253
- viteMode?: boolean;
254
- resolveNewUrlToAsset?: boolean;
255
- hmr?: BindingExperimentalHmrOptions;
256
- attachDebugInfo?: boolean;
257
- }
258
- interface BindingFilterToken {
259
- kind: FilterTokenKind;
260
- payload?: BindingStringOrRegex | number | boolean;
261
- }
262
- interface BindingHmrBoundaryOutput {
263
- boundary: string;
264
- acceptedVia: string;
105
+ type ImportNameKind = /** `import { x } from "mod"` */
106
+ 'Name' | /** `import * as ns from "mod"` */
107
+ 'NamespaceObject' | /** `import defaultExport from "mod"` */
108
+ 'Default';
109
+
110
+ /**
111
+ * Parse asynchronously.
112
+ *
113
+ * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
114
+ */
115
+
116
+ interface ParserOptions {
117
+ /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
118
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx';
119
+ /** Treat the source text as `script` or `module` code. */
120
+ sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
121
+ /**
122
+ * Return an AST which includes TypeScript-related properties, or excludes them.
123
+ *
124
+ * `'js'` is default for JS / JSX files.
125
+ * `'ts'` is default for TS / TSX files.
126
+ * The type of the file is determined from `lang` option, or extension of provided `filename`.
127
+ */
128
+ astType?: 'js' | 'ts';
129
+ /**
130
+ * Emit `ParenthesizedExpression` and `TSParenthesizedType` in AST.
131
+ *
132
+ * If this option is true, parenthesized expressions are represented by
133
+ * (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` nodes that
134
+ * have a single `expression` property containing the expression inside parentheses.
135
+ *
136
+ * @default true
137
+ */
138
+ preserveParens?: boolean;
139
+ /**
140
+ * Produce semantic errors with an additional AST pass.
141
+ * Semantic errors depend on symbols and scopes, where the parser does not construct.
142
+ * This adds a small performance overhead.
143
+ *
144
+ * @default false
145
+ */
146
+ showSemanticErrors?: boolean;
265
147
  }
266
- interface BindingHmrOutput {
267
- code: string;
268
- filename: string;
269
- sourcemap?: string;
270
- sourcemapFilename?: string;
271
- hmrBoundaries: Array<BindingHmrBoundaryOutput>;
272
- fullReload: boolean;
273
- firstInvalidatedBy?: string;
274
- isSelfAccepting: boolean;
275
- fullReloadReason?: string;
148
+
149
+ /** Parse synchronously. */
150
+
151
+ interface Span {
152
+ start: number;
153
+ end: number;
276
154
  }
277
- interface BindingHookFilter {
278
- value?: Array<Array<BindingFilterToken>>;
155
+ interface StaticExport {
156
+ start: number;
157
+ end: number;
158
+ entries: Array<StaticExportEntry>;
279
159
  }
280
- interface BindingHookLoadOutput {
281
- code: string;
282
- sideEffects?: BindingHookSideEffects;
283
- map?: BindingSourcemap;
284
- moduleType?: string;
160
+ interface StaticExportEntry {
161
+ start: number;
162
+ end: number;
163
+ moduleRequest?: ValueSpan;
164
+ /** The name under which the desired binding is exported by the module`. */
165
+ importName: ExportImportName;
166
+ /** The name used to export this binding by this module. */
167
+ exportName: ExportExportName;
168
+ /** The name that is used to locally access the exported value from within the importing module. */
169
+ localName: ExportLocalName;
170
+ /**
171
+ * Whether the export is a TypeScript `export type`.
172
+ *
173
+ * Examples:
174
+ *
175
+ * ```ts
176
+ * export type * from 'mod';
177
+ * export type * as ns from 'mod';
178
+ * export type { foo };
179
+ * export { type foo }:
180
+ * export type { foo } from 'mod';
181
+ * ```
182
+ */
183
+ isType: boolean;
285
184
  }
286
- interface BindingHookRenderChunkOutput {
287
- code: string;
288
- map?: BindingSourcemap;
185
+ interface StaticImport {
186
+ /** Start of import statement. */
187
+ start: number;
188
+ /** End of import statement. */
189
+ end: number;
190
+ /**
191
+ * Import source.
192
+ *
193
+ * ```js
194
+ * import { foo } from "mod";
195
+ * // ^^^
196
+ * ```
197
+ */
198
+ moduleRequest: ValueSpan;
199
+ /**
200
+ * Import specifiers.
201
+ *
202
+ * Empty for `import "mod"`.
203
+ */
204
+ entries: Array<StaticImportEntry>;
289
205
  }
290
- interface BindingHookResolveIdExtraArgs {
291
- custom?: number;
292
- isEntry: boolean;
206
+ interface StaticImportEntry {
293
207
  /**
294
- * - `import-statement`: `import { foo } from './lib.js';`
295
- * - `dynamic-import`: `import('./lib.js')`
296
- * - `require-call`: `require('./lib.js')`
297
- * - `import-rule`: `@import 'bg-color.css'`
298
- * - `url-token`: `url('./icon.png')`
299
- * - `new-url`: `new URL('./worker.js', import.meta.url)`
300
- * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
208
+ * The name under which the desired binding is exported by the module.
209
+ *
210
+ * ```js
211
+ * import { foo } from "mod";
212
+ * // ^^^
213
+ * import { foo as bar } from "mod";
214
+ * // ^^^
215
+ * ```
301
216
  */
302
- kind: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
217
+ importName: ImportName;
218
+ /**
219
+ * The name that is used to locally access the imported value from within the importing module.
220
+ * ```js
221
+ * import { foo } from "mod";
222
+ * // ^^^
223
+ * import { foo as bar } from "mod";
224
+ * // ^^^
225
+ * ```
226
+ */
227
+ localName: ValueSpan;
228
+ /**
229
+ * Whether this binding is for a TypeScript type-only import.
230
+ *
231
+ * `true` for the following imports:
232
+ * ```ts
233
+ * import type { foo } from "mod";
234
+ * import { type foo } from "mod";
235
+ * ```
236
+ */
237
+ isType: boolean;
303
238
  }
304
- interface BindingHookResolveIdOutput {
305
- id: string;
306
- external?: BindingResolvedExternal;
307
- normalizeExternalId?: boolean;
308
- sideEffects?: BindingHookSideEffects;
239
+ interface ValueSpan {
240
+ value: string;
241
+ start: number;
242
+ end: number;
309
243
  }
310
- declare enum BindingHookSideEffects {
311
- True = 0,
312
- False = 1,
313
- NoTreeshake = 2,
244
+ declare class ResolverFactory {
245
+ constructor(options?: NapiResolveOptions | undefined | null);
246
+ static default(): ResolverFactory;
247
+ /** Clone the resolver using the same underlying cache. */
248
+ cloneWithOptions(options: NapiResolveOptions): ResolverFactory;
249
+ /** Clear the underlying cache. */
250
+ clearCache(): void;
251
+ /** Synchronously resolve `specifier` at an absolute path to a `directory`. */
252
+ sync(directory: string, request: string): ResolveResult;
253
+ /** Asynchronously resolve `specifier` at an absolute path to a `directory`. */
254
+ async(directory: string, request: string): Promise<ResolveResult>;
314
255
  }
315
- interface BindingHookTransformOutput {
316
- code?: string;
317
- sideEffects?: BindingHookSideEffects;
318
- map?: BindingSourcemap;
319
- moduleType?: string;
256
+ declare enum EnforceExtension {
257
+ Auto = 0,
258
+ Enabled = 1,
259
+ Disabled = 2,
320
260
  }
321
- interface BindingImportGlobPluginConfig {
322
- root?: string;
323
- restoreQueryExtension?: boolean;
324
- }
325
- interface BindingInjectImportNamed {
326
- tagNamed: true;
327
- imported: string;
328
- alias?: string;
329
- from: string;
330
- }
331
- interface BindingInjectImportNamespace {
332
- tagNamespace: true;
333
- alias: string;
334
- from: string;
335
- }
336
- interface BindingInputItem {
337
- name?: string;
338
- import: string;
339
- }
340
- interface BindingInputOptions {
341
- external?: undefined | ((source: string, importer: string | undefined, isResolved: boolean) => boolean);
342
- input: Array<BindingInputItem>;
343
- plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[];
344
- resolve?: BindingResolveOptions;
345
- shimMissingExports?: boolean;
346
- platform?: 'node' | 'browser' | 'neutral';
347
- logLevel: BindingLogLevel;
348
- onLog: (logLevel: 'debug' | 'warn' | 'info', log: BindingLog) => void;
349
- cwd: string;
350
- treeshake?: BindingTreeshake;
351
- moduleTypes?: Record<string, string>;
352
- define?: Array<[string, string]>;
353
- dropLabels?: Array<string>;
354
- inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>;
355
- experimental?: BindingExperimentalOptions;
356
- profilerNames?: boolean;
357
- jsx?: BindingJsx;
358
- transform?: TransformOptions;
359
- watch?: BindingWatchOption;
360
- keepNames?: boolean;
361
- checks?: BindingChecksOptions;
362
- deferSyncScanData?: undefined | (() => BindingDeferSyncScanData[]);
363
- makeAbsoluteExternalsRelative?: BindingMakeAbsoluteExternalsRelative;
364
- debug?: BindingDebugOptions;
365
- invalidateJsSideCache?: () => void;
366
- markModuleLoaded?: (id: string, success: boolean) => void;
367
- }
368
- interface BindingIsolatedDeclarationPluginConfig {
369
- stripInternal?: boolean;
370
- }
371
- interface BindingJsonPluginConfig {
372
- minify?: boolean;
373
- namedExports?: boolean;
374
- stringify?: BindingJsonPluginStringify;
375
- }
376
- type BindingJsonPluginStringify = boolean | string;
377
- interface BindingJsonSourcemap {
378
- file?: string;
379
- mappings?: string;
380
- sourceRoot?: string;
381
- sources?: Array<string | undefined | null>;
382
- sourcesContent?: Array<string | undefined | null>;
383
- names?: Array<string>;
384
- debugId?: string;
385
- x_google_ignoreList?: Array<number>;
386
- }
387
- declare enum BindingJsx {
388
- Disable = 0,
389
- Preserve = 1,
390
- React = 2,
391
- ReactJsx = 3,
392
- }
393
- interface BindingLog {
394
- code: string;
395
- message: string;
396
- id?: string;
397
- exporter?: string;
398
- }
399
- declare enum BindingLogLevel {
400
- Silent = 0,
401
- Warn = 1,
402
- Info = 2,
403
- Debug = 3,
404
- }
405
- type BindingMakeAbsoluteExternalsRelative = {
406
- type: 'Bool';
407
- field0: boolean;
408
- } | {
409
- type: 'IfRelativeSource';
410
- };
411
- interface BindingManifestPluginConfig {
412
- root: string;
413
- outPath: string;
414
- }
415
- interface BindingMatchGroup {
416
- name: string;
417
- test?: string | RegExp | ((id: string) => VoidNullable<boolean>);
418
- priority?: number;
419
- minSize?: number;
420
- minShareCount?: number;
421
- minModuleSize?: number;
422
- maxModuleSize?: number;
423
- maxSize?: number;
424
- }
425
- interface BindingMfManifest {
426
- filePath?: string;
427
- disableAssetsAnalyze?: boolean;
428
- fileName?: string;
429
- }
430
- interface BindingMinifyOptions {
431
- mangle?: boolean;
432
- compress?: boolean;
433
- removeWhitespace?: boolean;
434
- }
435
- interface BindingModuleFederationPluginOption {
436
- name: string;
437
- filename?: string;
438
- exposes?: Record<string, string>;
439
- remotes?: Array<BindingRemote>;
440
- shared?: Record<string, BindingShared>;
441
- runtimePlugins?: Array<string>;
442
- manifest?: BindingMfManifest;
443
- getPublicPath?: string;
444
- }
445
- interface BindingModules {
446
- values: Array<BindingRenderedModule>;
447
- keys: Array<string>;
448
- }
449
- interface BindingModuleSideEffectsRule {
450
- test?: RegExp | undefined;
451
- sideEffects: boolean;
452
- external?: boolean | undefined;
453
- }
454
- interface BindingOutputOptions {
455
- name?: string;
456
- assetFileNames?: string | ((chunk: BindingPreRenderedAsset) => string);
457
- entryFileNames?: string | ((chunk: PreRenderedChunk) => string);
458
- chunkFileNames?: string | ((chunk: PreRenderedChunk) => string);
459
- cssEntryFileNames?: string | ((chunk: PreRenderedChunk) => string);
460
- cssChunkFileNames?: string | ((chunk: PreRenderedChunk) => string);
461
- sanitizeFileName?: boolean | ((name: string) => string);
462
- banner?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
463
- dir?: string;
464
- file?: string;
465
- esModule?: boolean | 'if-default-prop';
466
- exports?: 'default' | 'named' | 'none' | 'auto';
467
- extend?: boolean;
468
- externalLiveBindings?: boolean;
469
- footer?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
470
- format?: 'es' | 'cjs' | 'iife' | 'umd' | 'app';
471
- globals?: Record<string, string> | ((name: string) => string);
472
- hashCharacters?: 'base64' | 'base36' | 'hex';
473
- inlineDynamicImports?: boolean;
474
- intro?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
475
- outro?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
476
- plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[];
477
- sourcemap?: 'file' | 'inline' | 'hidden';
478
- sourcemapIgnoreList?: (source: string, sourcemapPath: string) => boolean;
479
- sourcemapDebugIds?: boolean;
480
- sourcemapPathTransform?: (source: string, sourcemapPath: string) => string;
481
- minify?: boolean | 'dce-only' | BindingMinifyOptions;
482
- advancedChunks?: BindingAdvancedChunksOptions;
483
- legalComments?: 'none' | 'inline';
484
- polyfillRequire?: boolean;
485
- preserveModules?: boolean;
486
- virtualDirname?: string;
487
- preserveModulesRoot?: string;
488
- preserveEntrySignatures?: 'strict' | 'allow-extension' | 'exports-only' | false;
489
- }
490
- interface BindingPluginContextResolvedId {
491
- id: string;
492
- external: boolean | 'absolute' | 'relative';
493
- }
494
- interface BindingPluginContextResolveOptions {
261
+ type ModuleType = 'module' | 'commonjs' | 'json' | 'wasm' | 'addon';
262
+
263
+ /**
264
+ * Module Resolution Options
265
+ *
266
+ * Options are directly ported from [enhanced-resolve](https://github.com/webpack/enhanced-resolve#resolver-options).
267
+ *
268
+ * See [webpack resolve](https://webpack.js.org/configuration/resolve/) for information and examples
269
+ */
270
+ interface NapiResolveOptions {
495
271
  /**
496
- * - `import-statement`: `import { foo } from './lib.js';`
497
- * - `dynamic-import`: `import('./lib.js')`
498
- * - `require-call`: `require('./lib.js')`
499
- * - `import-rule`: `@import 'bg-color.css'`
500
- * - `url-token`: `url('./icon.png')`
501
- * - `new-url`: `new URL('./worker.js', import.meta.url)`
502
- * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
272
+ * Path to TypeScript configuration file.
273
+ *
274
+ * Default `None`
503
275
  */
504
- importKind?: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
505
- skipSelf?: boolean;
506
- custom?: number;
276
+ tsconfig?: TsconfigOptions;
277
+ /**
278
+ * Alias for [ResolveOptions::alias] and [ResolveOptions::fallback].
279
+ *
280
+ * For the second value of the tuple, `None -> AliasValue::Ignore`, Some(String) ->
281
+ * AliasValue::Path(String)`
282
+ * Create aliases to import or require certain modules more easily.
283
+ * A trailing $ can also be added to the given object's keys to signify an exact match.
284
+ */
285
+ alias?: Record<string, Array<string | undefined | null>>;
286
+ /**
287
+ * A list of alias fields in description files.
288
+ * Specify a field, such as `browser`, to be parsed according to [this specification](https://github.com/defunctzombie/package-browser-field-spec).
289
+ * Can be a path to json object such as `["path", "to", "exports"]`.
290
+ *
291
+ * Default `[]`
292
+ */
293
+ aliasFields?: (string | string[])[];
294
+ /**
295
+ * Condition names for exports field which defines entry points of a package.
296
+ * The key order in the exports field is significant. During condition matching, earlier entries have higher priority and take precedence over later entries.
297
+ *
298
+ * Default `[]`
299
+ */
300
+ conditionNames?: Array<string>;
301
+ /**
302
+ * If true, it will not allow extension-less files.
303
+ * So by default `require('./foo')` works if `./foo` has a `.js` extension,
304
+ * but with this enabled only `require('./foo.js')` will work.
305
+ *
306
+ * Default to `true` when [ResolveOptions::extensions] contains an empty string.
307
+ * Use `Some(false)` to disable the behavior.
308
+ * See <https://github.com/webpack/enhanced-resolve/pull/285>
309
+ *
310
+ * Default None, which is the same as `Some(false)` when the above empty rule is not applied.
311
+ */
312
+ enforceExtension?: EnforceExtension;
313
+ /**
314
+ * A list of exports fields in description files.
315
+ * Can be a path to json object such as `["path", "to", "exports"]`.
316
+ *
317
+ * Default `[["exports"]]`.
318
+ */
319
+ exportsFields?: (string | string[])[];
320
+ /**
321
+ * Fields from `package.json` which are used to provide the internal requests of a package
322
+ * (requests starting with # are considered internal).
323
+ *
324
+ * Can be a path to a JSON object such as `["path", "to", "imports"]`.
325
+ *
326
+ * Default `[["imports"]]`.
327
+ */
328
+ importsFields?: (string | string[])[];
329
+ /**
330
+ * An object which maps extension to extension aliases.
331
+ *
332
+ * Default `{}`
333
+ */
334
+ extensionAlias?: Record<string, Array<string>>;
335
+ /**
336
+ * Attempt to resolve these extensions in order.
337
+ * If multiple files share the same name but have different extensions,
338
+ * will resolve the one with the extension listed first in the array and skip the rest.
339
+ *
340
+ * Default `[".js", ".json", ".node"]`
341
+ */
342
+ extensions?: Array<string>;
343
+ /**
344
+ * Redirect module requests when normal resolving fails.
345
+ *
346
+ * Default `[]`
347
+ */
348
+ fallback?: Record<string, Array<string | undefined | null>>;
349
+ /**
350
+ * Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests).
351
+ *
352
+ * See also webpack configuration [resolve.fullySpecified](https://webpack.js.org/configuration/module/#resolvefullyspecified)
353
+ *
354
+ * Default `false`
355
+ */
356
+ fullySpecified?: boolean;
357
+ /**
358
+ * A list of main fields in description files
359
+ *
360
+ * Default `["main"]`.
361
+ */
362
+ mainFields?: string | string[];
363
+ /**
364
+ * The filename to be used while resolving directories.
365
+ *
366
+ * Default `["index"]`
367
+ */
368
+ mainFiles?: Array<string>;
369
+ /**
370
+ * A list of directories to resolve modules from, can be absolute path or folder name.
371
+ *
372
+ * Default `["node_modules"]`
373
+ */
374
+ modules?: string | string[];
375
+ /**
376
+ * Resolve to a context instead of a file.
377
+ *
378
+ * Default `false`
379
+ */
380
+ resolveToContext?: boolean;
381
+ /**
382
+ * Prefer to resolve module requests as relative requests instead of using modules from node_modules directories.
383
+ *
384
+ * Default `false`
385
+ */
386
+ preferRelative?: boolean;
387
+ /**
388
+ * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in ResolveOptions::roots.
389
+ *
390
+ * Default `false`
391
+ */
392
+ preferAbsolute?: boolean;
393
+ /**
394
+ * A list of resolve restrictions to restrict the paths that a request can be resolved on.
395
+ *
396
+ * Default `[]`
397
+ */
398
+ restrictions?: Array<Restriction>;
399
+ /**
400
+ * A list of directories where requests of server-relative URLs (starting with '/') are resolved.
401
+ * On non-Windows systems these requests are resolved as an absolute path first.
402
+ *
403
+ * Default `[]`
404
+ */
405
+ roots?: Array<string>;
406
+ /**
407
+ * Whether to resolve symlinks to their symlinked location.
408
+ * When enabled, symlinked resources are resolved to their real path, not their symlinked location.
409
+ * Note that this may cause module resolution to fail when using tools that symlink packages (like npm link).
410
+ *
411
+ * Default `true`
412
+ */
413
+ symlinks?: boolean;
414
+ /**
415
+ * Whether to parse [module.builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules) or not.
416
+ * For example, "zlib" will throw [crate::ResolveError::Builtin] when set to true.
417
+ *
418
+ * Default `false`
419
+ */
420
+ builtinModules?: boolean;
421
+ /**
422
+ * Resolve [ResolveResult::moduleType].
423
+ *
424
+ * Default `false`
425
+ */
426
+ moduleType?: boolean;
507
427
  }
508
- interface BindingPluginHookMeta {
509
- order?: BindingPluginOrder;
428
+ interface ResolveResult {
429
+ path?: string;
430
+ error?: string;
431
+ /**
432
+ * Module type for this path.
433
+ *
434
+ * Enable with `ResolveOptions#moduleType`.
435
+ *
436
+ * The module type is computed `ESM_FILE_FORMAT` from the [ESM resolution algorithm specification](https://nodejs.org/docs/latest/api/esm.html#resolution-algorithm-specification).
437
+ *
438
+ * The algorithm uses the file extension or finds the closest `package.json` with the `type` field.
439
+ */
440
+ moduleType?: ModuleType;
441
+ /** `package.json` path for the given module. */
442
+ packageJsonPath?: string;
510
443
  }
511
- interface BindingPluginOptions {
512
- name: string;
513
- hookUsage: number;
514
- buildStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable>;
515
- buildStartMeta?: BindingPluginHookMeta;
516
- resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>;
517
- resolveIdMeta?: BindingPluginHookMeta;
518
- resolveIdFilter?: BindingHookFilter;
519
- resolveDynamicImport?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>;
520
- resolveDynamicImportMeta?: BindingPluginHookMeta;
521
- load?: (ctx: BindingPluginContext, id: string) => MaybePromise<VoidNullable<BindingHookLoadOutput>>;
522
- loadMeta?: BindingPluginHookMeta;
523
- loadFilter?: BindingHookFilter;
524
- transform?: (ctx: BindingTransformPluginContext, id: string, code: string, module_type: BindingTransformHookExtraArgs) => MaybePromise<VoidNullable<BindingHookTransformOutput>>;
525
- transformMeta?: BindingPluginHookMeta;
526
- transformFilter?: BindingHookFilter;
527
- moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>;
528
- moduleParsedMeta?: BindingPluginHookMeta;
529
- buildEnd?: (ctx: BindingPluginContext, error?: (Error | BindingError)[]) => MaybePromise<VoidNullable>;
530
- buildEndMeta?: BindingPluginHookMeta;
531
- renderChunk?: (ctx: BindingPluginContext, code: string, chunk: BindingRenderedChunk, opts: BindingNormalizedOptions, meta: BindingRenderedChunkMeta) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>;
532
- renderChunkMeta?: BindingPluginHookMeta;
533
- renderChunkFilter?: BindingHookFilter;
534
- augmentChunkHash?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => MaybePromise<void | string>;
535
- augmentChunkHashMeta?: BindingPluginHookMeta;
536
- renderStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => void;
537
- renderStartMeta?: BindingPluginHookMeta;
538
- renderError?: (ctx: BindingPluginContext, error: (Error | BindingError)[]) => void;
539
- renderErrorMeta?: BindingPluginHookMeta;
540
- generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>;
541
- generateBundleMeta?: BindingPluginHookMeta;
542
- writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>;
543
- writeBundleMeta?: BindingPluginHookMeta;
544
- closeBundle?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>;
545
- closeBundleMeta?: BindingPluginHookMeta;
546
- watchChange?: (ctx: BindingPluginContext, path: string, event: string) => MaybePromise<VoidNullable>;
547
- watchChangeMeta?: BindingPluginHookMeta;
548
- closeWatcher?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>;
549
- closeWatcherMeta?: BindingPluginHookMeta;
550
- banner?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
551
- bannerMeta?: BindingPluginHookMeta;
552
- footer?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
553
- footerMeta?: BindingPluginHookMeta;
554
- intro?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
555
- introMeta?: BindingPluginHookMeta;
556
- outro?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
557
- outroMeta?: BindingPluginHookMeta;
444
+
445
+ /**
446
+ * Alias Value for [ResolveOptions::alias] and [ResolveOptions::fallback].
447
+ * Use struct because napi don't support structured union now
448
+ */
449
+ interface Restriction {
450
+ path?: string;
451
+ regex?: string;
558
452
  }
559
- declare enum BindingPluginOrder {
560
- Pre = 0,
561
- Post = 1,
453
+ /**
454
+ * Tsconfig Options
455
+ *
456
+ * Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options)
457
+ */
458
+ interface TsconfigOptions {
459
+ /**
460
+ * Allows you to specify where to find the TypeScript configuration file.
461
+ * You may provide
462
+ * * a relative path to the configuration file. It will be resolved relative to cwd.
463
+ * * an absolute path to the configuration file.
464
+ */
465
+ configFile: string;
466
+ /**
467
+ * Support for Typescript Project References.
468
+ *
469
+ * * `'auto'`: use the `references` field from tsconfig of `config_file`.
470
+ * * `string[]`: manually provided relative or absolute path.
471
+ */
472
+ references?: 'auto' | string[];
562
473
  }
563
- interface BindingPreRenderedAsset {
474
+ interface SourceMap {
475
+ file?: string;
476
+ mappings: string;
564
477
  names: Array<string>;
565
- originalFileNames: Array<string>;
566
- source: BindingAssetSource;
567
- }
568
- interface BindingRemote {
569
- type?: string;
570
- entry: string;
571
- name: string;
572
- entryGlobalName?: string;
573
- shareScope?: string;
574
- }
575
- interface BindingReplacePluginConfig {
576
- values: Record<string, string>;
577
- delimiters?: [string, string];
578
- preventAssignment?: boolean;
579
- objectGuards?: boolean;
580
- sourcemap?: boolean;
478
+ sourceRoot?: string;
479
+ sources: Array<string>;
480
+ sourcesContent?: Array<string>;
481
+ version: number;
482
+ x_google_ignoreList?: Array<number>;
581
483
  }
582
- interface BindingReporterPluginConfig {
583
- isTty: boolean;
584
- isLib: boolean;
585
- assetsDir: string;
586
- chunkLimit: number;
587
- shouldLogInfo: boolean;
588
- reportCompressedSize: boolean;
484
+ interface CompilerAssumptions {
485
+ ignoreFunctionLength?: boolean;
486
+ noDocumentAll?: boolean;
487
+ objectRestNoSymbols?: boolean;
488
+ pureGetters?: boolean;
489
+ /**
490
+ * When using public class fields, assume that they don't shadow any getter in the current class,
491
+ * in its subclasses or in its superclass. Thus, it's safe to assign them rather than using
492
+ * `Object.defineProperty`.
493
+ *
494
+ * For example:
495
+ *
496
+ * Input:
497
+ * ```js
498
+ * class Test {
499
+ * field = 2;
500
+ *
501
+ * static staticField = 3;
502
+ * }
503
+ * ```
504
+ *
505
+ * When `set_public_class_fields` is `true`, the output will be:
506
+ * ```js
507
+ * class Test {
508
+ * constructor() {
509
+ * this.field = 2;
510
+ * }
511
+ * }
512
+ * Test.staticField = 3;
513
+ * ```
514
+ *
515
+ * Otherwise, the output will be:
516
+ * ```js
517
+ * import _defineProperty from "@oxc-project/runtime/helpers/defineProperty";
518
+ * class Test {
519
+ * constructor() {
520
+ * _defineProperty(this, "field", 2);
521
+ * }
522
+ * }
523
+ * _defineProperty(Test, "staticField", 3);
524
+ * ```
525
+ *
526
+ * NOTE: For TypeScript, if you wanted behavior is equivalent to `useDefineForClassFields: false`, you should
527
+ * set both `set_public_class_fields` and [`crate::TypeScriptOptions::remove_class_fields_without_initializer`]
528
+ * to `true`.
529
+ */
530
+ setPublicClassFields?: boolean;
589
531
  }
590
- type BindingResolvedExternal = boolean | string;
591
- interface BindingResolveOptions {
592
- alias?: Array<AliasItem>;
593
- aliasFields?: Array<Array<string>>;
594
- conditionNames?: Array<string>;
595
- exportsFields?: Array<Array<string>>;
596
- extensions?: Array<string>;
597
- extensionAlias?: Array<ExtensionAliasItem>;
598
- mainFields?: Array<string>;
599
- mainFiles?: Array<string>;
600
- modules?: Array<string>;
601
- symlinks?: boolean;
602
- tsconfigFilename?: string;
532
+ interface DecoratorOptions {
533
+ /**
534
+ * Enables experimental support for decorators, which is a version of decorators that predates the TC39 standardization process.
535
+ *
536
+ * Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification.
537
+ * This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
538
+ *
539
+ * @see https://www.typescriptlang.org/tsconfig/#experimentalDecorators
540
+ * @default false
541
+ */
542
+ legacy?: boolean;
543
+ /**
544
+ * Enables emitting decorator metadata.
545
+ *
546
+ * This option the same as [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
547
+ * in TypeScript, and it only works when `legacy` is true.
548
+ *
549
+ * @see https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata
550
+ * @default false
551
+ */
552
+ emitDecoratorMetadata?: boolean;
603
553
  }
604
- interface BindingShared {
605
- version?: string;
606
- shareScope?: string;
607
- singleton?: boolean;
608
- requiredVersion?: string;
609
- strictVersion?: boolean;
554
+ type HelperMode =
555
+ /**
556
+ * Runtime mode (default): Helper functions are imported from a runtime package.
557
+ *
558
+ * Example:
559
+ *
560
+ * ```js
561
+ * import helperName from "@oxc-project/runtime/helpers/helperName";
562
+ * helperName(...arguments);
563
+ * ```
564
+ */
565
+ 'Runtime' |
566
+ /**
567
+ * External mode: Helper functions are accessed from a global `babelHelpers` object.
568
+ *
569
+ * Example:
570
+ *
571
+ * ```js
572
+ * babelHelpers.helperName(...arguments);
573
+ * ```
574
+ */
575
+ 'External';
576
+ interface Helpers {
577
+ mode?: HelperMode;
610
578
  }
611
- interface BindingSourcemap {
612
- inner: string | BindingJsonSourcemap;
579
+
580
+ /** TypeScript Isolated Declarations for Standalone DTS Emit */
581
+ declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult;
582
+ interface IsolatedDeclarationsOptions {
583
+ /**
584
+ * Do not emit declarations for code that has an @internal annotation in its JSDoc comment.
585
+ * This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
586
+ *
587
+ * Default: `false`
588
+ *
589
+ * See <https://www.typescriptlang.org/tsconfig/#stripInternal>
590
+ */
591
+ stripInternal?: boolean;
592
+ sourcemap?: boolean;
613
593
  }
614
- interface BindingTransformHookExtraArgs {
615
- moduleType: string;
594
+ interface IsolatedDeclarationsResult {
595
+ code: string;
596
+ map?: SourceMap;
597
+ errors: Array<OxcError>;
616
598
  }
617
- interface BindingTransformPluginConfig {
618
- include?: Array<BindingStringOrRegex>;
619
- exclude?: Array<BindingStringOrRegex>;
620
- jsxRefreshInclude?: Array<BindingStringOrRegex>;
621
- jsxRefreshExclude?: Array<BindingStringOrRegex>;
622
- isServerConsumer?: boolean;
623
- runtimeResolveBase?: string;
624
- jsxInject?: string;
625
- transformOptions?: TransformOptions;
599
+
600
+ /**
601
+ * Configure how TSX and JSX are transformed.
602
+ *
603
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
604
+ */
605
+ interface JsxOptions {
606
+ /**
607
+ * Decides which runtime to use.
608
+ *
609
+ * - 'automatic' - auto-import the correct JSX factories
610
+ * - 'classic' - no auto-import
611
+ *
612
+ * @default 'automatic'
613
+ */
614
+ runtime?: 'classic' | 'automatic';
615
+ /**
616
+ * Emit development-specific information, such as `__source` and `__self`.
617
+ *
618
+ * @default false
619
+ *
620
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
621
+ */
622
+ development?: boolean;
623
+ /**
624
+ * Toggles whether or not to throw an error if an XML namespaced tag name
625
+ * is used.
626
+ *
627
+ * Though the JSX spec allows this, it is disabled by default since React's
628
+ * JSX does not currently have support for it.
629
+ *
630
+ * @default true
631
+ */
632
+ throwIfNamespace?: boolean;
633
+ /**
634
+ * Enables `@babel/plugin-transform-react-pure-annotations`.
635
+ *
636
+ * It will mark top-level React method calls as pure for tree shaking.
637
+ *
638
+ * @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
639
+ *
640
+ * @default true
641
+ */
642
+ pure?: boolean;
643
+ /**
644
+ * Replaces the import source when importing functions.
645
+ *
646
+ * @default 'react'
647
+ */
648
+ importSource?: string;
649
+ /**
650
+ * Replace the function used when compiling JSX expressions. It should be a
651
+ * qualified name (e.g. `React.createElement`) or an identifier (e.g.
652
+ * `createElement`).
653
+ *
654
+ * Only used for `classic` {@link runtime}.
655
+ *
656
+ * @default 'React.createElement'
657
+ */
658
+ pragma?: string;
659
+ /**
660
+ * Replace the component used when compiling JSX fragments. It should be a
661
+ * valid JSX tag name.
662
+ *
663
+ * Only used for `classic` {@link runtime}.
664
+ *
665
+ * @default 'React.Fragment'
666
+ */
667
+ pragmaFrag?: string;
668
+ /**
669
+ * When spreading props, use `Object.assign` directly instead of an extend helper.
670
+ *
671
+ * Only used for `classic` {@link runtime}.
672
+ *
673
+ * @default false
674
+ */
675
+ useBuiltIns?: boolean;
676
+ /**
677
+ * When spreading props, use inline object with spread elements directly
678
+ * instead of an extend helper or Object.assign.
679
+ *
680
+ * Only used for `classic` {@link runtime}.
681
+ *
682
+ * @default false
683
+ */
684
+ useSpread?: boolean;
685
+ /**
686
+ * Enable React Fast Refresh .
687
+ *
688
+ * Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
689
+ *
690
+ * @default false
691
+ */
692
+ refresh?: boolean | ReactRefreshOptions;
626
693
  }
627
- interface BindingTreeshake {
628
- moduleSideEffects: boolean | BindingModuleSideEffectsRule[] | ((id: string, is_external: boolean) => boolean | undefined);
629
- annotations?: boolean;
630
- manualPureFunctions?: Array<string>;
631
- unknownGlobalSideEffects?: boolean;
694
+
695
+ /**
696
+ * Transform JavaScript code to a Vite Node runnable module.
697
+ *
698
+ * @param filename The name of the file being transformed.
699
+ * @param sourceText the source code itself
700
+ * @param options The options for the transformation. See {@link
701
+ * ModuleRunnerTransformOptions} for more information.
702
+ *
703
+ * @returns an object containing the transformed code, source maps, and any
704
+ * errors that occurred during parsing or transformation.
705
+ *
706
+ * @deprecated Only works for Vite.
707
+ */
708
+ declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult;
709
+ interface ModuleRunnerTransformOptions {
710
+ /**
711
+ * Enable source map generation.
712
+ *
713
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
714
+ *
715
+ * @default false
716
+ *
717
+ * @see {@link SourceMap}
718
+ */
719
+ sourcemap?: boolean;
632
720
  }
633
- interface BindingViteResolvePluginConfig {
634
- resolveOptions: BindingViteResolvePluginResolveOptions;
635
- environmentConsumer: string;
636
- environmentName: string;
637
- builtins: Array<BindingStringOrRegex>;
638
- external: true | string[];
639
- noExternal: true | Array<string | RegExp>;
640
- dedupe: Array<string>;
641
- finalizeBareSpecifier?: (resolvedId: string, rawId: string, importer: string | null | undefined) => VoidNullable<string>;
642
- finalizeOtherSpecifiers?: (resolvedId: string, rawId: string) => VoidNullable<string>;
721
+ interface ModuleRunnerTransformResult {
722
+ /**
723
+ * The transformed code.
724
+ *
725
+ * If parsing failed, this will be an empty string.
726
+ */
727
+ code: string;
728
+ /**
729
+ * The source map for the transformed code.
730
+ *
731
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
732
+ */
733
+ map?: SourceMap;
734
+ deps: Array<string>;
735
+ dynamicDeps: Array<string>;
736
+ /**
737
+ * Parse and transformation errors.
738
+ *
739
+ * Oxc's parser recovers from common syntax errors, meaning that
740
+ * transformed code may still be available even if there are errors in this
741
+ * list.
742
+ */
743
+ errors: Array<OxcError>;
643
744
  }
644
- interface BindingViteResolvePluginResolveOptions {
645
- isBuild: boolean;
646
- isProduction: boolean;
647
- asSrc: boolean;
648
- preferRelative: boolean;
649
- isRequire?: boolean;
650
- root: string;
651
- scan: boolean;
652
- mainFields: Array<string>;
653
- conditions: Array<string>;
654
- externalConditions: Array<string>;
655
- extensions: Array<string>;
656
- tryIndex: boolean;
657
- tryPrefix?: string;
658
- preserveSymlinks: boolean;
745
+ interface ReactRefreshOptions {
746
+ /**
747
+ * Specify the identifier of the refresh registration variable.
748
+ *
749
+ * @default `$RefreshReg$`.
750
+ */
751
+ refreshReg?: string;
752
+ /**
753
+ * Specify the identifier of the refresh signature variable.
754
+ *
755
+ * @default `$RefreshSig$`.
756
+ */
757
+ refreshSig?: string;
758
+ emitFullSignatures?: boolean;
659
759
  }
660
- interface BindingWatchOption {
661
- skipWrite?: boolean;
662
- include?: Array<BindingStringOrRegex>;
663
- exclude?: Array<BindingStringOrRegex>;
664
- buildDelay?: number;
760
+
761
+ /**
762
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version.
763
+ *
764
+ * @param filename The name of the file being transformed. If this is a
765
+ * relative path, consider setting the {@link TransformOptions#cwd} option..
766
+ * @param sourceText the source code itself
767
+ * @param options The options for the transformation. See {@link
768
+ * TransformOptions} for more information.
769
+ *
770
+ * @returns an object containing the transformed code, source maps, and any
771
+ * errors that occurred during parsing or transformation.
772
+ */
773
+ declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult;
774
+
775
+ /**
776
+ * Options for transforming a JavaScript or TypeScript file.
777
+ *
778
+ * @see {@link transform}
779
+ */
780
+ interface TransformOptions {
781
+ /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
782
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx';
783
+ /** Treat the source text as `script` or `module` code. */
784
+ sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
785
+ /**
786
+ * The current working directory. Used to resolve relative paths in other
787
+ * options.
788
+ */
789
+ cwd?: string;
790
+ /**
791
+ * Enable source map generation.
792
+ *
793
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
794
+ *
795
+ * @default false
796
+ *
797
+ * @see {@link SourceMap}
798
+ */
799
+ sourcemap?: boolean;
800
+ /** Set assumptions in order to produce smaller output. */
801
+ assumptions?: CompilerAssumptions;
802
+ /** Configure how TypeScript is transformed. */
803
+ typescript?: TypeScriptOptions;
804
+ /** Configure how TSX and JSX are transformed. */
805
+ jsx?: 'preserve' | JsxOptions;
806
+ /**
807
+ * Sets the target environment for the generated JavaScript.
808
+ *
809
+ * The lowest target is `es2015`.
810
+ *
811
+ * Example:
812
+ *
813
+ * * 'es2015'
814
+ * * ['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']
815
+ *
816
+ * @default `esnext` (No transformation)
817
+ *
818
+ * @see [esbuild#target](https://esbuild.github.io/api/#target)
819
+ */
820
+ target?: string | Array<string>;
821
+ /** Behaviour for runtime helpers. */
822
+ helpers?: Helpers;
823
+ /** Define Plugin */
824
+ define?: Record<string, string>;
825
+ /** Inject Plugin */
826
+ inject?: Record<string, string | [string, string]>;
827
+ /** Decorator plugin */
828
+ decorator?: DecoratorOptions;
665
829
  }
666
- interface Comment {
667
- type: 'Line' | 'Block';
668
- value: string;
669
- start: number;
670
- end: number;
830
+ interface TransformResult {
831
+ /**
832
+ * The transformed code.
833
+ *
834
+ * If parsing failed, this will be an empty string.
835
+ */
836
+ code: string;
837
+ /**
838
+ * The source map for the transformed code.
839
+ *
840
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
841
+ */
842
+ map?: SourceMap;
843
+ /**
844
+ * The `.d.ts` declaration file for the transformed code. Declarations are
845
+ * only generated if `declaration` is set to `true` and a TypeScript file
846
+ * is provided.
847
+ *
848
+ * If parsing failed and `declaration` is set, this will be an empty string.
849
+ *
850
+ * @see {@link TypeScriptOptions#declaration}
851
+ * @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
852
+ */
853
+ declaration?: string;
854
+ /**
855
+ * Declaration source map. Only generated if both
856
+ * {@link TypeScriptOptions#declaration declaration} and
857
+ * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
858
+ */
859
+ declarationMap?: SourceMap;
860
+ /**
861
+ * Helpers used.
862
+ *
863
+ * @internal
864
+ *
865
+ * Example:
866
+ *
867
+ * ```text
868
+ * { "_objectSpread": "@oxc-project/runtime/helpers/objectSpread2" }
869
+ * ```
870
+ */
871
+ helpersUsed: Record<string, string>;
872
+ /**
873
+ * Parse and transformation errors.
874
+ *
875
+ * Oxc's parser recovers from common syntax errors, meaning that
876
+ * transformed code may still be available even if there are errors in this
877
+ * list.
878
+ */
879
+ errors: Array<OxcError>;
671
880
  }
672
- interface CompilerAssumptions {
673
- ignoreFunctionLength?: boolean;
674
- noDocumentAll?: boolean;
675
- objectRestNoSymbols?: boolean;
676
- pureGetters?: boolean;
881
+ interface TypeScriptOptions {
882
+ jsxPragma?: string;
883
+ jsxPragmaFrag?: string;
884
+ onlyRemoveTypeImports?: boolean;
885
+ allowNamespaces?: boolean;
677
886
  /**
678
- * When using public class fields, assume that they don't shadow any getter in the current class,
679
- * in its subclasses or in its superclass. Thus, it's safe to assign them rather than using
680
- * `Object.defineProperty`.
887
+ * When enabled, type-only class fields are only removed if they are prefixed with the declare modifier:
681
888
  *
682
- * For example:
889
+ * @deprecated
683
890
  *
684
- * Input:
685
- * ```js
686
- * class Test {
687
- * field = 2;
891
+ * Allowing `declare` fields is built-in support in Oxc without any option. If you want to remove class fields
892
+ * without initializer, you can use `remove_class_fields_without_initializer: true` instead.
893
+ */
894
+ allowDeclareFields?: boolean;
895
+ /**
896
+ * When enabled, class fields without initializers are removed.
688
897
  *
689
- * static staticField = 3;
898
+ * For example:
899
+ * ```ts
900
+ * class Foo {
901
+ * x: number;
902
+ * y: number = 0;
690
903
  * }
691
904
  * ```
692
- *
693
- * When `set_public_class_fields` is `true`, the output will be:
905
+ * // transform into
694
906
  * ```js
695
- * class Test {
696
- * constructor() {
697
- * this.field = 2;
698
- * }
907
+ * class Foo {
908
+ * x: number;
699
909
  * }
700
- * Test.staticField = 3;
701
910
  * ```
702
911
  *
703
- * Otherwise, the output will be:
912
+ * The option is used to align with the behavior of TypeScript's `useDefineForClassFields: false` option.
913
+ * When you want to enable this, you also need to set [`crate::CompilerAssumptions::set_public_class_fields`]
914
+ * to `true`. The `set_public_class_fields: true` + `remove_class_fields_without_initializer: true` is
915
+ * equivalent to `useDefineForClassFields: false` in TypeScript.
916
+ *
917
+ * When `set_public_class_fields` is true and class-properties plugin is enabled, the above example transforms into:
918
+ *
704
919
  * ```js
705
- * import _defineProperty from "@oxc-project/runtime/helpers/defineProperty";
706
- * class Test {
920
+ * class Foo {
707
921
  * constructor() {
708
- * _defineProperty(this, "field", 2);
922
+ * this.y = 0;
709
923
  * }
710
924
  * }
711
- * _defineProperty(Test, "staticField", 3);
712
925
  * ```
713
926
  *
714
- * NOTE: For TypeScript, if you wanted behavior is equivalent to `useDefineForClassFields: false`, you should
715
- * set both `set_public_class_fields` and [`crate::TypeScriptOptions::remove_class_fields_without_initializer`]
716
- * to `true`.
927
+ * Defaults to `false`.
717
928
  */
718
- setPublicClassFields?: boolean;
719
- }
720
- interface DecoratorOptions {
929
+ removeClassFieldsWithoutInitializer?: boolean;
721
930
  /**
722
- * Enables experimental support for decorators, which is a version of decorators that predates the TC39 standardization process.
931
+ * Also generate a `.d.ts` declaration file for TypeScript files.
723
932
  *
724
- * Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification.
725
- * This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
933
+ * The source file must be compliant with all
934
+ * [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
935
+ * requirements.
726
936
  *
727
- * @see https://www.typescriptlang.org/tsconfig/#experimentalDecorators
728
937
  * @default false
729
938
  */
730
- legacy?: boolean;
939
+ declaration?: IsolatedDeclarationsOptions;
731
940
  /**
732
- * Enables emitting decorator metadata.
941
+ * Rewrite or remove TypeScript import/export declaration extensions.
733
942
  *
734
- * This option the same as [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
735
- * in TypeScript, and it only works when `legacy` is true.
943
+ * - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
944
+ * - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
945
+ * - When set to `true`, it's equivalent to `rewrite`.
946
+ * - When set to `false` or omitted, no changes will be made to the extensions.
736
947
  *
737
- * @see https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata
738
948
  * @default false
739
949
  */
740
- emitDecoratorMetadata?: boolean;
950
+ rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
741
951
  }
742
- interface DynamicImport {
743
- start: number;
744
- end: number;
745
- moduleRequest: Span;
952
+ declare class BindingBundleEndEventData {
953
+ output: string;
954
+ duration: number;
955
+ get result(): Bundler;
746
956
  }
747
- interface EcmaScriptModule {
748
- /**
749
- * Has ESM syntax.
750
- *
751
- * i.e. `import` and `export` statements, and `import.meta`.
752
- *
753
- * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
754
- */
755
- hasModuleSyntax: boolean;
756
- /** Import statements. */
757
- staticImports: Array<StaticImport>;
758
- /** Export statements. */
759
- staticExports: Array<StaticExport>;
760
- /** Dynamic import expressions. */
761
- dynamicImports: Array<DynamicImport>;
762
- /** Span positions` of `import.meta` */
763
- importMetas: Array<Span>;
957
+ declare class BindingBundleErrorEventData {
958
+ get result(): Bundler;
959
+ get error(): Array<Error | BindingError>;
764
960
  }
765
- declare enum EnforceExtension {
766
- Auto = 0,
767
- Enabled = 1,
768
- Disabled = 2,
961
+ declare class BindingError {
962
+ kind: string;
963
+ message: string;
964
+ }
965
+ declare class BindingModuleInfo {
966
+ id: string;
967
+ importers: Array<string>;
968
+ dynamicImporters: Array<string>;
969
+ importedIds: Array<string>;
970
+ dynamicallyImportedIds: Array<string>;
971
+ exports: Array<string>;
972
+ isEntry: boolean;
973
+ get code(): string | null;
974
+ }
975
+ declare class BindingNormalizedOptions {
976
+ get input(): Array<string> | Record<string, string>;
977
+ get cwd(): string | null;
978
+ get platform(): 'node' | 'browser' | 'neutral';
979
+ get shimMissingExports(): boolean;
980
+ get name(): string | null;
981
+ get cssEntryFilenames(): string | undefined;
982
+ get cssChunkFilenames(): string | undefined;
983
+ get entryFilenames(): string | undefined;
984
+ get chunkFilenames(): string | undefined;
985
+ get assetFilenames(): string | undefined;
986
+ get dir(): string | null;
987
+ get file(): string | null;
988
+ get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd';
989
+ get exports(): 'default' | 'named' | 'none' | 'auto';
990
+ get esModule(): boolean | 'if-default-prop';
991
+ get inlineDynamicImports(): boolean;
992
+ get sourcemap(): boolean | 'inline' | 'hidden';
993
+ get banner(): string | undefined | null | undefined;
994
+ get footer(): string | undefined | null | undefined;
995
+ get intro(): string | undefined | null | undefined;
996
+ get outro(): string | undefined | null | undefined;
997
+ get externalLiveBindings(): boolean;
998
+ get extend(): boolean;
999
+ get globals(): Record<string, string> | undefined;
1000
+ get hashCharacters(): 'base64' | 'base36' | 'hex';
1001
+ get sourcemapDebugIds(): boolean;
1002
+ get minify(): false | BindingMinifyOptions;
1003
+ get polyfillRequire(): boolean;
1004
+ get legalComments(): 'none' | 'inline';
1005
+ }
1006
+ declare class BindingOutputAsset {
1007
+ get fileName(): string;
1008
+ get originalFileName(): string | null;
1009
+ get originalFileNames(): Array<string>;
1010
+ get source(): BindingAssetSource;
1011
+ get name(): string | null;
1012
+ get names(): Array<string>;
1013
+ }
1014
+ declare class BindingOutputChunk {
1015
+ get isEntry(): boolean;
1016
+ get isDynamicEntry(): boolean;
1017
+ get facadeModuleId(): string | null;
1018
+ get moduleIds(): Array<string>;
1019
+ get exports(): Array<string>;
1020
+ get fileName(): string;
1021
+ get modules(): BindingModules;
1022
+ get imports(): Array<string>;
1023
+ get dynamicImports(): Array<string>;
1024
+ get code(): string;
1025
+ get map(): string | null;
1026
+ get sourcemapFileName(): string | null;
1027
+ get preliminaryFileName(): string;
1028
+ get name(): string;
1029
+ }
1030
+ declare class BindingOutputs {
1031
+ get chunks(): Array<BindingOutputChunk>;
1032
+ get assets(): Array<BindingOutputAsset>;
1033
+ get errors(): Array<Error | BindingError>;
1034
+ }
1035
+ declare class BindingPluginContext {
1036
+ load(specifier: string, sideEffects: BindingHookSideEffects | undefined): Promise<void>;
1037
+ resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>;
1038
+ emitFile(file: BindingEmittedAsset, assetFilename?: string | undefined | null, fnSanitizedFileName?: string | undefined | null): string;
1039
+ emitChunk(file: BindingEmittedChunk): string;
1040
+ getFileName(referenceId: string): string;
1041
+ getModuleInfo(moduleId: string): BindingModuleInfo | null;
1042
+ getModuleIds(): Array<string>;
1043
+ addWatchFile(file: string): void;
1044
+ }
1045
+ declare class BindingRenderedChunk {
1046
+ get name(): string;
1047
+ get isEntry(): boolean;
1048
+ get isDynamicEntry(): boolean;
1049
+ get facadeModuleId(): string | null;
1050
+ get moduleIds(): Array<string>;
1051
+ get exports(): Array<string>;
1052
+ get fileName(): string;
1053
+ get modules(): BindingModules;
1054
+ get imports(): Array<string>;
1055
+ get dynamicImports(): Array<string>;
1056
+ }
1057
+ declare class BindingRenderedChunkMeta {
1058
+ get chunks(): Record<string, BindingRenderedChunk>;
1059
+ }
1060
+ declare class BindingRenderedModule {
1061
+ get code(): string | null;
1062
+ get renderedExports(): Array<string>;
1063
+ }
1064
+ declare class BindingTransformPluginContext {
1065
+ getCombinedSourcemap(): string;
1066
+ inner(): BindingPluginContext;
1067
+ }
1068
+ declare class BindingWatcherChangeData {
1069
+ path: string;
1070
+ kind: string;
1071
+ }
1072
+ declare class BindingWatcherEvent {
1073
+ eventKind(): string;
1074
+ watchChangeData(): BindingWatcherChangeData;
1075
+ bundleEndData(): BindingBundleEndEventData;
1076
+ bundleEventKind(): string;
1077
+ bundleErrorData(): BindingBundleErrorEventData;
1078
+ }
1079
+ declare class Bundler {
1080
+ constructor(option: BindingBundlerOptions);
1081
+ write(): Promise<BindingOutputs>;
1082
+ generate(): Promise<BindingOutputs>;
1083
+ scan(): Promise<BindingOutputs>;
1084
+ close(): Promise<void>;
1085
+ get closed(): boolean;
1086
+ getWatchFiles(): Promise<Array<string>>;
1087
+ generateHmrPatch(changedFiles: Array<string>): Promise<BindingHmrOutput>;
1088
+ hmrInvalidate(file: string, firstInvalidatedBy?: string | undefined | null): Promise<BindingHmrOutput>;
1089
+ }
1090
+ declare class ParallelJsPluginRegistry {
1091
+ id: number;
1092
+ workerCount: number;
1093
+ constructor(workerCount: number);
1094
+ }
1095
+ interface AliasItem {
1096
+ find: string;
1097
+ replacements: Array<string>;
1098
+ }
1099
+ interface BindingAdvancedChunksOptions {
1100
+ minSize?: number;
1101
+ minShareCount?: number;
1102
+ groups?: Array<BindingMatchGroup>;
1103
+ maxSize?: number;
1104
+ minModuleSize?: number;
1105
+ maxModuleSize?: number;
1106
+ }
1107
+ interface BindingAssetPluginConfig {
1108
+ isServer?: boolean;
1109
+ urlBase?: string;
1110
+ publicDir?: string;
1111
+ assetsInclude?: Array<BindingStringOrRegex>;
1112
+ }
1113
+ interface BindingAssetSource {
1114
+ inner: string | Uint8Array;
1115
+ }
1116
+ interface BindingBuildImportAnalysisPluginConfig {
1117
+ preloadCode: string;
1118
+ insertPreload: boolean;
1119
+ optimizeModulePreloadRelativePaths: boolean;
1120
+ renderBuiltUrl: boolean;
1121
+ isRelativeBase: boolean;
1122
+ }
1123
+ interface BindingBuiltinPlugin {
1124
+ __name: BindingBuiltinPluginName;
1125
+ options?: unknown;
1126
+ }
1127
+ type BindingBuiltinPluginName = 'builtin:alias' | 'builtin:asset' | 'builtin:asset-import-meta-url' | 'builtin:build-import-analysis' | 'builtin:dynamic-import-vars' | 'builtin:import-glob' | 'builtin:isolated-declaration' | 'builtin:json' | 'builtin:load-fallback' | 'builtin:manifest' | 'builtin:module-federation' | 'builtin:module-preload-polyfill' | 'builtin:oxc-runtime' | 'builtin:reporter' | 'builtin:replace' | 'builtin:transform' | 'builtin:vite-resolve' | 'builtin:wasm-fallback' | 'builtin:wasm-helper' | 'builtin:web-worker-post';
1128
+ interface BindingBundlerOptions {
1129
+ inputOptions: BindingInputOptions;
1130
+ outputOptions: BindingOutputOptions;
1131
+ parallelPluginsRegistry?: ParallelJsPluginRegistry;
1132
+ }
1133
+ interface BindingChecksOptions {
1134
+ circularDependency?: boolean;
1135
+ eval?: boolean;
1136
+ missingGlobalName?: boolean;
1137
+ missingNameOptionForIifeExport?: boolean;
1138
+ mixedExport?: boolean;
1139
+ unresolvedEntry?: boolean;
1140
+ unresolvedImport?: boolean;
1141
+ filenameConflict?: boolean;
1142
+ commonJsVariableInEsm?: boolean;
1143
+ importIsUndefined?: boolean;
1144
+ configurationFieldConflict?: boolean;
769
1145
  }
770
- interface ErrorLabel {
771
- message?: string;
772
- start: number;
773
- end: number;
1146
+ interface BindingDebugOptions {
1147
+ sessionId?: string;
774
1148
  }
775
- interface ExportExportName {
776
- kind: ExportExportNameKind;
777
- name?: string;
778
- start?: number;
779
- end?: number;
1149
+ interface BindingDeferSyncScanData {
1150
+ /** ModuleId */
1151
+ id: string;
1152
+ sideEffects?: BindingHookSideEffects;
780
1153
  }
781
- type ExportExportNameKind = /** `export { name } */
782
- 'Name' | /** `export default expression` */
783
- 'Default' | /** `export * from "mod" */
784
- 'None';
785
- interface ExportImportName {
786
- kind: ExportImportNameKind;
787
- name?: string;
788
- start?: number;
789
- end?: number;
1154
+ interface BindingDynamicImportVarsPluginConfig {
1155
+ include?: Array<BindingStringOrRegex>;
1156
+ exclude?: Array<BindingStringOrRegex>;
1157
+ resolver?: (id: string, importer: string) => MaybePromise<string | undefined>;
790
1158
  }
791
- type ExportImportNameKind = /** `export { name } */
792
- 'Name' | /** `export * as ns from "mod"` */
793
- 'All' | /** `export * from "mod"` */
794
- 'AllButDefault' | /** Does not have a specifier. */
795
- 'None';
796
- interface ExportLocalName {
797
- kind: ExportLocalNameKind;
1159
+ interface BindingEmittedAsset {
798
1160
  name?: string;
799
- start?: number;
800
- end?: number;
801
- }
802
- type ExportLocalNameKind = /** `export { name } */
803
- 'Name' | /** `export default expression` */
804
- 'Default' |
805
- /**
806
- * If the exported value is not locally accessible from within the module.
807
- * `export default function () {}`
808
- */
809
- 'None';
810
- interface ExtensionAliasItem {
811
- target: string;
812
- replacements: Array<string>;
813
- }
814
- type FilterTokenKind = 'Id' | 'Code' | 'ModuleType' | 'And' | 'Or' | 'Not' | 'Include' | 'Exclude' | 'CleanUrl' | 'QueryKey' | 'QueryValue';
815
-
816
- /**
817
- * Get offset within a `Uint8Array` which is aligned on 4 GiB.
818
- *
819
- * Does not check that the offset is within bounds of `buffer`.
820
- * To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
821
- */
822
-
823
- type HelperMode =
824
- /**
825
- * Runtime mode (default): Helper functions are imported from a runtime package.
826
- *
827
- * Example:
828
- *
829
- * ```js
830
- * import helperName from "@oxc-project/runtime/helpers/helperName";
831
- * helperName(...arguments);
832
- * ```
833
- */
834
- 'Runtime' |
835
- /**
836
- * External mode: Helper functions are accessed from a global `babelHelpers` object.
837
- *
838
- * Example:
839
- *
840
- * ```js
841
- * babelHelpers.helperName(...arguments);
842
- * ```
843
- */
844
- 'External';
845
- interface Helpers {
846
- mode?: HelperMode;
1161
+ fileName?: string;
1162
+ originalFileName?: string;
1163
+ source: BindingAssetSource;
847
1164
  }
848
- interface ImportName {
849
- kind: ImportNameKind;
1165
+ interface BindingEmittedChunk {
850
1166
  name?: string;
851
- start?: number;
852
- end?: number;
1167
+ fileName?: string;
1168
+ id: string;
1169
+ importer?: string;
853
1170
  }
854
- type ImportNameKind = /** `import { x } from "mod"` */
855
- 'Name' | /** `import * as ns from "mod"` */
856
- 'NamespaceObject' | /** `import defaultExport from "mod"` */
857
- 'Default';
858
-
859
- /** TypeScript Isolated Declarations for Standalone DTS Emit */
860
- declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult;
861
- interface IsolatedDeclarationsOptions {
862
- /**
863
- * Do not emit declarations for code that has an @internal annotation in its JSDoc comment.
864
- * This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
865
- *
866
- * Default: `false`
867
- *
868
- * See <https://www.typescriptlang.org/tsconfig/#stripInternal>
869
- */
870
- stripInternal?: boolean;
871
- sourcemap?: boolean;
1171
+ interface BindingExperimentalHmrOptions {
1172
+ host?: string;
1173
+ port?: number;
1174
+ implement?: string;
872
1175
  }
873
- interface IsolatedDeclarationsResult {
874
- code: string;
875
- map?: SourceMap;
876
- errors: Array<OxcError>;
1176
+ interface BindingExperimentalOptions {
1177
+ strictExecutionOrder?: boolean;
1178
+ disableLiveBindings?: boolean;
1179
+ viteMode?: boolean;
1180
+ resolveNewUrlToAsset?: boolean;
1181
+ hmr?: BindingExperimentalHmrOptions;
1182
+ attachDebugInfo?: boolean;
877
1183
  }
878
- interface JsChangedOutputs {
879
- chunks: Array<JsOutputChunk>;
880
- assets: Array<JsOutputAsset>;
881
- deleted: Array<string>;
1184
+ interface BindingFilterToken {
1185
+ kind: FilterTokenKind;
1186
+ payload?: BindingStringOrRegex | number | boolean;
882
1187
  }
883
- interface JsOutputAsset {
884
- names: Array<string>;
885
- originalFileNames: Array<string>;
886
- filename: string;
887
- source: BindingAssetSource;
1188
+ interface BindingHmrBoundaryOutput {
1189
+ boundary: string;
1190
+ acceptedVia: string;
888
1191
  }
889
- interface JsOutputChunk {
890
- name: string;
891
- isEntry: boolean;
892
- isDynamicEntry: boolean;
893
- facadeModuleId?: string;
894
- moduleIds: Array<string>;
895
- exports: Array<string>;
896
- filename: string;
897
- modules: Record<string, BindingRenderedModule>;
898
- imports: Array<string>;
899
- dynamicImports: Array<string>;
1192
+ interface BindingHmrOutput {
900
1193
  code: string;
901
- map?: BindingSourcemap;
1194
+ filename: string;
1195
+ sourcemap?: string;
902
1196
  sourcemapFilename?: string;
903
- preliminaryFilename: string;
904
- }
905
-
906
- /**
907
- * Configure how TSX and JSX are transformed.
908
- *
909
- * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
910
- */
911
- interface JsxOptions {
912
- /**
913
- * Decides which runtime to use.
914
- *
915
- * - 'automatic' - auto-import the correct JSX factories
916
- * - 'classic' - no auto-import
917
- *
918
- * @default 'automatic'
919
- */
920
- runtime?: 'classic' | 'automatic';
921
- /**
922
- * Emit development-specific information, such as `__source` and `__self`.
923
- *
924
- * @default false
925
- *
926
- * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
927
- */
928
- development?: boolean;
929
- /**
930
- * Toggles whether or not to throw an error if an XML namespaced tag name
931
- * is used.
932
- *
933
- * Though the JSX spec allows this, it is disabled by default since React's
934
- * JSX does not currently have support for it.
935
- *
936
- * @default true
937
- */
938
- throwIfNamespace?: boolean;
939
- /**
940
- * Enables `@babel/plugin-transform-react-pure-annotations`.
941
- *
942
- * It will mark top-level React method calls as pure for tree shaking.
943
- *
944
- * @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
945
- *
946
- * @default true
947
- */
948
- pure?: boolean;
949
- /**
950
- * Replaces the import source when importing functions.
951
- *
952
- * @default 'react'
953
- */
954
- importSource?: string;
955
- /**
956
- * Replace the function used when compiling JSX expressions. It should be a
957
- * qualified name (e.g. `React.createElement`) or an identifier (e.g.
958
- * `createElement`).
959
- *
960
- * Only used for `classic` {@link runtime}.
961
- *
962
- * @default 'React.createElement'
963
- */
964
- pragma?: string;
965
- /**
966
- * Replace the component used when compiling JSX fragments. It should be a
967
- * valid JSX tag name.
968
- *
969
- * Only used for `classic` {@link runtime}.
970
- *
971
- * @default 'React.Fragment'
972
- */
973
- pragmaFrag?: string;
974
- /**
975
- * When spreading props, use `Object.assign` directly instead of an extend helper.
976
- *
977
- * Only used for `classic` {@link runtime}.
978
- *
979
- * @default false
980
- */
981
- useBuiltIns?: boolean;
982
- /**
983
- * When spreading props, use inline object with spread elements directly
984
- * instead of an extend helper or Object.assign.
985
- *
986
- * Only used for `classic` {@link runtime}.
987
- *
988
- * @default false
989
- */
990
- useSpread?: boolean;
991
- /**
992
- * Enable React Fast Refresh .
993
- *
994
- * Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
995
- *
996
- * @default false
997
- */
998
- refresh?: boolean | ReactRefreshOptions;
1197
+ hmrBoundaries: Array<BindingHmrBoundaryOutput>;
1198
+ fullReload: boolean;
1199
+ firstInvalidatedBy?: string;
1200
+ isSelfAccepting: boolean;
1201
+ fullReloadReason?: string;
999
1202
  }
1000
-
1001
- /**
1002
- * Transform JavaScript code to a Vite Node runnable module.
1003
- *
1004
- * @param filename The name of the file being transformed.
1005
- * @param sourceText the source code itself
1006
- * @param options The options for the transformation. See {@link
1007
- * ModuleRunnerTransformOptions} for more information.
1008
- *
1009
- * @returns an object containing the transformed code, source maps, and any
1010
- * errors that occurred during parsing or transformation.
1011
- *
1012
- * @deprecated Only works for Vite.
1013
- */
1014
- declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult;
1015
- interface ModuleRunnerTransformOptions {
1016
- /**
1017
- * Enable source map generation.
1018
- *
1019
- * When `true`, the `sourceMap` field of transform result objects will be populated.
1020
- *
1021
- * @default false
1022
- *
1023
- * @see {@link SourceMap}
1024
- */
1025
- sourcemap?: boolean;
1203
+ interface BindingHookFilter {
1204
+ value?: Array<Array<BindingFilterToken>>;
1026
1205
  }
1027
- interface ModuleRunnerTransformResult {
1028
- /**
1029
- * The transformed code.
1030
- *
1031
- * If parsing failed, this will be an empty string.
1032
- */
1206
+ interface BindingHookLoadOutput {
1033
1207
  code: string;
1034
- /**
1035
- * The source map for the transformed code.
1036
- *
1037
- * This will be set if {@link TransformOptions#sourcemap} is `true`.
1038
- */
1039
- map?: SourceMap;
1040
- deps: Array<string>;
1041
- dynamicDeps: Array<string>;
1042
- /**
1043
- * Parse and transformation errors.
1044
- *
1045
- * Oxc's parser recovers from common syntax errors, meaning that
1046
- * transformed code may still be available even if there are errors in this
1047
- * list.
1048
- */
1049
- errors: Array<OxcError>;
1208
+ sideEffects?: BindingHookSideEffects;
1209
+ map?: BindingSourcemap;
1210
+ moduleType?: string;
1050
1211
  }
1051
- type ModuleType = 'module' | 'commonjs' | 'json' | 'wasm' | 'addon';
1052
-
1053
- /**
1054
- * Module Resolution Options
1055
- *
1056
- * Options are directly ported from [enhanced-resolve](https://github.com/webpack/enhanced-resolve#resolver-options).
1057
- *
1058
- * See [webpack resolve](https://webpack.js.org/configuration/resolve/) for information and examples
1059
- */
1060
- interface NapiResolveOptions {
1061
- /**
1062
- * Path to TypeScript configuration file.
1063
- *
1064
- * Default `None`
1065
- */
1066
- tsconfig?: TsconfigOptions;
1067
- /**
1068
- * Alias for [ResolveOptions::alias] and [ResolveOptions::fallback].
1069
- *
1070
- * For the second value of the tuple, `None -> AliasValue::Ignore`, Some(String) ->
1071
- * AliasValue::Path(String)`
1072
- * Create aliases to import or require certain modules more easily.
1073
- * A trailing $ can also be added to the given object's keys to signify an exact match.
1074
- */
1075
- alias?: Record<string, Array<string | undefined | null>>;
1076
- /**
1077
- * A list of alias fields in description files.
1078
- * Specify a field, such as `browser`, to be parsed according to [this specification](https://github.com/defunctzombie/package-browser-field-spec).
1079
- * Can be a path to json object such as `["path", "to", "exports"]`.
1080
- *
1081
- * Default `[]`
1082
- */
1083
- aliasFields?: (string | string[])[];
1084
- /**
1085
- * Condition names for exports field which defines entry points of a package.
1086
- * The key order in the exports field is significant. During condition matching, earlier entries have higher priority and take precedence over later entries.
1087
- *
1088
- * Default `[]`
1089
- */
1090
- conditionNames?: Array<string>;
1091
- /**
1092
- * If true, it will not allow extension-less files.
1093
- * So by default `require('./foo')` works if `./foo` has a `.js` extension,
1094
- * but with this enabled only `require('./foo.js')` will work.
1095
- *
1096
- * Default to `true` when [ResolveOptions::extensions] contains an empty string.
1097
- * Use `Some(false)` to disable the behavior.
1098
- * See <https://github.com/webpack/enhanced-resolve/pull/285>
1099
- *
1100
- * Default None, which is the same as `Some(false)` when the above empty rule is not applied.
1101
- */
1102
- enforceExtension?: EnforceExtension;
1103
- /**
1104
- * A list of exports fields in description files.
1105
- * Can be a path to json object such as `["path", "to", "exports"]`.
1106
- *
1107
- * Default `[["exports"]]`.
1108
- */
1109
- exportsFields?: (string | string[])[];
1110
- /**
1111
- * Fields from `package.json` which are used to provide the internal requests of a package
1112
- * (requests starting with # are considered internal).
1113
- *
1114
- * Can be a path to a JSON object such as `["path", "to", "imports"]`.
1115
- *
1116
- * Default `[["imports"]]`.
1117
- */
1118
- importsFields?: (string | string[])[];
1119
- /**
1120
- * An object which maps extension to extension aliases.
1121
- *
1122
- * Default `{}`
1123
- */
1124
- extensionAlias?: Record<string, Array<string>>;
1125
- /**
1126
- * Attempt to resolve these extensions in order.
1127
- * If multiple files share the same name but have different extensions,
1128
- * will resolve the one with the extension listed first in the array and skip the rest.
1129
- *
1130
- * Default `[".js", ".json", ".node"]`
1131
- */
1132
- extensions?: Array<string>;
1133
- /**
1134
- * Redirect module requests when normal resolving fails.
1135
- *
1136
- * Default `[]`
1137
- */
1138
- fallback?: Record<string, Array<string | undefined | null>>;
1139
- /**
1140
- * Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests).
1141
- *
1142
- * See also webpack configuration [resolve.fullySpecified](https://webpack.js.org/configuration/module/#resolvefullyspecified)
1143
- *
1144
- * Default `false`
1145
- */
1146
- fullySpecified?: boolean;
1147
- /**
1148
- * A list of main fields in description files
1149
- *
1150
- * Default `["main"]`.
1151
- */
1152
- mainFields?: string | string[];
1153
- /**
1154
- * The filename to be used while resolving directories.
1155
- *
1156
- * Default `["index"]`
1157
- */
1158
- mainFiles?: Array<string>;
1159
- /**
1160
- * A list of directories to resolve modules from, can be absolute path or folder name.
1161
- *
1162
- * Default `["node_modules"]`
1163
- */
1164
- modules?: string | string[];
1165
- /**
1166
- * Resolve to a context instead of a file.
1167
- *
1168
- * Default `false`
1169
- */
1170
- resolveToContext?: boolean;
1171
- /**
1172
- * Prefer to resolve module requests as relative requests instead of using modules from node_modules directories.
1173
- *
1174
- * Default `false`
1175
- */
1176
- preferRelative?: boolean;
1177
- /**
1178
- * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in ResolveOptions::roots.
1179
- *
1180
- * Default `false`
1181
- */
1182
- preferAbsolute?: boolean;
1183
- /**
1184
- * A list of resolve restrictions to restrict the paths that a request can be resolved on.
1185
- *
1186
- * Default `[]`
1187
- */
1188
- restrictions?: Array<Restriction>;
1189
- /**
1190
- * A list of directories where requests of server-relative URLs (starting with '/') are resolved.
1191
- * On non-Windows systems these requests are resolved as an absolute path first.
1192
- *
1193
- * Default `[]`
1194
- */
1195
- roots?: Array<string>;
1196
- /**
1197
- * Whether to resolve symlinks to their symlinked location.
1198
- * When enabled, symlinked resources are resolved to their real path, not their symlinked location.
1199
- * Note that this may cause module resolution to fail when using tools that symlink packages (like npm link).
1200
- *
1201
- * Default `true`
1202
- */
1203
- symlinks?: boolean;
1204
- /**
1205
- * Whether to parse [module.builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules) or not.
1206
- * For example, "zlib" will throw [crate::ResolveError::Builtin] when set to true.
1207
- *
1208
- * Default `false`
1209
- */
1210
- builtinModules?: boolean;
1212
+ interface BindingHookRenderChunkOutput {
1213
+ code: string;
1214
+ map?: BindingSourcemap;
1215
+ }
1216
+ interface BindingHookResolveIdExtraArgs {
1217
+ custom?: number;
1218
+ isEntry: boolean;
1211
1219
  /**
1212
- * Resolve [ResolveResult::moduleType].
1213
- *
1214
- * Default `false`
1220
+ * - `import-statement`: `import { foo } from './lib.js';`
1221
+ * - `dynamic-import`: `import('./lib.js')`
1222
+ * - `require-call`: `require('./lib.js')`
1223
+ * - `import-rule`: `@import 'bg-color.css'`
1224
+ * - `url-token`: `url('./icon.png')`
1225
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
1226
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
1215
1227
  */
1216
- moduleType?: boolean;
1228
+ kind: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
1229
+ }
1230
+ interface BindingHookResolveIdOutput {
1231
+ id: string;
1232
+ external?: BindingResolvedExternal;
1233
+ normalizeExternalId?: boolean;
1234
+ sideEffects?: BindingHookSideEffects;
1235
+ }
1236
+ declare enum BindingHookSideEffects {
1237
+ True = 0,
1238
+ False = 1,
1239
+ NoTreeshake = 2,
1240
+ }
1241
+ interface BindingHookTransformOutput {
1242
+ code?: string;
1243
+ sideEffects?: BindingHookSideEffects;
1244
+ map?: BindingSourcemap;
1245
+ moduleType?: string;
1246
+ }
1247
+ interface BindingImportGlobPluginConfig {
1248
+ root?: string;
1249
+ restoreQueryExtension?: boolean;
1217
1250
  }
1218
- interface OxcError {
1219
- severity: Severity;
1251
+ interface BindingInjectImportNamed {
1252
+ tagNamed: true;
1253
+ imported: string;
1254
+ alias?: string;
1255
+ from: string;
1256
+ }
1257
+ interface BindingInjectImportNamespace {
1258
+ tagNamespace: true;
1259
+ alias: string;
1260
+ from: string;
1261
+ }
1262
+ interface BindingInputItem {
1263
+ name?: string;
1264
+ import: string;
1265
+ }
1266
+ interface BindingInputOptions {
1267
+ external?: undefined | ((source: string, importer: string | undefined, isResolved: boolean) => boolean);
1268
+ input: Array<BindingInputItem>;
1269
+ plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[];
1270
+ resolve?: BindingResolveOptions;
1271
+ shimMissingExports?: boolean;
1272
+ platform?: 'node' | 'browser' | 'neutral';
1273
+ logLevel: BindingLogLevel;
1274
+ onLog: (logLevel: 'debug' | 'warn' | 'info', log: BindingLog) => void;
1275
+ cwd: string;
1276
+ treeshake?: BindingTreeshake;
1277
+ moduleTypes?: Record<string, string>;
1278
+ define?: Array<[string, string]>;
1279
+ dropLabels?: Array<string>;
1280
+ inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>;
1281
+ experimental?: BindingExperimentalOptions;
1282
+ profilerNames?: boolean;
1283
+ jsx?: BindingJsx;
1284
+ transform?: TransformOptions;
1285
+ watch?: BindingWatchOption;
1286
+ keepNames?: boolean;
1287
+ checks?: BindingChecksOptions;
1288
+ deferSyncScanData?: undefined | (() => BindingDeferSyncScanData[]);
1289
+ makeAbsoluteExternalsRelative?: BindingMakeAbsoluteExternalsRelative;
1290
+ debug?: BindingDebugOptions;
1291
+ invalidateJsSideCache?: () => void;
1292
+ markModuleLoaded?: (id: string, success: boolean) => void;
1293
+ }
1294
+ interface BindingIsolatedDeclarationPluginConfig {
1295
+ stripInternal?: boolean;
1296
+ }
1297
+ interface BindingJsonPluginConfig {
1298
+ minify?: boolean;
1299
+ namedExports?: boolean;
1300
+ stringify?: BindingJsonPluginStringify;
1301
+ }
1302
+ type BindingJsonPluginStringify = boolean | string;
1303
+ interface BindingJsonSourcemap {
1304
+ file?: string;
1305
+ mappings?: string;
1306
+ sourceRoot?: string;
1307
+ sources?: Array<string | undefined | null>;
1308
+ sourcesContent?: Array<string | undefined | null>;
1309
+ names?: Array<string>;
1310
+ debugId?: string;
1311
+ x_google_ignoreList?: Array<number>;
1312
+ }
1313
+ declare enum BindingJsx {
1314
+ Disable = 0,
1315
+ Preserve = 1,
1316
+ React = 2,
1317
+ ReactJsx = 3,
1318
+ }
1319
+ interface BindingLog {
1320
+ code: string;
1220
1321
  message: string;
1221
- labels: Array<ErrorLabel>;
1222
- helpMessage?: string;
1223
- codeframe?: string;
1322
+ id?: string;
1323
+ exporter?: string;
1224
1324
  }
1225
-
1226
- /**
1227
- * Parse asynchronously.
1228
- *
1229
- * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
1230
- */
1231
-
1232
- interface ParserOptions {
1233
- /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1234
- lang?: 'js' | 'jsx' | 'ts' | 'tsx';
1235
- /** Treat the source text as `script` or `module` code. */
1236
- sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
1237
- /**
1238
- * Return an AST which includes TypeScript-related properties, or excludes them.
1239
- *
1240
- * `'js'` is default for JS / JSX files.
1241
- * `'ts'` is default for TS / TSX files.
1242
- * The type of the file is determined from `lang` option, or extension of provided `filename`.
1243
- */
1244
- astType?: 'js' | 'ts';
1245
- /**
1246
- * Emit `ParenthesizedExpression` and `TSParenthesizedType` in AST.
1247
- *
1248
- * If this option is true, parenthesized expressions are represented by
1249
- * (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` nodes that
1250
- * have a single `expression` property containing the expression inside parentheses.
1251
- *
1252
- * @default true
1253
- */
1254
- preserveParens?: boolean;
1325
+ declare enum BindingLogLevel {
1326
+ Silent = 0,
1327
+ Warn = 1,
1328
+ Info = 2,
1329
+ Debug = 3,
1330
+ }
1331
+ type BindingMakeAbsoluteExternalsRelative = {
1332
+ type: 'Bool';
1333
+ field0: boolean;
1334
+ } | {
1335
+ type: 'IfRelativeSource';
1336
+ };
1337
+ interface BindingManifestPluginConfig {
1338
+ root: string;
1339
+ outPath: string;
1340
+ }
1341
+ interface BindingMatchGroup {
1342
+ name: string;
1343
+ test?: string | RegExp | ((id: string) => VoidNullable<boolean>);
1344
+ priority?: number;
1345
+ minSize?: number;
1346
+ minShareCount?: number;
1347
+ minModuleSize?: number;
1348
+ maxModuleSize?: number;
1349
+ maxSize?: number;
1350
+ }
1351
+ interface BindingMfManifest {
1352
+ filePath?: string;
1353
+ disableAssetsAnalyze?: boolean;
1354
+ fileName?: string;
1355
+ }
1356
+ interface BindingMinifyOptions {
1357
+ mangle?: boolean;
1358
+ compress?: boolean;
1359
+ removeWhitespace?: boolean;
1360
+ }
1361
+ interface BindingModuleFederationPluginOption {
1362
+ name: string;
1363
+ filename?: string;
1364
+ exposes?: Record<string, string>;
1365
+ remotes?: Array<BindingRemote>;
1366
+ shared?: Record<string, BindingShared>;
1367
+ runtimePlugins?: Array<string>;
1368
+ manifest?: BindingMfManifest;
1369
+ getPublicPath?: string;
1370
+ }
1371
+ interface BindingModules {
1372
+ values: Array<BindingRenderedModule>;
1373
+ keys: Array<string>;
1374
+ }
1375
+ interface BindingModuleSideEffectsRule {
1376
+ test?: RegExp | undefined;
1377
+ sideEffects: boolean;
1378
+ external?: boolean | undefined;
1379
+ }
1380
+ interface BindingOutputOptions {
1381
+ name?: string;
1382
+ assetFileNames?: string | ((chunk: BindingPreRenderedAsset) => string);
1383
+ entryFileNames?: string | ((chunk: PreRenderedChunk) => string);
1384
+ chunkFileNames?: string | ((chunk: PreRenderedChunk) => string);
1385
+ cssEntryFileNames?: string | ((chunk: PreRenderedChunk) => string);
1386
+ cssChunkFileNames?: string | ((chunk: PreRenderedChunk) => string);
1387
+ sanitizeFileName?: boolean | ((name: string) => string);
1388
+ banner?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
1389
+ dir?: string;
1390
+ file?: string;
1391
+ esModule?: boolean | 'if-default-prop';
1392
+ exports?: 'default' | 'named' | 'none' | 'auto';
1393
+ extend?: boolean;
1394
+ externalLiveBindings?: boolean;
1395
+ footer?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
1396
+ format?: 'es' | 'cjs' | 'iife' | 'umd' | 'app';
1397
+ globals?: Record<string, string> | ((name: string) => string);
1398
+ hashCharacters?: 'base64' | 'base36' | 'hex';
1399
+ inlineDynamicImports?: boolean;
1400
+ intro?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
1401
+ outro?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
1402
+ plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[];
1403
+ sourcemap?: 'file' | 'inline' | 'hidden';
1404
+ sourcemapIgnoreList?: (source: string, sourcemapPath: string) => boolean;
1405
+ sourcemapDebugIds?: boolean;
1406
+ sourcemapPathTransform?: (source: string, sourcemapPath: string) => string;
1407
+ minify?: boolean | 'dce-only' | BindingMinifyOptions;
1408
+ advancedChunks?: BindingAdvancedChunksOptions;
1409
+ legalComments?: 'none' | 'inline';
1410
+ polyfillRequire?: boolean;
1411
+ preserveModules?: boolean;
1412
+ virtualDirname?: string;
1413
+ preserveModulesRoot?: string;
1414
+ preserveEntrySignatures?: 'strict' | 'allow-extension' | 'exports-only' | false;
1415
+ }
1416
+ interface BindingPluginContextResolvedId {
1417
+ id: string;
1418
+ external: boolean | 'absolute' | 'relative';
1419
+ }
1420
+ interface BindingPluginContextResolveOptions {
1255
1421
  /**
1256
- * Produce semantic errors with an additional AST pass.
1257
- * Semantic errors depend on symbols and scopes, where the parser does not construct.
1258
- * This adds a small performance overhead.
1259
- *
1260
- * @default false
1422
+ * - `import-statement`: `import { foo } from './lib.js';`
1423
+ * - `dynamic-import`: `import('./lib.js')`
1424
+ * - `require-call`: `require('./lib.js')`
1425
+ * - `import-rule`: `@import 'bg-color.css'`
1426
+ * - `url-token`: `url('./icon.png')`
1427
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
1428
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
1261
1429
  */
1262
- showSemanticErrors?: boolean;
1430
+ importKind?: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
1431
+ skipSelf?: boolean;
1432
+ custom?: number;
1433
+ }
1434
+ interface BindingPluginHookMeta {
1435
+ order?: BindingPluginOrder;
1436
+ }
1437
+ interface BindingPluginOptions {
1438
+ name: string;
1439
+ hookUsage: number;
1440
+ buildStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable>;
1441
+ buildStartMeta?: BindingPluginHookMeta;
1442
+ resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>;
1443
+ resolveIdMeta?: BindingPluginHookMeta;
1444
+ resolveIdFilter?: BindingHookFilter;
1445
+ resolveDynamicImport?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>;
1446
+ resolveDynamicImportMeta?: BindingPluginHookMeta;
1447
+ load?: (ctx: BindingPluginContext, id: string) => MaybePromise<VoidNullable<BindingHookLoadOutput>>;
1448
+ loadMeta?: BindingPluginHookMeta;
1449
+ loadFilter?: BindingHookFilter;
1450
+ transform?: (ctx: BindingTransformPluginContext, id: string, code: string, module_type: BindingTransformHookExtraArgs) => MaybePromise<VoidNullable<BindingHookTransformOutput>>;
1451
+ transformMeta?: BindingPluginHookMeta;
1452
+ transformFilter?: BindingHookFilter;
1453
+ moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>;
1454
+ moduleParsedMeta?: BindingPluginHookMeta;
1455
+ buildEnd?: (ctx: BindingPluginContext, error?: (Error | BindingError)[]) => MaybePromise<VoidNullable>;
1456
+ buildEndMeta?: BindingPluginHookMeta;
1457
+ renderChunk?: (ctx: BindingPluginContext, code: string, chunk: BindingRenderedChunk, opts: BindingNormalizedOptions, meta: BindingRenderedChunkMeta) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>;
1458
+ renderChunkMeta?: BindingPluginHookMeta;
1459
+ renderChunkFilter?: BindingHookFilter;
1460
+ augmentChunkHash?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => MaybePromise<void | string>;
1461
+ augmentChunkHashMeta?: BindingPluginHookMeta;
1462
+ renderStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => void;
1463
+ renderStartMeta?: BindingPluginHookMeta;
1464
+ renderError?: (ctx: BindingPluginContext, error: (Error | BindingError)[]) => void;
1465
+ renderErrorMeta?: BindingPluginHookMeta;
1466
+ generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>;
1467
+ generateBundleMeta?: BindingPluginHookMeta;
1468
+ writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>;
1469
+ writeBundleMeta?: BindingPluginHookMeta;
1470
+ closeBundle?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>;
1471
+ closeBundleMeta?: BindingPluginHookMeta;
1472
+ watchChange?: (ctx: BindingPluginContext, path: string, event: string) => MaybePromise<VoidNullable>;
1473
+ watchChangeMeta?: BindingPluginHookMeta;
1474
+ closeWatcher?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>;
1475
+ closeWatcherMeta?: BindingPluginHookMeta;
1476
+ banner?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
1477
+ bannerMeta?: BindingPluginHookMeta;
1478
+ footer?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
1479
+ footerMeta?: BindingPluginHookMeta;
1480
+ intro?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
1481
+ introMeta?: BindingPluginHookMeta;
1482
+ outro?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
1483
+ outroMeta?: BindingPluginHookMeta;
1263
1484
  }
1264
-
1265
- /** Parse synchronously. */
1266
-
1267
- interface PreRenderedChunk {
1485
+ declare enum BindingPluginOrder {
1486
+ Pre = 0,
1487
+ Post = 1,
1488
+ }
1489
+ interface BindingPreRenderedAsset {
1490
+ names: Array<string>;
1491
+ originalFileNames: Array<string>;
1492
+ source: BindingAssetSource;
1493
+ }
1494
+ interface BindingRemote {
1495
+ type?: string;
1496
+ entry: string;
1268
1497
  name: string;
1269
- isEntry: boolean;
1270
- isDynamicEntry: boolean;
1271
- facadeModuleId?: string;
1272
- moduleIds: Array<string>;
1273
- exports: Array<string>;
1498
+ entryGlobalName?: string;
1499
+ shareScope?: string;
1274
1500
  }
1275
-
1276
- /** Returns `true` if raw transfer is supported on this platform. */
1277
-
1278
- interface ReactRefreshOptions {
1279
- /**
1280
- * Specify the identifier of the refresh registration variable.
1281
- *
1282
- * @default `$RefreshReg$`.
1283
- */
1284
- refreshReg?: string;
1285
- /**
1286
- * Specify the identifier of the refresh signature variable.
1287
- *
1288
- * @default `$RefreshSig$`.
1289
- */
1290
- refreshSig?: string;
1291
- emitFullSignatures?: boolean;
1501
+ interface BindingReplacePluginConfig {
1502
+ values: Record<string, string>;
1503
+ delimiters?: [string, string];
1504
+ preventAssignment?: boolean;
1505
+ objectGuards?: boolean;
1506
+ sourcemap?: boolean;
1292
1507
  }
1293
- interface ResolveResult {
1294
- path?: string;
1295
- error?: string;
1296
- /**
1297
- * Module type for this path.
1298
- *
1299
- * Enable with `ResolveOptions#moduleType`.
1300
- *
1301
- * The module type is computed `ESM_FILE_FORMAT` from the [ESM resolution algorithm specification](https://nodejs.org/docs/latest/api/esm.html#resolution-algorithm-specification).
1302
- *
1303
- * The algorithm uses the file extension or finds the closest `package.json` with the `type` field.
1304
- */
1305
- moduleType?: ModuleType;
1306
- /** `package.json` path for the given module. */
1307
- packageJsonPath?: string;
1508
+ interface BindingReporterPluginConfig {
1509
+ isTty: boolean;
1510
+ isLib: boolean;
1511
+ assetsDir: string;
1512
+ chunkLimit: number;
1513
+ shouldLogInfo: boolean;
1514
+ reportCompressedSize: boolean;
1308
1515
  }
1309
-
1310
- /**
1311
- * Alias Value for [ResolveOptions::alias] and [ResolveOptions::fallback].
1312
- * Use struct because napi don't support structured union now
1313
- */
1314
- interface Restriction {
1315
- path?: string;
1316
- regex?: string;
1516
+ type BindingResolvedExternal = boolean | string;
1517
+ interface BindingResolveOptions {
1518
+ alias?: Array<AliasItem>;
1519
+ aliasFields?: Array<Array<string>>;
1520
+ conditionNames?: Array<string>;
1521
+ exportsFields?: Array<Array<string>>;
1522
+ extensions?: Array<string>;
1523
+ extensionAlias?: Array<ExtensionAliasItem>;
1524
+ mainFields?: Array<string>;
1525
+ mainFiles?: Array<string>;
1526
+ modules?: Array<string>;
1527
+ symlinks?: boolean;
1528
+ tsconfigFilename?: string;
1317
1529
  }
1318
- type Severity = 'Error' | 'Warning' | 'Advice';
1319
-
1320
- /**
1321
- * Shutdown the tokio runtime manually.
1322
- *
1323
- * This is required for the wasm target with `tokio_unstable` cfg.
1324
- * In the wasm runtime, the `park` threads will hang there until the tokio::Runtime is shutdown.
1325
- */
1326
-
1327
- interface SourceMap {
1328
- file?: string;
1329
- mappings: string;
1330
- names: Array<string>;
1331
- sourceRoot?: string;
1332
- sources: Array<string>;
1333
- sourcesContent?: Array<string>;
1334
- version: number;
1335
- x_google_ignoreList?: Array<number>;
1530
+ interface BindingShared {
1531
+ version?: string;
1532
+ shareScope?: string;
1533
+ singleton?: boolean;
1534
+ requiredVersion?: string;
1535
+ strictVersion?: boolean;
1336
1536
  }
1337
- interface Span {
1338
- start: number;
1339
- end: number;
1537
+ interface BindingSourcemap {
1538
+ inner: string | BindingJsonSourcemap;
1340
1539
  }
1341
-
1342
- /**
1343
- * Start the async runtime manually.
1344
- *
1345
- * This is required when the async runtime is shutdown manually.
1346
- * Usually it's used in test.
1347
- */
1348
-
1349
- interface StaticExport {
1350
- start: number;
1351
- end: number;
1352
- entries: Array<StaticExportEntry>;
1540
+ interface BindingTransformHookExtraArgs {
1541
+ moduleType: string;
1353
1542
  }
1354
- interface StaticExportEntry {
1355
- start: number;
1356
- end: number;
1357
- moduleRequest?: ValueSpan;
1358
- /** The name under which the desired binding is exported by the module`. */
1359
- importName: ExportImportName;
1360
- /** The name used to export this binding by this module. */
1361
- exportName: ExportExportName;
1362
- /** The name that is used to locally access the exported value from within the importing module. */
1363
- localName: ExportLocalName;
1364
- /**
1365
- * Whether the export is a TypeScript `export type`.
1366
- *
1367
- * Examples:
1368
- *
1369
- * ```ts
1370
- * export type * from 'mod';
1371
- * export type * as ns from 'mod';
1372
- * export type { foo };
1373
- * export { type foo }:
1374
- * export type { foo } from 'mod';
1375
- * ```
1376
- */
1377
- isType: boolean;
1543
+ interface BindingTransformPluginConfig {
1544
+ include?: Array<BindingStringOrRegex>;
1545
+ exclude?: Array<BindingStringOrRegex>;
1546
+ jsxRefreshInclude?: Array<BindingStringOrRegex>;
1547
+ jsxRefreshExclude?: Array<BindingStringOrRegex>;
1548
+ isServerConsumer?: boolean;
1549
+ runtimeResolveBase?: string;
1550
+ jsxInject?: string;
1551
+ transformOptions?: TransformOptions;
1378
1552
  }
1379
- interface StaticImport {
1380
- /** Start of import statement. */
1381
- start: number;
1382
- /** End of import statement. */
1383
- end: number;
1384
- /**
1385
- * Import source.
1386
- *
1387
- * ```js
1388
- * import { foo } from "mod";
1389
- * // ^^^
1390
- * ```
1391
- */
1392
- moduleRequest: ValueSpan;
1393
- /**
1394
- * Import specifiers.
1395
- *
1396
- * Empty for `import "mod"`.
1397
- */
1398
- entries: Array<StaticImportEntry>;
1553
+ interface BindingTreeshake {
1554
+ moduleSideEffects: boolean | BindingModuleSideEffectsRule[] | ((id: string, is_external: boolean) => boolean | undefined);
1555
+ annotations?: boolean;
1556
+ manualPureFunctions?: Array<string>;
1557
+ unknownGlobalSideEffects?: boolean;
1399
1558
  }
1400
- interface StaticImportEntry {
1401
- /**
1402
- * The name under which the desired binding is exported by the module.
1403
- *
1404
- * ```js
1405
- * import { foo } from "mod";
1406
- * // ^^^
1407
- * import { foo as bar } from "mod";
1408
- * // ^^^
1409
- * ```
1410
- */
1411
- importName: ImportName;
1412
- /**
1413
- * The name that is used to locally access the imported value from within the importing module.
1414
- * ```js
1415
- * import { foo } from "mod";
1416
- * // ^^^
1417
- * import { foo as bar } from "mod";
1418
- * // ^^^
1419
- * ```
1420
- */
1421
- localName: ValueSpan;
1422
- /**
1423
- * Whether this binding is for a TypeScript type-only import.
1424
- *
1425
- * `true` for the following imports:
1426
- * ```ts
1427
- * import type { foo } from "mod";
1428
- * import { type foo } from "mod";
1429
- * ```
1430
- */
1431
- isType: boolean;
1559
+ interface BindingViteResolvePluginConfig {
1560
+ resolveOptions: BindingViteResolvePluginResolveOptions;
1561
+ environmentConsumer: string;
1562
+ environmentName: string;
1563
+ builtins: Array<BindingStringOrRegex>;
1564
+ external: true | string[];
1565
+ noExternal: true | Array<string | RegExp>;
1566
+ dedupe: Array<string>;
1567
+ finalizeBareSpecifier?: (resolvedId: string, rawId: string, importer: string | null | undefined) => VoidNullable<string>;
1568
+ finalizeOtherSpecifiers?: (resolvedId: string, rawId: string) => VoidNullable<string>;
1569
+ }
1570
+ interface BindingViteResolvePluginResolveOptions {
1571
+ isBuild: boolean;
1572
+ isProduction: boolean;
1573
+ asSrc: boolean;
1574
+ preferRelative: boolean;
1575
+ isRequire?: boolean;
1576
+ root: string;
1577
+ scan: boolean;
1578
+ mainFields: Array<string>;
1579
+ conditions: Array<string>;
1580
+ externalConditions: Array<string>;
1581
+ extensions: Array<string>;
1582
+ tryIndex: boolean;
1583
+ tryPrefix?: string;
1584
+ preserveSymlinks: boolean;
1432
1585
  }
1433
- /**
1434
- * Transpile a JavaScript or TypeScript into a target ECMAScript version.
1435
- *
1436
- * @param filename The name of the file being transformed. If this is a
1437
- * relative path, consider setting the {@link TransformOptions#cwd} option..
1438
- * @param sourceText the source code itself
1439
- * @param options The options for the transformation. See {@link
1440
- * TransformOptions} for more information.
1441
- *
1442
- * @returns an object containing the transformed code, source maps, and any
1443
- * errors that occurred during parsing or transformation.
1444
- */
1445
- declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult;
1446
-
1447
- /**
1448
- * Options for transforming a JavaScript or TypeScript file.
1449
- *
1450
- * @see {@link transform}
1451
- */
1452
- interface TransformOptions {
1453
- /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1454
- lang?: 'js' | 'jsx' | 'ts' | 'tsx';
1455
- /** Treat the source text as `script` or `module` code. */
1456
- sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
1457
- /**
1458
- * The current working directory. Used to resolve relative paths in other
1459
- * options.
1460
- */
1461
- cwd?: string;
1462
- /**
1463
- * Enable source map generation.
1464
- *
1465
- * When `true`, the `sourceMap` field of transform result objects will be populated.
1466
- *
1467
- * @default false
1468
- *
1469
- * @see {@link SourceMap}
1470
- */
1471
- sourcemap?: boolean;
1472
- /** Set assumptions in order to produce smaller output. */
1473
- assumptions?: CompilerAssumptions;
1474
- /** Configure how TypeScript is transformed. */
1475
- typescript?: TypeScriptOptions;
1476
- /** Configure how TSX and JSX are transformed. */
1477
- jsx?: 'preserve' | JsxOptions;
1478
- /**
1479
- * Sets the target environment for the generated JavaScript.
1480
- *
1481
- * The lowest target is `es2015`.
1482
- *
1483
- * Example:
1484
- *
1485
- * * 'es2015'
1486
- * * ['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']
1487
- *
1488
- * @default `esnext` (No transformation)
1489
- *
1490
- * @see [esbuild#target](https://esbuild.github.io/api/#target)
1491
- */
1492
- target?: string | Array<string>;
1493
- /** Behaviour for runtime helpers. */
1494
- helpers?: Helpers;
1495
- /** Define Plugin */
1496
- define?: Record<string, string>;
1497
- /** Inject Plugin */
1498
- inject?: Record<string, string | [string, string]>;
1499
- /** Decorator plugin */
1500
- decorator?: DecoratorOptions;
1586
+ interface BindingWatchOption {
1587
+ skipWrite?: boolean;
1588
+ include?: Array<BindingStringOrRegex>;
1589
+ exclude?: Array<BindingStringOrRegex>;
1590
+ buildDelay?: number;
1501
1591
  }
1502
- interface TransformResult {
1503
- /**
1504
- * The transformed code.
1505
- *
1506
- * If parsing failed, this will be an empty string.
1507
- */
1508
- code: string;
1509
- /**
1510
- * The source map for the transformed code.
1511
- *
1512
- * This will be set if {@link TransformOptions#sourcemap} is `true`.
1513
- */
1514
- map?: SourceMap;
1515
- /**
1516
- * The `.d.ts` declaration file for the transformed code. Declarations are
1517
- * only generated if `declaration` is set to `true` and a TypeScript file
1518
- * is provided.
1519
- *
1520
- * If parsing failed and `declaration` is set, this will be an empty string.
1521
- *
1522
- * @see {@link TypeScriptOptions#declaration}
1523
- * @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
1524
- */
1525
- declaration?: string;
1526
- /**
1527
- * Declaration source map. Only generated if both
1528
- * {@link TypeScriptOptions#declaration declaration} and
1529
- * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
1530
- */
1531
- declarationMap?: SourceMap;
1532
- /**
1533
- * Helpers used.
1534
- *
1535
- * @internal
1536
- *
1537
- * Example:
1538
- *
1539
- * ```text
1540
- * { "_objectSpread": "@oxc-project/runtime/helpers/objectSpread2" }
1541
- * ```
1542
- */
1543
- helpersUsed: Record<string, string>;
1544
- /**
1545
- * Parse and transformation errors.
1546
- *
1547
- * Oxc's parser recovers from common syntax errors, meaning that
1548
- * transformed code may still be available even if there are errors in this
1549
- * list.
1550
- */
1551
- errors: Array<OxcError>;
1592
+ interface ExtensionAliasItem {
1593
+ target: string;
1594
+ replacements: Array<string>;
1552
1595
  }
1553
-
1554
- /**
1555
- * Tsconfig Options
1556
- *
1557
- * Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options)
1558
- */
1559
- interface TsconfigOptions {
1560
- /**
1561
- * Allows you to specify where to find the TypeScript configuration file.
1562
- * You may provide
1563
- * * a relative path to the configuration file. It will be resolved relative to cwd.
1564
- * * an absolute path to the configuration file.
1565
- */
1566
- configFile: string;
1567
- /**
1568
- * Support for Typescript Project References.
1569
- *
1570
- * * `'auto'`: use the `references` field from tsconfig of `config_file`.
1571
- * * `string[]`: manually provided relative or absolute path.
1572
- */
1573
- references?: 'auto' | string[];
1596
+ type FilterTokenKind = 'Id' | 'Code' | 'ModuleType' | 'And' | 'Or' | 'Not' | 'Include' | 'Exclude' | 'CleanUrl' | 'QueryKey' | 'QueryValue';
1597
+ interface JsChangedOutputs {
1598
+ chunks: Array<JsOutputChunk>;
1599
+ assets: Array<JsOutputAsset>;
1600
+ deleted: Array<string>;
1574
1601
  }
1575
- interface TypeScriptOptions {
1576
- jsxPragma?: string;
1577
- jsxPragmaFrag?: string;
1578
- onlyRemoveTypeImports?: boolean;
1579
- allowNamespaces?: boolean;
1580
- /**
1581
- * When enabled, type-only class fields are only removed if they are prefixed with the declare modifier:
1582
- *
1583
- * @deprecated
1584
- *
1585
- * Allowing `declare` fields is built-in support in Oxc without any option. If you want to remove class fields
1586
- * without initializer, you can use `remove_class_fields_without_initializer: true` instead.
1587
- */
1588
- allowDeclareFields?: boolean;
1589
- /**
1590
- * When enabled, class fields without initializers are removed.
1591
- *
1592
- * For example:
1593
- * ```ts
1594
- * class Foo {
1595
- * x: number;
1596
- * y: number = 0;
1597
- * }
1598
- * ```
1599
- * // transform into
1600
- * ```js
1601
- * class Foo {
1602
- * x: number;
1603
- * }
1604
- * ```
1605
- *
1606
- * The option is used to align with the behavior of TypeScript's `useDefineForClassFields: false` option.
1607
- * When you want to enable this, you also need to set [`crate::CompilerAssumptions::set_public_class_fields`]
1608
- * to `true`. The `set_public_class_fields: true` + `remove_class_fields_without_initializer: true` is
1609
- * equivalent to `useDefineForClassFields: false` in TypeScript.
1610
- *
1611
- * When `set_public_class_fields` is true and class-properties plugin is enabled, the above example transforms into:
1612
- *
1613
- * ```js
1614
- * class Foo {
1615
- * constructor() {
1616
- * this.y = 0;
1617
- * }
1618
- * }
1619
- * ```
1620
- *
1621
- * Defaults to `false`.
1622
- */
1623
- removeClassFieldsWithoutInitializer?: boolean;
1624
- /**
1625
- * Also generate a `.d.ts` declaration file for TypeScript files.
1626
- *
1627
- * The source file must be compliant with all
1628
- * [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
1629
- * requirements.
1630
- *
1631
- * @default false
1632
- */
1633
- declaration?: IsolatedDeclarationsOptions;
1634
- /**
1635
- * Rewrite or remove TypeScript import/export declaration extensions.
1636
- *
1637
- * - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
1638
- * - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
1639
- * - When set to `true`, it's equivalent to `rewrite`.
1640
- * - When set to `false` or omitted, no changes will be made to the extensions.
1641
- *
1642
- * @default false
1643
- */
1644
- rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
1602
+ interface JsOutputAsset {
1603
+ names: Array<string>;
1604
+ originalFileNames: Array<string>;
1605
+ filename: string;
1606
+ source: BindingAssetSource;
1645
1607
  }
1646
- interface ValueSpan {
1647
- value: string;
1648
- start: number;
1649
- end: number;
1608
+ interface JsOutputChunk {
1609
+ name: string;
1610
+ isEntry: boolean;
1611
+ isDynamicEntry: boolean;
1612
+ facadeModuleId?: string;
1613
+ moduleIds: Array<string>;
1614
+ exports: Array<string>;
1615
+ filename: string;
1616
+ modules: Record<string, BindingRenderedModule>;
1617
+ imports: Array<string>;
1618
+ dynamicImports: Array<string>;
1619
+ code: string;
1620
+ map?: BindingSourcemap;
1621
+ sourcemapFilename?: string;
1622
+ preliminaryFilename: string;
1623
+ }
1624
+ interface PreRenderedChunk {
1625
+ name: string;
1626
+ isEntry: boolean;
1627
+ isDynamicEntry: boolean;
1628
+ facadeModuleId?: string;
1629
+ moduleIds: Array<string>;
1630
+ exports: Array<string>;
1650
1631
  }
1651
1632
  //#endregion
1652
1633
  export { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingDynamicImportVarsPluginConfig, BindingHmrOutput, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingMinifyOptions, BindingModuleFederationPluginOption, BindingRemote, BindingRenderedChunk, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWatcherEvent, Bundler, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ParseResult, ParserOptions, PreRenderedChunk, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform };