@rspack/binding 1.2.5 → 1.2.7-alpha.0

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 +43 -47
  2. package/package.json +11 -11
package/binding.d.ts CHANGED
@@ -4,11 +4,13 @@
4
4
  /* -- banner.d.ts -- */
5
5
  export type JsFilename =
6
6
  | string
7
- | ((pathData: JsPathData, assetInfo?: JsAssetInfo) => string);
7
+ | ((pathData: JsPathData, assetInfo?: AssetInfo) => string);
8
8
 
9
9
  export type LocalJsFilename = JsFilename;
10
10
 
11
11
  export type RawLazyCompilationTest = RegExp | ((m: JsModule) => boolean);
12
+
13
+ export type AssetInfo = KnownAssetInfo & Record<string, any>;
12
14
  /* -- banner.d.ts end -- */
13
15
 
14
16
  /* -- napi-rs generated below -- */
@@ -97,7 +99,7 @@ export declare class JsChunkGroup {
97
99
  }
98
100
 
99
101
  export declare class JsCompilation {
100
- updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSourceOwned) => JsCompatSourceOwned), assetInfoUpdateOrFunction?: JsAssetInfo | ((assetInfo: JsAssetInfo) => JsAssetInfo)): void
102
+ updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSourceOwned) => JsCompatSourceOwned), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo)): void
101
103
  getAssets(): Readonly<JsAsset>[]
102
104
  getAsset(name: string): JsAsset | null
103
105
  getAssetSource(name: string): JsCompatSource | null
@@ -113,7 +115,7 @@ export declare class JsCompilation {
113
115
  deleteAssetSource(name: string): void
114
116
  getAssetFilenames(): Array<string>
115
117
  hasAsset(name: string): boolean
116
- emitAsset(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
118
+ emitAsset(filename: string, source: JsCompatSource, jsAssetInfo?: AssetInfo | undefined | null): void
117
119
  deleteAsset(filename: string): void
118
120
  renameAsset(filename: string, newName: string): void
119
121
  get entrypoints(): JsChunkGroup[]
@@ -251,7 +253,7 @@ export declare class JsModule {
251
253
  libIdent(options: JsLibIdentOptions): string | null
252
254
  get resourceResolveData(): JsResourceData | undefined
253
255
  get matchResource(): string | undefined
254
- emitFile(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
256
+ emitFile(filename: string, source: JsCompatSource, jsAssetInfo?: AssetInfo | undefined | null): void
255
257
  }
256
258
 
257
259
  export declare class JsModuleGraph {
@@ -452,7 +454,7 @@ export interface JsAlterAssetTagsData {
452
454
 
453
455
  export interface JsAsset {
454
456
  name: string
455
- info: JsAssetInfo
457
+ info: AssetInfo
456
458
  }
457
459
 
458
460
  export interface JsAssetEmittedArgs {
@@ -461,47 +463,6 @@ export interface JsAssetEmittedArgs {
461
463
  targetPath: string
462
464
  }
463
465
 
464
- export interface JsAssetInfo {
465
- /** if the asset can be long term cached forever (contains a hash) */
466
- immutable?: boolean
467
- /** whether the asset is minimized */
468
- minimized?: boolean
469
- /** the value(s) of the full hash used for this asset */
470
- fullhash: Array<string>
471
- /** the value(s) of the chunk hash used for this asset */
472
- chunkhash: Array<string>
473
- /**
474
- * the value(s) of the module hash used for this asset
475
- * the value(s) of the content hash used for this asset
476
- */
477
- contenthash: Array<string>
478
- sourceFilename?: string
479
- /** when asset was created from a source file (potentially transformed), it should be flagged as copied */
480
- copied?: boolean
481
- /**
482
- * size in bytes, only set after asset has been emitted
483
- * when asset is only used for development and doesn't count towards user-facing assets
484
- */
485
- development?: boolean
486
- /** when asset ships data for updating an existing application (HMR) */
487
- hotModuleReplacement?: boolean
488
- /** when asset is javascript and an ESM */
489
- javascriptModule?: boolean
490
- /** related object to other assets, keyed by type of relation (only points from parent to child) */
491
- related: JsAssetInfoRelated
492
- /** unused css local ident for the css chunk */
493
- cssUnusedIdents?: Array<string>
494
- /**
495
- * Webpack: AssetInfo = KnownAssetInfo & Record<string, any>
496
- * But Napi.rs does not support Intersectiont types. This is a hack to store the additional fields
497
- * in the rust struct and have the Js side to reshape and align with webpack
498
- * Related: packages/rspack/src/Compilation.ts
499
- */
500
- extras: Record<string, any>
501
- /** whether this asset is over the size limit */
502
- isOverSizeLimit?: boolean
503
- }
504
-
505
466
  export interface JsAssetInfoRelated {
506
467
  sourceMap?: string
507
468
  }
@@ -1305,6 +1266,41 @@ export interface JsTap {
1305
1266
  stage: number
1306
1267
  }
1307
1268
 
1269
+ export interface KnownAssetInfo {
1270
+ /** if the asset can be long term cached forever (contains a hash) */
1271
+ immutable?: boolean
1272
+ /** whether the asset is minimized */
1273
+ minimized?: boolean
1274
+ /** the value(s) of the full hash used for this asset */
1275
+ fullhash?: string | Array<string>
1276
+ /** the value(s) of the chunk hash used for this asset */
1277
+ chunkhash?: string | Array<string>
1278
+ /**
1279
+ * the value(s) of the module hash used for this asset
1280
+ * the value(s) of the content hash used for this asset
1281
+ */
1282
+ contenthash?: string | Array<string>
1283
+ /** when asset was created from a source file (potentially transformed), the original filename relative to compilation context */
1284
+ sourceFilename?: string
1285
+ /** when asset was created from a source file (potentially transformed), it should be flagged as copied */
1286
+ copied?: boolean
1287
+ /**
1288
+ * size in bytes, only set after asset has been emitted
1289
+ * when asset is only used for development and doesn't count towards user-facing assets
1290
+ */
1291
+ development?: boolean
1292
+ /** when asset ships data for updating an existing application (HMR) */
1293
+ hotModuleReplacement?: boolean
1294
+ /** when asset is javascript and an ESM */
1295
+ javascriptModule?: boolean
1296
+ /** related object to other assets, keyed by type of relation (only points from parent to child) */
1297
+ related?: JsAssetInfoRelated
1298
+ /** unused css local ident for the css chunk */
1299
+ cssUnusedIdents?: Array<string>
1300
+ /** whether this asset is over the size limit */
1301
+ isOverSizeLimit?: boolean
1302
+ }
1303
+
1308
1304
  export interface NodeFsStats {
1309
1305
  isFile: boolean
1310
1306
  isDirectory: boolean
@@ -1318,7 +1314,7 @@ export interface NodeFsStats {
1318
1314
 
1319
1315
  export interface PathWithInfo {
1320
1316
  path: string
1321
- info: JsAssetInfo
1317
+ info: AssetInfo
1322
1318
  }
1323
1319
 
1324
1320
  export interface RawAliasOptionItem {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "1.2.5",
3
+ "version": "1.2.7-alpha.0",
4
4
  "license": "MIT",
5
5
  "description": "Node binding for rspack",
6
6
  "main": "binding.js",
@@ -17,22 +17,22 @@
17
17
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
18
18
  "repository": "web-infra-dev/rspack",
19
19
  "devDependencies": {
20
- "@napi-rs/cli": "3.0.0-alpha.65",
20
+ "@napi-rs/cli": "3.0.0-alpha.72",
21
21
  "typescript": "^5.7.3"
22
22
  },
23
23
  "napi": {
24
24
  "binaryName": "rspack"
25
25
  },
26
26
  "optionalDependencies": {
27
- "@rspack/binding-darwin-arm64": "1.2.5",
28
- "@rspack/binding-linux-arm64-gnu": "1.2.5",
29
- "@rspack/binding-linux-arm64-musl": "1.2.5",
30
- "@rspack/binding-win32-arm64-msvc": "1.2.5",
31
- "@rspack/binding-win32-ia32-msvc": "1.2.5",
32
- "@rspack/binding-win32-x64-msvc": "1.2.5",
33
- "@rspack/binding-darwin-x64": "1.2.5",
34
- "@rspack/binding-linux-x64-gnu": "1.2.5",
35
- "@rspack/binding-linux-x64-musl": "1.2.5"
27
+ "@rspack/binding-darwin-arm64": "1.2.7-alpha.0",
28
+ "@rspack/binding-win32-arm64-msvc": "1.2.7-alpha.0",
29
+ "@rspack/binding-linux-arm64-musl": "1.2.7-alpha.0",
30
+ "@rspack/binding-linux-arm64-gnu": "1.2.7-alpha.0",
31
+ "@rspack/binding-darwin-x64": "1.2.7-alpha.0",
32
+ "@rspack/binding-win32-ia32-msvc": "1.2.7-alpha.0",
33
+ "@rspack/binding-win32-x64-msvc": "1.2.7-alpha.0",
34
+ "@rspack/binding-linux-x64-gnu": "1.2.7-alpha.0",
35
+ "@rspack/binding-linux-x64-musl": "1.2.7-alpha.0"
36
36
  },
37
37
  "scripts": {
38
38
  "build:dev": "node scripts/build.js",