@rspack/binding 0.5.7 → 0.5.8

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 (2) hide show
  1. package/binding.d.ts +81 -80
  2. package/package.json +10 -10
package/binding.d.ts CHANGED
@@ -63,40 +63,12 @@ export class JsStats {
63
63
  }
64
64
 
65
65
  export class Rspack {
66
- constructor(options: RawOptions, builtinPlugins: Array<BuiltinPlugin>, jsHooks: JsHooks, registerJsTaps: RegisterJsTaps, outputFilesystem: ThreadsafeNodeFS, jsLoaderRunner: (...args: any[]) => any)
67
- unsafe_set_disabled_hooks(hooks: Array<string>): void
68
- /**
69
- * Build with the given option passed to the constructor
70
- *
71
- * Warning:
72
- * Calling this method recursively might cause a deadlock.
73
- */
74
- unsafe_build(callback: (err: null | Error) => void): void
75
- /**
76
- * Rebuild with the given option passed to the constructor
77
- *
78
- * Warning:
79
- * Calling this method recursively will cause a deadlock.
80
- */
81
- unsafe_rebuild(changed_files: string[], removed_files: string[], callback: (err: null | Error) => void): void
82
- /**
83
- * Get the last compilation
84
- *
85
- * Warning:
86
- *
87
- * Calling this method under the build or rebuild method might cause a deadlock.
88
- *
89
- * **Note** that this method is not safe if you cache the _JsCompilation_ on the Node side, as it will be invalidated by the next build and accessing a dangling ptr is a UB.
90
- */
91
- unsafe_last_compilation(f: (arg0: JsCompilation) => void): void
92
- /**
93
- * Destroy the compiler
94
- *
95
- * Warning:
96
- *
97
- * Anything related to this compiler will be invalidated after this method is called.
98
- */
99
- unsafe_drop(): void
66
+ constructor(options: RawOptions, builtinPlugins: Array<BuiltinPlugin>, jsHooks: JsHooks, registerJsTaps: RegisterJsTaps, outputFilesystem: ThreadsafeNodeFS)
67
+ setDisabledHooks(hooks: Array<string>): void
68
+ /** Build with the given option passed to the constructor */
69
+ build(callback: (err: null | Error) => void): void
70
+ /** Rebuild with the given option passed to the constructor */
71
+ rebuild(changed_files: string[], removed_files: string[], callback: (err: null | Error) => void): void
100
72
  }
101
73
 
102
74
  export function __chunk_graph_inner_get_chunk_entry_dependent_chunks_iterable(jsChunkUkey: number, compilation: JsCompilation): Array<JsChunk>
@@ -123,6 +95,12 @@ export function __chunk_inner_is_only_initial(jsChunkUkey: number, compilation:
123
95
 
124
96
  export function __entrypoint_inner_get_runtime_chunk(ukey: number, compilation: JsCompilation): JsChunk
125
97
 
98
+ export interface AfterResolveCreateData {
99
+ request: string
100
+ userRequest: string
101
+ resource: string
102
+ }
103
+
126
104
  export interface AfterResolveData {
127
105
  request: string
128
106
  context: string
@@ -130,11 +108,7 @@ export interface AfterResolveData {
130
108
  contextDependencies: Array<string>
131
109
  missingDependencies: Array<string>
132
110
  factoryMeta: FactoryMeta
133
- }
134
-
135
- export interface BeforeResolveData {
136
- request: string
137
- context: string
111
+ createData?: AfterResolveCreateData
138
112
  }
139
113
 
140
114
  export interface BuiltinPlugin {
@@ -199,7 +173,8 @@ export enum BuiltinPluginName {
199
173
  HtmlRspackPlugin = 'HtmlRspackPlugin',
200
174
  SwcJsMinimizerRspackPlugin = 'SwcJsMinimizerRspackPlugin',
201
175
  SwcCssMinimizerRspackPlugin = 'SwcCssMinimizerRspackPlugin',
202
- BundlerInfoRspackPlugin = 'BundlerInfoRspackPlugin'
176
+ BundlerInfoRspackPlugin = 'BundlerInfoRspackPlugin',
177
+ JsLoaderRspackPlugin = 'JsLoaderRspackPlugin'
203
178
  }
204
179
 
205
180
  export function cleanupGlobalTrace(): void
@@ -259,6 +234,11 @@ export interface JsAssetInfoRelated {
259
234
  sourceMap?: string
260
235
  }
261
236
 
237
+ export interface JsBeforeResolveArgs {
238
+ request: string
239
+ context: string
240
+ }
241
+
262
242
  export interface JsBuildTimeExecutionOption {
263
243
  publicPath?: string
264
244
  baseUri?: string
@@ -331,32 +311,27 @@ export interface JsExecuteModuleResult {
331
311
  }
332
312
 
333
313
  export interface JsHooks {
334
- afterProcessAssets: (...args: any[]) => any
335
- thisCompilation: (...args: any[]) => any
336
- emit: (...args: any[]) => any
337
- assetEmitted: (...args: any[]) => any
338
- shouldEmit: (...args: any[]) => any
339
- afterEmit: (...args: any[]) => any
340
- optimizeModules: (...args: any[]) => any
341
- afterOptimizeModules: (...args: any[]) => any
342
- optimizeTree: (...args: any[]) => any
343
- optimizeChunkModules: (...args: any[]) => any
344
- beforeCompile: (...args: any[]) => any
345
- afterCompile: (...args: any[]) => any
346
- finishModules: (...args: any[]) => any
347
- finishMake: (...args: any[]) => any
348
- buildModule: (...args: any[]) => any
349
- beforeResolve: (...args: any[]) => any
350
- afterResolve: (...args: any[]) => any
351
- contextModuleFactoryBeforeResolve: (...args: any[]) => any
352
- contextModuleFactoryAfterResolve: (...args: any[]) => any
353
- normalModuleFactoryCreateModule: (...args: any[]) => any
354
- normalModuleFactoryResolveForScheme: (...args: any[]) => any
355
- chunkAsset: (...args: any[]) => any
356
- succeedModule: (...args: any[]) => any
357
- stillValidModule: (...args: any[]) => any
358
- executeModule: (...args: any[]) => any
359
- runtimeModule: (...args: any[]) => any
314
+ afterProcessAssets: () => void
315
+ emit: () => void
316
+ assetEmitted: (asset: JsAssetEmittedArgs) => void
317
+ afterEmit: () => void
318
+ optimizeModules: (compilation: JsCompilation) => void
319
+ afterOptimizeModules: (compilation: JsCompilation) => void
320
+ optimizeTree: () => void
321
+ optimizeChunkModules: (compilation: JsCompilation) => void
322
+ finishModules: (compilation: JsCompilation) => void
323
+ finishMake: (compilation: JsCompilation) => void
324
+ buildModule: (module: JsModule) => void
325
+ chunkAsset: (asset: JsChunkAssetArgs) => void
326
+ afterResolve: (data: AfterResolveData) => Promise<(boolean | void | AfterResolveCreateData)[]>
327
+ contextModuleFactoryBeforeResolve: (data: JsBeforeResolveArgs) => Promise<boolean | void>
328
+ contextModuleFactoryAfterResolve: (data: AfterResolveData) => Promise<boolean | void>
329
+ normalModuleFactoryCreateModule: (data: CreateModuleData) => void
330
+ normalModuleFactoryResolveForScheme: (data: JsResolveForSchemeInput) => Promise<JsResolveForSchemeResult>
331
+ succeedModule: (module: JsModule) => void
332
+ stillValidModule: (module: JsModule) => void
333
+ executeModule: (arg: JsExecuteModuleArg) => void
334
+ runtimeModule: (arg: JsRuntimeModuleArg) => JsRuntimeModule | void
360
335
  }
361
336
 
362
337
  export interface JsLoaderContext {
@@ -403,6 +378,23 @@ export interface JsLoaderContext {
403
378
  hot: boolean
404
379
  }
405
380
 
381
+ /** Only for dts generation */
382
+ export interface JsLoaderResult {
383
+ /** Content in pitching stage can be empty */
384
+ content?: Buffer
385
+ fileDependencies: Array<string>
386
+ contextDependencies: Array<string>
387
+ missingDependencies: Array<string>
388
+ buildDependencies: Array<string>
389
+ assetFilenames: Array<string>
390
+ sourceMap?: Buffer
391
+ additionalData?: Buffer
392
+ additionalDataExternal: ExternalObject<'AdditionalData'>
393
+ cacheable: boolean
394
+ /** Used to instruct how rust loaders should execute */
395
+ isPitching: boolean
396
+ }
397
+
406
398
  export interface JsModule {
407
399
  context?: string
408
400
  originalSource?: JsCompatSource
@@ -603,9 +595,9 @@ export interface RawAliasOptionItem {
603
595
  redirect: Array<string | false>
604
596
  }
605
597
 
606
- export interface RawAssetGeneratorDataUrl {
607
- type: "options"
608
- options?: RawAssetGeneratorDataUrlOptions
598
+ export interface RawAssetGeneratorDataUrlFnArgs {
599
+ filename: string
600
+ content: string
609
601
  }
610
602
 
611
603
  export interface RawAssetGeneratorDataUrlOptions {
@@ -616,11 +608,11 @@ export interface RawAssetGeneratorDataUrlOptions {
616
608
  export interface RawAssetGeneratorOptions {
617
609
  filename?: string
618
610
  publicPath?: string
619
- dataUrl?: RawAssetGeneratorDataUrl
611
+ dataUrl?: RawAssetGeneratorDataUrlOptions | ((arg: RawAssetGeneratorDataUrlFnArgs) => string)
620
612
  }
621
613
 
622
614
  export interface RawAssetInlineGeneratorOptions {
623
- dataUrl?: RawAssetGeneratorDataUrl
615
+ dataUrl?: RawAssetGeneratorDataUrlOptions | ((arg: RawAssetGeneratorDataUrlFnArgs) => string)
624
616
  }
625
617
 
626
618
  export interface RawAssetParserDataUrl {
@@ -1022,7 +1014,7 @@ export interface RawModuleRuleUse {
1022
1014
  export interface RawModuleRuleUses {
1023
1015
  type: "array" | "function"
1024
1016
  arrayUse?: Array<RawModuleRuleUse>
1025
- funcUse?: (...args: any[]) => any
1017
+ funcUse?: (arg: RawFuncUseCtx) => RawModuleRuleUse[]
1026
1018
  }
1027
1019
 
1028
1020
  export interface RawNodeOption {
@@ -1107,6 +1099,12 @@ export interface RawParserOptions {
1107
1099
  javascript?: RawJavascriptParserOptions
1108
1100
  }
1109
1101
 
1102
+ export interface RawPathData {
1103
+ filename?: string
1104
+ contentHash?: string
1105
+ url?: string
1106
+ }
1107
+
1110
1108
  export interface RawPluginImportConfig {
1111
1109
  libraryName: string
1112
1110
  libraryDirectory?: string
@@ -1290,19 +1288,22 @@ export interface RawTrustedTypes {
1290
1288
  export function registerGlobalTrace(filter: string, layer: "chrome" | "logger", output: string): void
1291
1289
 
1292
1290
  export interface RegisterJsTaps {
1293
- registerCompilerCompilationTaps: (...args: any[]) => any
1294
- registerCompilerMakeTaps: (...args: any[]) => any
1295
- registerCompilationProcessAssetsTaps: (...args: any[]) => any
1291
+ registerCompilerThisCompilationTaps: (stages: Array<number>) => Array<{ function: ((compilation: JsCompilation) => void); stage: number; }>
1292
+ registerCompilerCompilationTaps: (stages: Array<number>) => Array<{ function: ((compilation: JsCompilation) => void); stage: number; }>
1293
+ registerCompilerMakeTaps: (stages: Array<number>) => Array<{ function: ((compilation: JsCompilation) => Promise<void>); stage: number; }>
1294
+ registerCompilerShouldEmitTaps: (stages: Array<number>) => Array<{ function: ((compilation: JsCompilation) => boolean | undefined); stage: number; }>
1295
+ registerCompilationProcessAssetsTaps: (stages: Array<number>) => Array<{ function: ((compilation: JsCompilation) => Promise<void>); stage: number; }>
1296
+ registerNormalModuleFactoryBeforeResolveTaps: (stages: Array<number>) => Array<{ function: ((compilation: JsBeforeResolveArgs) => Promise<[boolean | undefined, JsBeforeResolveArgs]>); stage: number; }>
1296
1297
  }
1297
1298
 
1298
1299
  /** Builtin loader runner */
1299
1300
  export function runBuiltinLoader(builtin: string, options: string | undefined | null, loaderContext: JsLoaderContext): Promise<JsLoaderContext>
1300
1301
 
1301
1302
  export interface ThreadsafeNodeFS {
1302
- writeFile: (...args: any[]) => any
1303
- removeFile: (...args: any[]) => any
1304
- mkdir: (...args: any[]) => any
1305
- mkdirp: (...args: any[]) => any
1306
- removeDirAll: (...args: any[]) => any
1303
+ writeFile: (name: string, content: Buffer) => void
1304
+ removeFile: (name: string) => void
1305
+ mkdir: (name: string) => void
1306
+ mkdirp: (name: string) => string | void
1307
+ removeDirAll: (name: string) => string | void
1307
1308
  }
1308
1309
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "license": "MIT",
5
5
  "description": "Node binding for rspack",
6
6
  "main": "binding.js",
@@ -22,15 +22,15 @@
22
22
  "binaryName": "rspack"
23
23
  },
24
24
  "optionalDependencies": {
25
- "@rspack/binding-darwin-arm64": "0.5.7",
26
- "@rspack/binding-win32-arm64-msvc": "0.5.7",
27
- "@rspack/binding-linux-arm64-gnu": "0.5.7",
28
- "@rspack/binding-win32-ia32-msvc": "0.5.7",
29
- "@rspack/binding-linux-arm64-musl": "0.5.7",
30
- "@rspack/binding-darwin-x64": "0.5.7",
31
- "@rspack/binding-win32-x64-msvc": "0.5.7",
32
- "@rspack/binding-linux-x64-musl": "0.5.7",
33
- "@rspack/binding-linux-x64-gnu": "0.5.7"
25
+ "@rspack/binding-darwin-arm64": "0.5.8",
26
+ "@rspack/binding-linux-arm64-gnu": "0.5.8",
27
+ "@rspack/binding-win32-arm64-msvc": "0.5.8",
28
+ "@rspack/binding-darwin-x64": "0.5.8",
29
+ "@rspack/binding-win32-ia32-msvc": "0.5.8",
30
+ "@rspack/binding-linux-arm64-musl": "0.5.8",
31
+ "@rspack/binding-win32-x64-msvc": "0.5.8",
32
+ "@rspack/binding-linux-x64-gnu": "0.5.8",
33
+ "@rspack/binding-linux-x64-musl": "0.5.8"
34
34
  },
35
35
  "scripts": {
36
36
  "build:debug": "node scripts/build.js",