@rspack/binding 1.4.1 → 1.4.3

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 (3) hide show
  1. package/README.md +1 -1
  2. package/binding.d.ts +102 -107
  3. package/package.json +11 -11
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <picture>
2
- <img alt="Rspack Banner" src="https://assets.rspack.dev/rspack/rspack-banner.png">
2
+ <img alt="Rspack Banner" src="https://assets.rspack.rs/rspack/rspack-banner.png">
3
3
  </picture>
4
4
 
5
5
  # @rspack/binding
package/binding.d.ts CHANGED
@@ -10,6 +10,8 @@ export type RawLazyCompilationTest = RegExp | ((module: Module) => boolean);
10
10
 
11
11
  export type AssetInfo = KnownAssetInfo & Record<string, any>;
12
12
 
13
+ export type CustomPluginName = string;
14
+
13
15
  export const MODULE_IDENTIFIER_SYMBOL: unique symbol;
14
16
 
15
17
  export const COMPILATION_HOOKS_MAP_SYMBOL: unique symbol;
@@ -21,6 +23,8 @@ export const BUILD_INFO_MISSING_DEPENDENCIES_SYMBOL: unique symbol;
21
23
  export const BUILD_INFO_BUILD_DEPENDENCIES_SYMBOL: unique symbol;
22
24
  export const COMMIT_CUSTOM_FIELDS_SYMBOL: unique symbol;
23
25
 
26
+ export const RUST_ERROR_SYMBOL: unique symbol;
27
+
24
28
  interface KnownBuildInfo {
25
29
  [BUILD_INFO_ASSETS_SYMBOL]: Assets,
26
30
  [BUILD_INFO_FILE_DEPENDENCIES_SYMBOL]: string[],
@@ -73,6 +77,18 @@ export interface ExternalModule extends Module {
73
77
  readonly userRequest: string;
74
78
  }
75
79
 
80
+ export interface RspackError extends Error {
81
+ name: string;
82
+ message: string;
83
+ details?: string;
84
+ module?: null | Module;
85
+ loc?: DependencyLocation;
86
+ file?: string;
87
+ stack?: string;
88
+ hideStack?: boolean;
89
+ error?: Error;
90
+ }
91
+
76
92
  export type DependencyLocation = SyntheticDependencyLocation | RealDependencyLocation;
77
93
  /* -- banner.d.ts end -- */
78
94
 
@@ -93,10 +109,63 @@ export declare class AsyncDependenciesBlock {
93
109
  get blocks(): AsyncDependenciesBlock[]
94
110
  }
95
111
 
112
+ export declare class Chunk {
113
+ get name(): string | undefined
114
+ get id(): string | undefined
115
+ get ids(): Array<string>
116
+ get idNameHints(): Array<string>
117
+ get filenameTemplate(): string | undefined
118
+ get cssFilenameTemplate(): string | undefined
119
+ get _files(): Array<string>
120
+ get _runtime(): Array<string>
121
+ get hash(): string | undefined
122
+ get contentHash(): Record<string, string>
123
+ get renderedHash(): string | undefined
124
+ get chunkReason(): string | undefined
125
+ get _auxiliaryFiles(): Array<string>
126
+ isOnlyInitial(): boolean
127
+ canBeInitial(): boolean
128
+ hasRuntime(): boolean
129
+ getAllAsyncChunks(): Chunk[]
130
+ getAllInitialChunks(): Chunk[]
131
+ getAllReferencedChunks(): Chunk[]
132
+ get _groupsIterable(): ChunkGroup[]
133
+ getEntryOptions(): EntryOptionsDTO | undefined
134
+ }
135
+
136
+ export declare class ChunkGraph {
137
+ hasChunkEntryDependentChunks(chunk: Chunk): boolean
138
+ getChunkModules(chunk: Chunk): Module[]
139
+ getChunkModulesIterable(chunk: Chunk): Iterable<Module>
140
+ getChunkEntryModulesIterable(chunk: Chunk): Iterable<Module>
141
+ getNumberOfEntryModules(chunk: Chunk): number
142
+ getChunkEntryDependentChunksIterable(chunk: Chunk): Chunk[]
143
+ getChunkModulesIterableBySourceType(chunk: Chunk, sourceType: string): Module[]
144
+ getModuleChunks(module: Module): Chunk[]
145
+ getModuleId(module: Module): string | number | null
146
+ _getModuleHash(module: Module, runtime: string | string[] | undefined): string | null
147
+ getBlockChunkGroup(jsBlock: AsyncDependenciesBlock): ChunkGroup | null
148
+ }
149
+
150
+ export declare class ChunkGroup {
151
+ get chunks(): Chunk[]
152
+ get index(): number | undefined
153
+ get name(): string | undefined
154
+ get origins(): Array<JsChunkGroupOrigin>
155
+ get childrenIterable(): ChunkGroup[]
156
+ isInitial(): boolean
157
+ getParents(): ChunkGroup[]
158
+ getRuntimeChunk(): Chunk
159
+ getEntrypointChunk(): Chunk
160
+ getFiles(): Array<string>
161
+ getModulePreOrderIndex(module: Module): number | null
162
+ getModulePostOrderIndex(module: Module): number | null
163
+ }
164
+
96
165
  export declare class Chunks {
97
166
  get size(): number
98
- _values(): JsChunk[]
99
- _has(chunk: JsChunk): boolean
167
+ _values(): Chunk[]
168
+ _has(chunk: Chunk): boolean
100
169
  }
101
170
 
102
171
  export declare class CodeGenerationResult {
@@ -143,10 +212,10 @@ export declare class Dependency {
143
212
 
144
213
  export declare class Diagnostics {
145
214
  get length(): number
146
- values(): Array<JsRspackError>
147
- get(index: number): JsRspackError | undefined
148
- set(index: number, error: JsRspackError): void
149
- spliceWithArray(index: number, deleteCount?: number | undefined | null, newItems?: Array<JsRspackError> | undefined | null): Array<JsRspackError>
215
+ values(): Array<RspackError>
216
+ get(index: number): RspackError | undefined
217
+ set(index: number, error: RspackError): void
218
+ spliceWithArray(index: number, deleteCount?: number | undefined | null, newItems?: Array<RspackError> | undefined | null): Array<RspackError>
150
219
  }
151
220
 
152
221
  export declare class EntryDataDto {
@@ -194,58 +263,6 @@ export declare class ExternalModule {
194
263
  _emitFile(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
195
264
  }
196
265
 
197
- export declare class JsChunk {
198
- get name(): string | undefined
199
- get id(): string | undefined
200
- get ids(): Array<string>
201
- get idNameHints(): Array<string>
202
- get filenameTemplate(): string | undefined
203
- get cssFilenameTemplate(): string | undefined
204
- get files(): Array<string>
205
- get runtime(): Array<string>
206
- get hash(): string | undefined
207
- get contentHash(): Record<string, string>
208
- get renderedHash(): string | undefined
209
- get chunkReason(): string | undefined
210
- get auxiliaryFiles(): Array<string>
211
- isOnlyInitial(): boolean
212
- canBeInitial(): boolean
213
- hasRuntime(): boolean
214
- getAllAsyncChunks(): JsChunk[]
215
- getAllInitialChunks(): JsChunk[]
216
- getAllReferencedChunks(): JsChunk[]
217
- groups(): JsChunkGroup[]
218
- getEntryOptions(): EntryOptionsDTO | undefined
219
- }
220
-
221
- export declare class JsChunkGraph {
222
- hasChunkEntryDependentChunks(chunk: JsChunk): boolean
223
- getChunkModules(chunk: JsChunk): Module[]
224
- getChunkEntryModules(chunk: JsChunk): Module[]
225
- getNumberOfEntryModules(chunk: JsChunk): number
226
- getChunkEntryDependentChunksIterable(chunk: JsChunk): JsChunk[]
227
- getChunkModulesIterableBySourceType(chunk: JsChunk, sourceType: string): Module[]
228
- getModuleChunks(module: Module): JsChunk[]
229
- getModuleId(module: Module): string | number | null
230
- getModuleHash(module: Module, runtime: string | string[] | undefined): string | null
231
- getBlockChunkGroup(jsBlock: AsyncDependenciesBlock): JsChunkGroup | null
232
- }
233
-
234
- export declare class JsChunkGroup {
235
- get chunks(): JsChunk[]
236
- get index(): number | undefined
237
- get name(): string | undefined
238
- get origins(): Array<JsChunkGroupOrigin>
239
- get childrenIterable(): JsChunkGroup[]
240
- isInitial(): boolean
241
- getParents(): JsChunkGroup[]
242
- getRuntimeChunk(): JsChunk
243
- getEntrypointChunk(): JsChunk
244
- getFiles(): Array<string>
245
- getModulePreOrderIndex(module: Module): number | null
246
- getModulePostOrderIndex(module: Module): number | null
247
- }
248
-
249
266
  export declare class JsCompilation {
250
267
  updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSourceOwned) => JsCompatSourceOwned), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo | undefined)): void
251
268
  getAssets(): Readonly<JsAsset>[]
@@ -256,9 +273,9 @@ export declare class JsCompilation {
256
273
  getOptimizationBailout(): Array<JsStatsOptimizationBailout>
257
274
  get chunks(): Chunks
258
275
  getNamedChunkKeys(): Array<string>
259
- getNamedChunk(name: string): JsChunk | null
276
+ getNamedChunk(name: string): Chunk
260
277
  getNamedChunkGroupKeys(): Array<string>
261
- getNamedChunkGroup(name: string): JsChunkGroup
278
+ getNamedChunkGroup(name: string): ChunkGroup
262
279
  setAssetSource(name: string, source: JsCompatSource): void
263
280
  deleteAssetSource(name: string): void
264
281
  getAssetFilenames(): Array<string>
@@ -266,8 +283,8 @@ export declare class JsCompilation {
266
283
  emitAsset(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
267
284
  deleteAsset(filename: string): void
268
285
  renameAsset(filename: string, newName: string): void
269
- get entrypoints(): JsChunkGroup[]
270
- get chunkGroups(): JsChunkGroup[]
286
+ get entrypoints(): ChunkGroup[]
287
+ get chunkGroups(): ChunkGroup[]
271
288
  get hash(): string | null
272
289
  dependencies(): JsDependencies
273
290
  pushDiagnostic(diagnostic: JsRspackDiagnostic): void
@@ -275,8 +292,8 @@ export declare class JsCompilation {
275
292
  pushNativeDiagnostics(diagnostics: ExternalObject<'Diagnostic[]'>): void
276
293
  get errors(): Diagnostics
277
294
  get warnings(): Diagnostics
278
- getErrors(): Array<JsRspackError>
279
- getWarnings(): Array<JsRspackError>
295
+ getErrors(): Array<RspackError>
296
+ getWarnings(): Array<RspackError>
280
297
  getStats(): JsStats
281
298
  getAssetPath(filename: string, data: JsPathData): string
282
299
  getAssetPathWithInfo(filename: string, data: JsPathData): PathWithInfo
@@ -294,9 +311,9 @@ export declare class JsCompilation {
294
311
  rebuildModule(moduleIdentifiers: Array<string>, f: any): void
295
312
  importModule(request: string, layer: string | undefined | null, publicPath: JsFilename | undefined | null, baseUri: string | undefined | null, originalModule: string, originalModuleContext: string | undefined | null, callback: any): void
296
313
  get entries(): JsEntries
297
- addRuntimeModule(chunk: JsChunk, runtimeModule: JsAddingRuntimeModule): void
314
+ addRuntimeModule(chunk: Chunk, runtimeModule: JsAddingRuntimeModule): void
298
315
  get moduleGraph(): JsModuleGraph
299
- get chunkGraph(): JsChunkGraph
316
+ get chunkGraph(): ChunkGraph
300
317
  addEntry(args: [string, EntryDependency, JsEntryOptions | undefined][], callback: (errMsg: Error | null, results: [string | null, Module][]) => void): void
301
318
  addInclude(args: [string, EntryDependency, JsEntryOptions | undefined][], callback: (errMsg: Error | null, results: [string | null, Module][]) => void): void
302
319
  get codeGenerationResults(): CodeGenerationResults
@@ -439,7 +456,7 @@ export declare class Sources {
439
456
  }
440
457
 
441
458
  export interface BuiltinPlugin {
442
- name: BuiltinPluginName
459
+ name: BuiltinPluginName | CustomPluginName
443
460
  options: unknown
444
461
  canInherentFromParent?: boolean
445
462
  }
@@ -558,7 +575,7 @@ export interface JsAddingRuntimeModule {
558
575
  }
559
576
 
560
577
  export interface JsAdditionalTreeRuntimeRequirementsArg {
561
- chunk: JsChunk
578
+ chunk: Chunk
562
579
  runtimeRequirements: JsRuntimeGlobals
563
580
  }
564
581
 
@@ -626,7 +643,7 @@ export interface JsAssetInfoRelated {
626
643
 
627
644
  export interface JsBannerContentFnCtx {
628
645
  hash: string
629
- chunk: JsChunk
646
+ chunk: Chunk
630
647
  filename: string
631
648
  }
632
649
 
@@ -675,7 +692,7 @@ export interface JsCacheGroupTestCtx {
675
692
  }
676
693
 
677
694
  export interface JsChunkAssetArgs {
678
- chunk: JsChunk
695
+ chunk: Chunk
679
696
  filename: string
680
697
  }
681
698
 
@@ -687,7 +704,7 @@ export interface JsChunkGroupOrigin {
687
704
 
688
705
  export interface JsChunkOptionNameCtx {
689
706
  module: Module
690
- chunks: JsChunk[]
707
+ chunks: Chunk[]
691
708
  cacheGroupKey: string
692
709
  }
693
710
 
@@ -735,7 +752,7 @@ export interface JsCreateData {
735
752
 
736
753
  export interface JsCreateScriptData {
737
754
  code: string
738
- chunk: JsChunk
755
+ chunk: Chunk
739
756
  }
740
757
 
741
758
  export interface JsDefaultObjectRedirectWarnObject {
@@ -879,12 +896,12 @@ export interface JsLibraryOptions {
879
896
 
880
897
  export interface JsLinkPrefetchData {
881
898
  code: string
882
- chunk: JsChunk
899
+ chunk: Chunk
883
900
  }
884
901
 
885
902
  export interface JsLinkPreloadData {
886
903
  code: string
887
- chunk: JsChunk
904
+ chunk: Chunk
888
905
  }
889
906
 
890
907
  export interface JsLoaderContext {
@@ -904,7 +921,7 @@ export interface JsLoaderContext {
904
921
  loaderItems: Array<JsLoaderItem>
905
922
  loaderIndex: number
906
923
  loaderState: Readonly<JsLoaderState>
907
- __internal__error?: JsRspackError
924
+ __internal__error?: RspackError
908
925
  /**
909
926
  * UTF-8 hint for `content`
910
927
  * - Some(true): `content` is a `UTF-8` encoded sequence
@@ -1142,17 +1159,7 @@ export interface JsRsdoctorVariable {
1142
1159
 
1143
1160
  export interface JsRspackDiagnostic {
1144
1161
  severity: JsRspackSeverity
1145
- error: JsRspackError
1146
- }
1147
-
1148
- export interface JsRspackError {
1149
- name: string
1150
- message: string
1151
- moduleIdentifier?: string
1152
- loc?: DependencyLocation
1153
- file?: string
1154
- stack?: string
1155
- hideStack?: boolean
1162
+ error: RspackError
1156
1163
  }
1157
1164
 
1158
1165
  export declare enum JsRspackSeverity {
@@ -1173,11 +1180,11 @@ export interface JsRuntimeModule {
1173
1180
 
1174
1181
  export interface JsRuntimeModuleArg {
1175
1182
  module: JsRuntimeModule
1176
- chunk: JsChunk
1183
+ chunk: Chunk
1177
1184
  }
1178
1185
 
1179
1186
  export interface JsRuntimeRequirementInTreeArg {
1180
- chunk: JsChunk
1187
+ chunk: Chunk
1181
1188
  allRuntimeRequirements: JsRuntimeGlobals
1182
1189
  runtimeRequirements: JsRuntimeGlobals
1183
1190
  }
@@ -1284,10 +1291,11 @@ export interface JsStatsCompilation {
1284
1291
  hash?: string
1285
1292
  modules?: Array<JsStatsModule>
1286
1293
  namedChunkGroups?: Array<JsStatsChunkGroup>
1287
- warnings: Array<JsStatsWarning>
1294
+ warnings: Array<JsStatsError>
1288
1295
  }
1289
1296
 
1290
1297
  export interface JsStatsError {
1298
+ name?: string
1291
1299
  moduleDescriptor?: JsModuleDescriptor
1292
1300
  message: string
1293
1301
  chunkName?: string
@@ -1426,21 +1434,6 @@ export interface JsStatsSize {
1426
1434
  size: number
1427
1435
  }
1428
1436
 
1429
- export interface JsStatsWarning {
1430
- moduleDescriptor?: JsModuleDescriptor
1431
- name?: string
1432
- message: string
1433
- chunkName?: string
1434
- code?: string
1435
- chunkEntry?: boolean
1436
- chunkInitial?: boolean
1437
- file?: string
1438
- chunkId?: string
1439
- details?: string
1440
- stack?: string
1441
- moduleTrace: Array<JsStatsModuleTrace>
1442
- }
1443
-
1444
1437
  export interface JsTap {
1445
1438
  function: any
1446
1439
  stage: number
@@ -1556,7 +1549,7 @@ export interface RawAssetResourceGeneratorOptions {
1556
1549
  }
1557
1550
 
1558
1551
  export interface RawBannerPluginOptions {
1559
- banner: string | ((args: { hash: string, chunk: JsChunk, filename: string }) => string)
1552
+ banner: string | ((args: { hash: string, chunk: Chunk, filename: string }) => string)
1560
1553
  entryOnly?: boolean
1561
1554
  footer?: boolean
1562
1555
  raw?: boolean
@@ -2608,6 +2601,8 @@ export interface RealDependencyLocation {
2608
2601
  }
2609
2602
 
2610
2603
  /**
2604
+ * this is a process level tracing, which means it would be shared by all compilers in the same process
2605
+ * only the first call would take effect, the following calls would be ignored
2611
2606
  * Some code is modified based on
2612
2607
  * https://github.com/swc-project/swc/blob/d1d0607158ab40463d1b123fed52cc526eba8385/bindings/binding_core_node/src/util.rs#L29-L58
2613
2608
  * Apache-2.0 licensed
@@ -2689,7 +2684,7 @@ export interface RegisterJsTaps {
2689
2684
  registerCompilationAfterOptimizeModulesTaps: (stages: Array<number>) => Array<{ function: (() => void); stage: number; }>
2690
2685
  registerCompilationOptimizeTreeTaps: (stages: Array<number>) => Array<{ function: (() => Promise<void>); stage: number; }>
2691
2686
  registerCompilationOptimizeChunkModulesTaps: (stages: Array<number>) => Array<{ function: (() => Promise<boolean | undefined>); stage: number; }>
2692
- registerCompilationChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: JsChunk) => Buffer); stage: number; }>
2687
+ registerCompilationChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: Chunk) => Buffer); stage: number; }>
2693
2688
  registerCompilationChunkAssetTaps: (stages: Array<number>) => Array<{ function: ((arg: JsChunkAssetArgs) => void); stage: number; }>
2694
2689
  registerCompilationProcessAssetsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsCompilation) => Promise<void>); stage: number; }>
2695
2690
  registerCompilationAfterProcessAssetsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsCompilation) => void); stage: number; }>
@@ -2703,7 +2698,7 @@ export interface RegisterJsTaps {
2703
2698
  registerNormalModuleFactoryCreateModuleTaps: (stages: Array<number>) => Array<{ function: ((arg: JsNormalModuleFactoryCreateModuleArgs) => Promise<void>); stage: number; }>
2704
2699
  registerContextModuleFactoryBeforeResolveTaps: (stages: Array<number>) => Array<{ function: ((arg: false | JsContextModuleFactoryBeforeResolveData) => Promise<false | JsContextModuleFactoryBeforeResolveData>); stage: number; }>
2705
2700
  registerContextModuleFactoryAfterResolveTaps: (stages: Array<number>) => Array<{ function: ((arg: false | JsContextModuleFactoryAfterResolveData) => Promise<false | JsContextModuleFactoryAfterResolveData>); stage: number; }>
2706
- registerJavascriptModulesChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: JsChunk) => Buffer); stage: number; }>
2701
+ registerJavascriptModulesChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: Chunk) => Buffer); stage: number; }>
2707
2702
  registerHtmlPluginBeforeAssetTagGenerationTaps: (stages: Array<number>) => Array<{ function: ((arg: JsBeforeAssetTagGenerationData) => JsBeforeAssetTagGenerationData); stage: number; }>
2708
2703
  registerHtmlPluginAlterAssetTagsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsAlterAssetTagsData) => JsAlterAssetTagsData); stage: number; }>
2709
2704
  registerHtmlPluginAlterAssetTagGroupsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsAlterAssetTagGroupsData) => JsAlterAssetTagGroupsData); stage: number; }>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "license": "MIT",
5
5
  "description": "Node binding for rspack",
6
6
  "main": "binding.js",
@@ -47,16 +47,16 @@
47
47
  }
48
48
  },
49
49
  "optionalDependencies": {
50
- "@rspack/binding-darwin-arm64": "1.4.1",
51
- "@rspack/binding-win32-arm64-msvc": "1.4.1",
52
- "@rspack/binding-linux-arm64-gnu": "1.4.1",
53
- "@rspack/binding-linux-arm64-musl": "1.4.1",
54
- "@rspack/binding-win32-ia32-msvc": "1.4.1",
55
- "@rspack/binding-wasm32-wasi": "1.4.1",
56
- "@rspack/binding-darwin-x64": "1.4.1",
57
- "@rspack/binding-win32-x64-msvc": "1.4.1",
58
- "@rspack/binding-linux-x64-musl": "1.4.1",
59
- "@rspack/binding-linux-x64-gnu": "1.4.1"
50
+ "@rspack/binding-darwin-arm64": "1.4.3",
51
+ "@rspack/binding-win32-arm64-msvc": "1.4.3",
52
+ "@rspack/binding-linux-arm64-gnu": "1.4.3",
53
+ "@rspack/binding-linux-arm64-musl": "1.4.3",
54
+ "@rspack/binding-wasm32-wasi": "1.4.3",
55
+ "@rspack/binding-darwin-x64": "1.4.3",
56
+ "@rspack/binding-win32-x64-msvc": "1.4.3",
57
+ "@rspack/binding-win32-ia32-msvc": "1.4.3",
58
+ "@rspack/binding-linux-x64-musl": "1.4.3",
59
+ "@rspack/binding-linux-x64-gnu": "1.4.3"
60
60
  },
61
61
  "scripts": {
62
62
  "build:dev": "node scripts/build.js",