@rspack/binding 0.0.20 → 0.0.22

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/LICENSE +21 -0
  2. package/binding.d.ts +85 -10
  3. package/package.json +8 -6
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present Rspack Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/binding.d.ts CHANGED
@@ -25,7 +25,6 @@ export interface RawCssModulesConfig {
25
25
  export interface RawDecoratorOptions {
26
26
  legacy: boolean
27
27
  emitMetadata: boolean
28
- useDefineForClassFields: boolean
29
28
  }
30
29
  /**
31
30
  * It seems napi not support enum well
@@ -80,6 +79,8 @@ export interface RawReactOptions {
80
79
  export interface Minification {
81
80
  passes?: number
82
81
  enable?: boolean
82
+ dropConsole?: boolean
83
+ pureFuncs?: Array<string>
83
84
  }
84
85
  export interface RawBuiltins {
85
86
  html?: Array<RawHtmlPluginConfig>
@@ -94,6 +95,8 @@ export interface RawBuiltins {
94
95
  progress?: RawProgressPluginConfig
95
96
  react?: RawReactOptions
96
97
  decorator?: RawDecoratorOptions
98
+ noEmitAssets?: boolean
99
+ emotion?: string
97
100
  }
98
101
  export interface RawCacheOptions {
99
102
  type: string
@@ -115,6 +118,7 @@ export interface RawEntryItem {
115
118
  }
116
119
  export interface RawExperiments {
117
120
  lazyCompilation: boolean
121
+ changedHmr: boolean
118
122
  }
119
123
  /**
120
124
  * `loader` is for js side loader, `builtin_loader` is for rust side loader,
@@ -143,6 +147,9 @@ export interface RawModuleRuleCondition {
143
147
  */
144
148
  matcher?: string
145
149
  }
150
+ export interface RawIssuerOptions {
151
+ not?: Array<RawModuleRuleCondition>
152
+ }
146
153
  export interface RawModuleRule {
147
154
  /**
148
155
  * A condition matcher matching an absolute path.
@@ -162,10 +169,20 @@ export interface RawModuleRule {
162
169
  * TODO: align with webpack's `?` prefixed `resourceQuery`
163
170
  */
164
171
  resourceQuery?: RawModuleRuleCondition
165
- func?: (...args: any[]) => any
172
+ sideEffects?: boolean
166
173
  use?: Array<RawModuleRuleUse>
167
174
  type?: "js" | "jsx" | "ts" | "tsx" | "css" | "json" | "asset" | "asset/resource" | "asset/source" | "asset/inline"
175
+ parser?: RawModuleRuleParser
176
+ generator?: RawModuleRuleGenerator
168
177
  resolve?: RawResolveOptions
178
+ issuer?: RawIssuerOptions
179
+ func?: (...args: any[]) => any
180
+ }
181
+ export interface RawModuleRuleGenerator {
182
+ filename?: string
183
+ }
184
+ export interface RawModuleRuleParser {
185
+ dataUrlCondition?: RawAssetParserDataUrlOption
169
186
  }
170
187
  export interface RawAssetParserDataUrlOption {
171
188
  maxSize?: number
@@ -189,10 +206,16 @@ export interface JsLoaderContext {
189
206
  resourceQuery?: string
190
207
  resourceFragment?: string
191
208
  cacheable: boolean
209
+ fileDependencies: Array<string>
210
+ contextDependencies: Array<string>
211
+ missingDependencies: Array<string>
192
212
  buildDependencies: Array<string>
193
213
  }
194
214
  export interface JsLoaderResult {
195
215
  content: Buffer
216
+ fileDependencies: Array<string>
217
+ contextDependencies: Array<string>
218
+ missingDependencies: Array<string>
196
219
  buildDependencies: Array<string>
197
220
  sourceMap?: Buffer
198
221
  additionalData?: Buffer
@@ -204,6 +227,7 @@ export interface RawNodeOption {
204
227
  export interface RawOptimizationOptions {
205
228
  splitChunks?: RawSplitChunksOptions
206
229
  moduleIds?: string
230
+ removeAvailableModules?: boolean
207
231
  }
208
232
  export interface RawOutputOptions {
209
233
  path?: string
@@ -215,6 +239,7 @@ export interface RawOutputOptions {
215
239
  cssChunkFilename?: string
216
240
  uniqueName?: string
217
241
  library?: string
242
+ strictModuleErrorHandling?: boolean
218
243
  }
219
244
  export interface RawResolveOptions {
220
245
  preferRelative?: boolean
@@ -224,8 +249,10 @@ export interface RawResolveOptions {
224
249
  browserField?: boolean
225
250
  conditionNames?: Array<string>
226
251
  alias?: Record<string, string | false>
252
+ fallback?: Record<string, string | false>
227
253
  symlinks?: boolean
228
254
  tsConfigPath?: string
255
+ modules?: Array<string>
229
256
  }
230
257
  export interface RawSnapshotStrategy {
231
258
  hash: boolean
@@ -241,12 +268,21 @@ export interface RawSplitChunksOptions {
241
268
  cacheGroups?: Record<string, RawCacheGroupOptions>
242
269
  /** What kind of chunks should be selected. */
243
270
  chunks?: string
271
+ maxAsyncRequests?: number
272
+ maxInitialRequests?: number
273
+ minChunks?: number
274
+ minSize?: number
275
+ enforceSizeThreshold?: number
276
+ minRemainingSize?: number
244
277
  }
245
278
  export interface RawCacheGroupOptions {
246
- test: string
279
+ priority?: number
280
+ reuseExistingChunk?: boolean
281
+ test?: string
247
282
  /** What kind of chunks should be selected. */
248
283
  chunks?: string
249
- name: string
284
+ minChunks?: number
285
+ name?: string
250
286
  }
251
287
  export interface RawStatsOptions {
252
288
  colors: boolean
@@ -300,7 +336,7 @@ export interface JsAssetInfo {
300
336
  }
301
337
  export interface JsAsset {
302
338
  name: string
303
- source: JsCompatSource
339
+ source?: JsCompatSource
304
340
  info: JsAssetInfo
305
341
  }
306
342
  export interface JsChunk {
@@ -310,10 +346,17 @@ export interface JsChunkGroup {
310
346
  chunks: Array<JsChunk>
311
347
  }
312
348
  export interface JsHooks {
313
- done: (...args: any[]) => any
314
- processAssets: (...args: any[]) => any
349
+ processAssetsStageAdditional: (...args: any[]) => any
350
+ processAssetsStagePreProcess: (...args: any[]) => any
351
+ processAssetsStageNone: (...args: any[]) => any
352
+ processAssetsStageOptimizeInline: (...args: any[]) => any
353
+ processAssetsStageSummarize: (...args: any[]) => any
354
+ processAssetsStageReport: (...args: any[]) => any
315
355
  compilation: (...args: any[]) => any
316
356
  thisCompilation: (...args: any[]) => any
357
+ emit: (...args: any[]) => any
358
+ afterEmit: (...args: any[]) => any
359
+ make: (...args: any[]) => any
317
360
  }
318
361
  export interface JsCompatSource {
319
362
  /** Whether the underlying data structure is a `RawSource` */
@@ -354,6 +397,19 @@ export interface JsStatsModule {
354
397
  size: number
355
398
  issuer?: string
356
399
  issuerName?: string
400
+ issuerId?: string
401
+ issuerPath: Array<JsStatsModuleIssuer>
402
+ reasons?: Array<JsStatsModuleReason>
403
+ }
404
+ export interface JsStatsModuleIssuer {
405
+ identifier: string
406
+ name: string
407
+ id: string
408
+ }
409
+ export interface JsStatsModuleReason {
410
+ moduleIdentifier?: string
411
+ moduleName?: string
412
+ moduleId?: string
357
413
  }
358
414
  export interface JsStatsChunk {
359
415
  type: string
@@ -391,14 +447,33 @@ export class JsCompilation {
391
447
  getAssets(): Readonly<JsAsset>[]
392
448
  getAsset(name: string): JsAsset | null
393
449
  getAssetSource(name: string): JsCompatSource | null
450
+ setAssetSource(name: string, source: JsCompatSource): void
451
+ deleteAssetSource(name: string): void
394
452
  getAssetFilenames(): Array<string>
395
453
  hasAsset(name: string): boolean
396
454
  emitAsset(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
397
455
  deleteAsset(filename: string): void
398
- get assets(): Record<string, JsCompatSource>
399
456
  get entrypoints(): Record<string, JsChunkGroup>
400
457
  get hash(): string
458
+ getFileDependencies(): Array<string>
459
+ getContextDependencies(): Array<string>
460
+ getMissingDependencies(): Array<string>
461
+ getBuildDependencies(): Array<string>
401
462
  pushDiagnostic(severity: "error" | "warning", title: string, message: string): void
463
+ getStats(): JsStats
464
+ addFileDependencies(deps: Array<string>): void
465
+ addContextDependencies(deps: Array<string>): void
466
+ addMissingDependencies(deps: Array<string>): void
467
+ addBuildDependencies(deps: Array<string>): void
468
+ }
469
+ export class JsStats {
470
+ getAssets(): Array<JsStatsAsset>
471
+ getModules(showReasons: boolean): Array<JsStatsModule>
472
+ getChunks(): Array<JsStatsChunk>
473
+ getEntrypoints(): Array<JsStatsEntrypoint>
474
+ getErrors(): Array<JsStatsError>
475
+ getWarnings(): Array<JsStatsWarning>
476
+ getHash(): string
402
477
  }
403
478
  export class Rspack {
404
479
  constructor(options: RawOptions, jsHooks?: JsHooks | undefined | null)
@@ -408,14 +483,14 @@ export class Rspack {
408
483
  * Warning:
409
484
  * Calling this method recursively might cause a deadlock.
410
485
  */
411
- unsafe_build(callback: (err: null | Error, result: JsStatsCompilation) => void): void
486
+ unsafe_build(callback: (err: null | Error) => void): void
412
487
  /**
413
488
  * Rebuild with the given option passed to the constructor
414
489
  *
415
490
  * Warning:
416
491
  * Calling this method recursively will cause a deadlock.
417
492
  */
418
- unsafe_rebuild(callback: (err: null | Error, result: Record<string, {content: string, kind: number}>) => void): void
493
+ unsafe_rebuild(changed_files: string[], removed_files: string[], callback: (err: null | Error) => void): void
419
494
  /**
420
495
  * Get the last compilation
421
496
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Node binding for rspack",
5
5
  "main": "binding.js",
6
6
  "types": "binding.d.ts",
@@ -13,16 +13,17 @@
13
13
  ],
14
14
  "keywords": [],
15
15
  "author": "",
16
- "license": "ISC",
16
+ "license": "MIT",
17
17
  "devDependencies": {
18
- "@napi-rs/cli": "^2.6.2",
18
+ "@napi-rs/cli": "2.14.2",
19
19
  "why-is-node-running": "2.2.1",
20
20
  "npm-run-all": "4.1.5"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@rspack/binding-darwin-arm64": "0.0.20",
24
- "@rspack/binding-linux-x64-gnu": "0.0.20",
25
- "@rspack/binding-darwin-x64": "0.0.20"
23
+ "@rspack/binding-darwin-x64": "0.0.22",
24
+ "@rspack/binding-darwin-arm64": "0.0.22",
25
+ "@rspack/binding-win32-x64-msvc": "0.0.22",
26
+ "@rspack/binding-linux-x64-gnu": "0.0.22"
26
27
  },
27
28
  "scripts": {
28
29
  "build:debug": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json",
@@ -31,6 +32,7 @@
31
32
  "build:release": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json && pnpm move-binding",
32
33
  "build:release:x64": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json --target x86_64-apple-darwin",
33
34
  "build:release:linux": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json --zig --target x86_64-unknown-linux-gnu --zig-abi-suffix=2.17",
35
+ "build:release:win": "napi build --target x86_64-pc-windows-msvc --release --platform --js false --dts binding.d.ts --config napirs.rc.json",
34
36
  "move-binding": "node scripts/move-binding"
35
37
  }
36
38
  }