@rspack/binding 0.0.21 → 0.0.23

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 +22 -0
  2. package/binding.d.ts +185 -78
  3. package/package.json +11 -8
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present Bytedance, Inc. and its affiliates.
4
+
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/binding.d.ts CHANGED
@@ -3,49 +3,61 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ export interface ThreadsafeNodeFs {
7
+ writeFile: (...args: any[]) => any
8
+ mkdir: (...args: any[]) => any
9
+ mkdirp: (...args: any[]) => any
10
+ }
11
+ export interface NodeFs {
12
+ writeFile: (...args: any[]) => any
13
+ mkdir: (...args: any[]) => any
14
+ mkdirp: (...args: any[]) => any
15
+ }
16
+ export interface RawPattern {
17
+ from: string
18
+ to?: string
19
+ context?: string
20
+ toType?: string
21
+ noErrorOnMissing: boolean
22
+ force: boolean
23
+ priority: number
24
+ globOptions: RawGlobOptions
25
+ }
26
+ export interface RawGlobOptions {
27
+ caseSensitiveMatch?: boolean
28
+ dot?: boolean
29
+ }
30
+ export interface RawCopyConfig {
31
+ patterns: Array<RawPattern>
32
+ }
6
33
  export interface RawCssPluginConfig {
7
- /**
8
- * ## Example
9
- * ```rust,ignore
10
- * RawCssOptions {
11
- * preset_env: vec!["Firefox > 10".into(), "chrome >=20".into()],
12
- * }
13
- * ```
14
- * The preset_env will finally pass into [`browserslist::resolve`](https://docs.rs/browserslist-rs/latest/browserslist/fn.resolve.html).
15
- * For detailed configuration, see https://docs.rs/browserslist-rs/latest/browserslist/
16
- */
17
- presetEnv?: Array<string>
18
- modules?: RawCssModulesConfig
34
+ modules: RawCssModulesConfig
19
35
  }
20
36
  export interface RawCssModulesConfig {
21
- localsConvention?: string
22
- localIdentName?: string
23
- exportsOnly?: boolean
37
+ localsConvention: string
38
+ localIdentName: string
39
+ exportsOnly: boolean
24
40
  }
25
41
  export interface RawDecoratorOptions {
26
42
  legacy: boolean
27
43
  emitMetadata: boolean
28
- useDefineForClassFields: boolean
29
44
  }
30
- /**
31
- * It seems napi not support enum well
32
- */
33
45
  export interface RawHtmlPluginConfig {
34
46
  /** emitted file name in output path */
35
- filename?: string | void
47
+ filename?: string
36
48
  /** template html file */
37
49
  template?: string
38
50
  templateParameters?: Record<string, string>
39
51
  /** `head`, `body` or None */
40
- inject?: string | void
52
+ inject?: "head" | "body"
41
53
  /** path or `auto` */
42
54
  publicPath?: string
43
55
  /** `blocking`, `defer`, or `module` */
44
- scriptLoading?: string | void
56
+ scriptLoading?: "blocking" | "defer" | "module"
45
57
  /** entry_chunk_name (only entry chunks are supported) */
46
58
  chunks?: Array<string>
47
59
  excludedChunks?: Array<string>
48
- sri?: string | void
60
+ sri?: "sha256" | "sha384" | "sha512"
49
61
  minify?: boolean
50
62
  title?: string
51
63
  favicon?: string
@@ -67,7 +79,7 @@ export interface RawProgressPluginConfig {
67
79
  prefix?: string
68
80
  }
69
81
  export interface RawReactOptions {
70
- runtime?: string
82
+ runtime?: "automatic" | "classic"
71
83
  importSource?: string
72
84
  pragma?: string
73
85
  pragmaFrag?: string
@@ -77,23 +89,31 @@ export interface RawReactOptions {
77
89
  useSpread?: boolean
78
90
  refresh?: boolean
79
91
  }
80
- export interface Minification {
81
- passes?: number
82
- enable?: boolean
92
+ export interface RawMinification {
93
+ passes: number
94
+ dropConsole: boolean
95
+ pureFuncs: Array<string>
96
+ }
97
+ export interface RawPresetEnv {
98
+ targets: Array<string>
99
+ mode?: 'usage' | 'entry'
100
+ coreJs?: string
83
101
  }
84
102
  export interface RawBuiltins {
85
103
  html?: Array<RawHtmlPluginConfig>
86
104
  css?: RawCssPluginConfig
87
105
  postcss?: RawPostCssConfig
88
- minify?: Minification
89
- polyfill?: boolean
90
- browserslist?: Array<string>
91
- define?: Record<string, string>
92
- treeShaking?: boolean
93
- sideEffects?: boolean
106
+ minifyOptions?: RawMinification
107
+ presetEnv?: RawPresetEnv
108
+ define: Record<string, string>
109
+ treeShaking: boolean
94
110
  progress?: RawProgressPluginConfig
95
- react?: RawReactOptions
111
+ react: RawReactOptions
96
112
  decorator?: RawDecoratorOptions
113
+ noEmitAssets: boolean
114
+ emotion?: string
115
+ devFriendlySplitChunks: boolean
116
+ copy?: RawCopyConfig
97
117
  }
98
118
  export interface RawCacheOptions {
99
119
  type: string
@@ -107,7 +127,7 @@ export interface RawCacheOptions {
107
127
  version: string
108
128
  }
109
129
  export interface RawDevServer {
110
- hot?: boolean
130
+ hot: boolean
111
131
  }
112
132
  export interface RawEntryItem {
113
133
  import: Array<string>
@@ -115,6 +135,7 @@ export interface RawEntryItem {
115
135
  }
116
136
  export interface RawExperiments {
117
137
  lazyCompilation: boolean
138
+ incrementalRebuild: boolean
118
139
  }
119
140
  /**
120
141
  * `loader` is for js side loader, `builtin_loader` is for rust side loader,
@@ -128,10 +149,14 @@ export interface RawExperiments {
128
149
  * `builtin_loader`.
129
150
  */
130
151
  export interface RawModuleRuleUse {
131
- loader?: (...args: any[]) => any
152
+ jsLoader?: JsLoader
132
153
  builtinLoader?: string
133
154
  options?: string
134
- loaderName?: string
155
+ }
156
+ export interface JsLoader {
157
+ /** composed loader name, xx-loader!yy-loader!zz-loader */
158
+ name: string
159
+ func: (...args: any[]) => any
135
160
  }
136
161
  export interface RawModuleRuleCondition {
137
162
  /** Condition can be either a `string` or `Regexp`. */
@@ -143,6 +168,9 @@ export interface RawModuleRuleCondition {
143
168
  */
144
169
  matcher?: string
145
170
  }
171
+ export interface RawIssuerOptions {
172
+ not?: Array<RawModuleRuleCondition>
173
+ }
146
174
  export interface RawModuleRule {
147
175
  /**
148
176
  * A condition matcher matching an absolute path.
@@ -162,10 +190,20 @@ export interface RawModuleRule {
162
190
  * TODO: align with webpack's `?` prefixed `resourceQuery`
163
191
  */
164
192
  resourceQuery?: RawModuleRuleCondition
165
- func?: (...args: any[]) => any
193
+ sideEffects?: boolean
166
194
  use?: Array<RawModuleRuleUse>
167
- type?: "js" | "jsx" | "ts" | "tsx" | "css" | "json" | "asset" | "asset/resource" | "asset/source" | "asset/inline"
195
+ type?: string
196
+ parser?: RawModuleRuleParser
197
+ generator?: RawModuleRuleGenerator
168
198
  resolve?: RawResolveOptions
199
+ issuer?: RawIssuerOptions
200
+ oneOf?: Array<RawModuleRule>
201
+ }
202
+ export interface RawModuleRuleGenerator {
203
+ filename?: string
204
+ }
205
+ export interface RawModuleRuleParser {
206
+ dataUrlCondition?: RawAssetParserDataUrlOption
169
207
  }
170
208
  export interface RawAssetParserDataUrlOption {
171
209
  maxSize?: number
@@ -189,32 +227,41 @@ export interface JsLoaderContext {
189
227
  resourceQuery?: string
190
228
  resourceFragment?: string
191
229
  cacheable: boolean
230
+ fileDependencies: Array<string>
231
+ contextDependencies: Array<string>
232
+ missingDependencies: Array<string>
192
233
  buildDependencies: Array<string>
193
234
  }
194
235
  export interface JsLoaderResult {
195
236
  content: Buffer
237
+ fileDependencies: Array<string>
238
+ contextDependencies: Array<string>
239
+ missingDependencies: Array<string>
196
240
  buildDependencies: Array<string>
197
241
  sourceMap?: Buffer
198
242
  additionalData?: Buffer
199
243
  cacheable: boolean
200
244
  }
201
245
  export interface RawNodeOption {
202
- dirname?: string
246
+ dirname: string
203
247
  }
204
248
  export interface RawOptimizationOptions {
205
249
  splitChunks?: RawSplitChunksOptions
206
- moduleIds?: string
250
+ moduleIds: string
251
+ removeAvailableModules: boolean
252
+ sideEffects: string
207
253
  }
208
254
  export interface RawOutputOptions {
209
- path?: string
210
- publicPath?: string
211
- assetModuleFilename?: string
212
- filename?: string
213
- chunkFilename?: string
214
- cssFilename?: string
215
- cssChunkFilename?: string
216
- uniqueName?: string
255
+ path: string
256
+ publicPath: string
257
+ assetModuleFilename: string
258
+ filename: string
259
+ chunkFilename: string
260
+ cssFilename: string
261
+ cssChunkFilename: string
262
+ uniqueName: string
217
263
  library?: string
264
+ strictModuleErrorHandling: boolean
218
265
  }
219
266
  export interface RawResolveOptions {
220
267
  preferRelative?: boolean
@@ -224,16 +271,16 @@ export interface RawResolveOptions {
224
271
  browserField?: boolean
225
272
  conditionNames?: Array<string>
226
273
  alias?: Record<string, string | false>
274
+ fallback?: Record<string, string | false>
227
275
  symlinks?: boolean
228
276
  tsConfigPath?: string
277
+ modules?: Array<string>
229
278
  }
230
279
  export interface RawSnapshotStrategy {
231
280
  hash: boolean
232
281
  timestamp: boolean
233
282
  }
234
283
  export interface RawSnapshotOptions {
235
- resolveBuildDependencies: RawSnapshotStrategy
236
- buildDependencies: RawSnapshotStrategy
237
284
  resolve: RawSnapshotStrategy
238
285
  module: RawSnapshotStrategy
239
286
  }
@@ -241,35 +288,44 @@ export interface RawSplitChunksOptions {
241
288
  cacheGroups?: Record<string, RawCacheGroupOptions>
242
289
  /** What kind of chunks should be selected. */
243
290
  chunks?: string
291
+ maxAsyncRequests?: number
292
+ maxInitialRequests?: number
293
+ minChunks?: number
294
+ minSize?: number
295
+ enforceSizeThreshold?: number
296
+ minRemainingSize?: number
244
297
  }
245
298
  export interface RawCacheGroupOptions {
246
- test: string
299
+ priority?: number
300
+ reuseExistingChunk?: boolean
301
+ test?: string
247
302
  /** What kind of chunks should be selected. */
248
303
  chunks?: string
249
- name: string
304
+ minChunks?: number
305
+ name?: string
250
306
  }
251
307
  export interface RawStatsOptions {
252
308
  colors: boolean
253
309
  }
254
310
  export interface RawOptions {
255
- entry?: Record<string, RawEntryItem>
256
- mode?: string
257
- target?: string[]
258
- context?: string
259
- output?: RawOutputOptions
260
- resolve?: RawResolveOptions
261
- module?: RawModuleOptions
262
- builtins?: RawBuiltins
263
- externals?: Record<string, string>
264
- externalsType?: string
265
- devtool?: string
266
- optimization?: RawOptimizationOptions
267
- stats?: RawStatsOptions
268
- devServer?: RawDevServer
269
- snapshot?: RawSnapshotOptions
270
- cache?: RawCacheOptions
271
- experiments?: RawExperiments
272
- node?: RawNodeOption
311
+ entry: Record<string, RawEntryItem>
312
+ mode?: undefined | 'production' | 'development' | 'none'
313
+ target: Array<string>
314
+ context: string
315
+ output: RawOutputOptions
316
+ resolve: RawResolveOptions
317
+ module: RawModuleOptions
318
+ builtins: RawBuiltins
319
+ externals: Record<string, string>
320
+ externalsType: '' | 'node-commonjs' | 'window'
321
+ devtool: string
322
+ optimization: RawOptimizationOptions
323
+ stats: RawStatsOptions
324
+ devServer: RawDevServer
325
+ snapshot: RawSnapshotOptions
326
+ cache: RawCacheOptions
327
+ experiments: RawExperiments
328
+ node: RawNodeOption
273
329
  }
274
330
  export interface JsAssetInfoRelated {
275
331
  sourceMap?: string
@@ -300,7 +356,7 @@ export interface JsAssetInfo {
300
356
  }
301
357
  export interface JsAsset {
302
358
  name: string
303
- source: JsCompatSource
359
+ source?: JsCompatSource
304
360
  info: JsAssetInfo
305
361
  }
306
362
  export interface JsChunk {
@@ -310,10 +366,23 @@ export interface JsChunkGroup {
310
366
  chunks: Array<JsChunk>
311
367
  }
312
368
  export interface JsHooks {
313
- done: (...args: any[]) => any
314
- processAssets: (...args: any[]) => any
369
+ processAssetsStageAdditional: (...args: any[]) => any
370
+ processAssetsStagePreProcess: (...args: any[]) => any
371
+ processAssetsStageNone: (...args: any[]) => any
372
+ processAssetsStageOptimizeInline: (...args: any[]) => any
373
+ processAssetsStageSummarize: (...args: any[]) => any
374
+ processAssetsStageReport: (...args: any[]) => any
315
375
  compilation: (...args: any[]) => any
316
376
  thisCompilation: (...args: any[]) => any
377
+ emit: (...args: any[]) => any
378
+ afterEmit: (...args: any[]) => any
379
+ make: (...args: any[]) => any
380
+ optimizeChunkModule: (...args: any[]) => any
381
+ }
382
+ export interface JsModule {
383
+ originalSource?: JsCompatSource
384
+ resource: string
385
+ moduleIdentifier: string
317
386
  }
318
387
  export interface JsCompatSource {
319
388
  /** Whether the underlying data structure is a `RawSource` */
@@ -354,6 +423,19 @@ export interface JsStatsModule {
354
423
  size: number
355
424
  issuer?: string
356
425
  issuerName?: string
426
+ issuerId?: string
427
+ issuerPath: Array<JsStatsModuleIssuer>
428
+ reasons?: Array<JsStatsModuleReason>
429
+ }
430
+ export interface JsStatsModuleIssuer {
431
+ identifier: string
432
+ name: string
433
+ id: string
434
+ }
435
+ export interface JsStatsModuleReason {
436
+ moduleIdentifier?: string
437
+ moduleName?: string
438
+ moduleId?: string
357
439
  }
358
440
  export interface JsStatsChunk {
359
441
  type: string
@@ -391,31 +473,56 @@ export class JsCompilation {
391
473
  getAssets(): Readonly<JsAsset>[]
392
474
  getAsset(name: string): JsAsset | null
393
475
  getAssetSource(name: string): JsCompatSource | null
476
+ getModules(): Array<JsModule>
477
+ /**
478
+ * Only available for those none Js and Css source,
479
+ * return true if set module source successfully, false if failed.
480
+ */
481
+ setNoneAstModuleSource(moduleIdentifier: string, source: JsCompatSource): boolean
482
+ setAssetSource(name: string, source: JsCompatSource): void
483
+ deleteAssetSource(name: string): void
394
484
  getAssetFilenames(): Array<string>
395
485
  hasAsset(name: string): boolean
396
486
  emitAsset(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
397
487
  deleteAsset(filename: string): void
398
- get assets(): Record<string, JsCompatSource>
399
488
  get entrypoints(): Record<string, JsChunkGroup>
400
489
  get hash(): string
490
+ getFileDependencies(): Array<string>
491
+ getContextDependencies(): Array<string>
492
+ getMissingDependencies(): Array<string>
493
+ getBuildDependencies(): Array<string>
401
494
  pushDiagnostic(severity: "error" | "warning", title: string, message: string): void
495
+ getStats(): JsStats
496
+ addFileDependencies(deps: Array<string>): void
497
+ addContextDependencies(deps: Array<string>): void
498
+ addMissingDependencies(deps: Array<string>): void
499
+ addBuildDependencies(deps: Array<string>): void
500
+ }
501
+ export class JsStats {
502
+ getAssets(): Array<JsStatsAsset>
503
+ getModules(showReasons: boolean): Array<JsStatsModule>
504
+ getChunks(): Array<JsStatsChunk>
505
+ getEntrypoints(): Array<JsStatsEntrypoint>
506
+ getErrors(): Array<JsStatsError>
507
+ getWarnings(): Array<JsStatsWarning>
508
+ getHash(): string
402
509
  }
403
510
  export class Rspack {
404
- constructor(options: RawOptions, jsHooks?: JsHooks | undefined | null)
511
+ constructor(options: RawOptions, jsHooks: JsHooks | undefined | null, outputFilesystem: ThreadsafeNodeFS)
405
512
  /**
406
513
  * Build with the given option passed to the constructor
407
514
  *
408
515
  * Warning:
409
516
  * Calling this method recursively might cause a deadlock.
410
517
  */
411
- unsafe_build(callback: (err: null | Error, result: JsStatsCompilation) => void): void
518
+ unsafe_build(callback: (err: null | Error) => void): void
412
519
  /**
413
520
  * Rebuild with the given option passed to the constructor
414
521
  *
415
522
  * Warning:
416
523
  * Calling this method recursively will cause a deadlock.
417
524
  */
418
- unsafe_rebuild(callback: (err: null | Error, result: Record<string, {content: string, kind: number}>) => void): void
525
+ unsafe_rebuild(changed_files: string[], removed_files: string[], callback: (err: null | Error) => void): void
419
526
  /**
420
527
  * Get the last compilation
421
528
  *
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
+ "license": "MIT",
4
5
  "description": "Node binding for rspack",
5
6
  "main": "binding.js",
6
7
  "types": "binding.d.ts",
@@ -11,18 +12,19 @@
11
12
  "binding.js",
12
13
  "binding.d.ts"
13
14
  ],
14
- "keywords": [],
15
- "author": "",
16
- "license": "ISC",
15
+ "homepage": "https://rspack.org",
16
+ "bugs": "https://github.com/modern-js-dev/rspack/issues",
17
+ "repository": "modern-js-dev/rspack",
17
18
  "devDependencies": {
18
- "@napi-rs/cli": "^2.6.2",
19
+ "@napi-rs/cli": "2.14.2",
19
20
  "why-is-node-running": "2.2.1",
20
21
  "npm-run-all": "4.1.5"
21
22
  },
22
23
  "optionalDependencies": {
23
- "@rspack/binding-darwin-arm64": "0.0.21",
24
- "@rspack/binding-linux-x64-gnu": "0.0.21",
25
- "@rspack/binding-darwin-x64": "0.0.21"
24
+ "@rspack/binding-linux-x64-gnu": "0.0.23",
25
+ "@rspack/binding-darwin-x64": "0.0.23",
26
+ "@rspack/binding-win32-x64-msvc": "0.0.23",
27
+ "@rspack/binding-darwin-arm64": "0.0.23"
26
28
  },
27
29
  "scripts": {
28
30
  "build:debug": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json",
@@ -31,6 +33,7 @@
31
33
  "build:release": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json && pnpm move-binding",
32
34
  "build:release:x64": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json --target x86_64-apple-darwin",
33
35
  "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",
36
+ "build:release:win": "napi build --target x86_64-pc-windows-msvc --release --platform --js false --dts binding.d.ts --config napirs.rc.json",
34
37
  "move-binding": "node scripts/move-binding"
35
38
  }
36
39
  }