@rspack/binding 0.0.9 → 0.0.11

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.
package/binding.d.ts CHANGED
@@ -14,7 +14,8 @@ export interface RawCssPluginConfig {
14
14
  * The preset_env will finally pass into [`browserslist::resolve`](https://docs.rs/browserslist-rs/latest/browserslist/fn.resolve.html).
15
15
  * For detailed configuration, see https://docs.rs/browserslist-rs/latest/browserslist/
16
16
  */
17
- presetEnv: Array<string>
17
+ presetEnv?: Array<string>
18
+ modules?: boolean
18
19
  }
19
20
  export interface RawDecoratorOptions {
20
21
  legacy: boolean
@@ -80,10 +81,18 @@ export interface RawBuiltins {
80
81
  browserslist?: Array<string>
81
82
  define?: Record<string, string>
82
83
  treeShaking?: boolean
84
+ sideEffects?: boolean
83
85
  progress?: RawProgressPluginConfig
84
86
  react?: RawReactOptions
85
87
  decorator?: RawDecoratorOptions
86
88
  }
89
+ export interface RawDevServer {
90
+ hot?: boolean
91
+ }
92
+ export interface RawEntryItem {
93
+ import: Array<string>
94
+ runtime?: string
95
+ }
87
96
  /**
88
97
  * `loader` is for js side loader, `builtin_loader` is for rust side loader,
89
98
  * which is mapped to real rust side loader by [get_builtin_loader].
@@ -101,12 +110,35 @@ export interface RawModuleRuleUse {
101
110
  options?: string
102
111
  loaderName?: string
103
112
  }
113
+ export interface RawModuleRuleCondition {
114
+ /** Condition can be either a `string` or `Regexp`. */
115
+ type: "string" | "regexp"
116
+ /**
117
+ * Based on the condition type, the value can be either a `string` or `Regexp`.
118
+ * - "string": The value will be matched against the string.
119
+ * - "regexp": The value will be matched against the raw regexp source from JS side.
120
+ */
121
+ matcher?: string
122
+ }
104
123
  export interface RawModuleRule {
105
- test?: string
106
- resource?: string
107
- resourceQuery?: string
124
+ /**
125
+ * A condition matcher matching an absolute path.
126
+ * - String: To match the input must start with the provided string. I. e. an absolute directory path, or absolute path to the file.
127
+ * - Regexp: It's tested with the input.
128
+ */
129
+ test?: RawModuleRuleCondition
130
+ /**
131
+ * A condition matcher matching an absolute path.
132
+ * See `test` above
133
+ */
134
+ resource?: RawModuleRuleCondition
135
+ /**
136
+ * A condition matcher against the resource query.
137
+ * TODO: align with webpack's `?` prefixed `resourceQuery`
138
+ */
139
+ resourceQuery?: RawModuleRuleCondition
108
140
  func?: (...args: any[]) => any
109
- uses?: Array<RawModuleRuleUse>
141
+ use?: Array<RawModuleRuleUse>
110
142
  type?: "js" | "jsx" | "ts" | "tsx" | "css" | "json" | "asset" | "asset/resource" | "asset/source" | "asset/inline"
111
143
  }
112
144
  export interface RawAssetParserDataUrlOption {
@@ -131,6 +163,8 @@ export interface RawOutputOptions {
131
163
  assetModuleFilename?: string
132
164
  filename?: string
133
165
  chunkFilename?: string
166
+ cssFilename?: string
167
+ cssChunkFilename?: string
134
168
  uniqueName?: string
135
169
  }
136
170
  export interface RawResolveOptions {
@@ -142,10 +176,10 @@ export interface RawResolveOptions {
142
176
  conditionNames?: Array<string>
143
177
  alias?: Record<string, string | false>
144
178
  symlinks?: boolean
145
- tsconfig?: string
179
+ tsConfigPath?: string
146
180
  }
147
181
  export interface RawSplitChunksOptions {
148
- cacheGroups: Record<string, RawCacheGroupOptions>
182
+ cacheGroups?: Record<string, RawCacheGroupOptions>
149
183
  /** What kind of chunks should be selected. */
150
184
  chunks?: string
151
185
  }
@@ -159,7 +193,7 @@ export interface RawStatsOptions {
159
193
  colors: boolean
160
194
  }
161
195
  export interface RawOptions {
162
- entry?: Record<string, string>
196
+ entry?: Record<string, RawEntryItem>
163
197
  mode?: string
164
198
  target?: string[]
165
199
  context?: string
@@ -172,19 +206,12 @@ export interface RawOptions {
172
206
  devtool?: string
173
207
  optimization?: RawOptimizationOptions
174
208
  stats?: RawStatsOptions
209
+ devServer?: RawDevServer
175
210
  }
176
- export interface AssetContent {
177
- buffer?: Buffer
178
- source?: string
179
- }
180
- export interface UpdateAssetOptions {
181
- asset: AssetContent
182
- filename: string
183
- }
184
- export interface AssetInfoRelated {
211
+ export interface JsAssetInfoRelated {
185
212
  sourceMap?: string
186
213
  }
187
- export interface AssetInfo {
214
+ export interface JsAssetInfo {
188
215
  /**
189
216
  * if the asset can be long term cached forever (contains a hash)
190
217
  * whether the asset is minimized
@@ -200,23 +227,30 @@ export interface AssetInfo {
200
227
  * when asset is only used for development and doesn't count towards user-facing assets
201
228
  */
202
229
  development: boolean
230
+ /** when asset ships data for updating an existing application (HMR) */
231
+ hotModuleReplacement: boolean
203
232
  /**
204
- * when asset ships data for updating an existing application (HMR)
205
233
  * when asset is javascript and an ESM
206
234
  * related object to other assets, keyed by type of relation (only points from parent to child)
207
235
  */
208
- related: AssetInfoRelated
236
+ related: JsAssetInfoRelated
209
237
  }
210
- export interface Asset {
238
+ export interface JsAsset {
211
239
  name: string
212
240
  source: JsCompatSource
213
- info: AssetInfo
241
+ info: JsAssetInfo
242
+ }
243
+ export interface JsChunk {
244
+ files: Array<string>
245
+ }
246
+ export interface JsChunkGroup {
247
+ chunks: Array<JsChunk>
214
248
  }
215
- export interface PluginCallbacks {
216
- doneCallback: (...args: any[]) => any
217
- processAssetsCallback: (...args: any[]) => any
218
- compilationCallback: (...args: any[]) => any
219
- thisCompilationCallback: (...args: any[]) => any
249
+ export interface JsHooks {
250
+ done: (...args: any[]) => any
251
+ processAssets: (...args: any[]) => any
252
+ compilation: (...args: any[]) => any
253
+ thisCompilation: (...args: any[]) => any
220
254
  }
221
255
  export interface JsCompatSource {
222
256
  /** Whether the underlying data structure is a `RawSource` */
@@ -226,39 +260,28 @@ export interface JsCompatSource {
226
260
  source: Buffer
227
261
  map?: Buffer
228
262
  }
229
- export const enum DiffStatKind {
230
- Changed = 0,
231
- Deleted = 1,
232
- Added = 2
233
- }
234
- export interface DiffStat {
235
- content: string
236
- kind: DiffStatKind
237
- }
238
- export interface RebuildResult {
239
- diff: Record<string, DiffStat>
240
- stats: StatsCompilation
241
- }
242
- export interface StatsError {
263
+ export interface JsStatsError {
243
264
  message: string
244
265
  formatted: string
245
266
  }
246
- export interface StatsWarning {
267
+ export interface JsStatsWarning {
247
268
  message: string
248
269
  formatted: string
249
270
  }
250
- export interface StatsAsset {
271
+ export interface JsStatsAsset {
251
272
  type: string
252
273
  name: string
253
274
  size: number
254
275
  chunks: Array<string>
255
276
  chunkNames: Array<string>
256
- info: StatsAssetInfo
277
+ info: JsStatsAssetInfo
278
+ emitted: boolean
257
279
  }
258
- export interface StatsAssetInfo {
280
+ export interface JsStatsAssetInfo {
259
281
  development: boolean
282
+ hotModuleReplacement: boolean
260
283
  }
261
- export interface StatsModule {
284
+ export interface JsStatsModule {
262
285
  type: string
263
286
  moduleType: string
264
287
  identifier: string
@@ -267,7 +290,7 @@ export interface StatsModule {
267
290
  chunks: Array<string>
268
291
  size: number
269
292
  }
270
- export interface StatsChunk {
293
+ export interface JsStatsChunk {
271
294
  type: string
272
295
  files: Array<string>
273
296
  id: string
@@ -276,45 +299,45 @@ export interface StatsChunk {
276
299
  names: Array<string>
277
300
  size: number
278
301
  }
279
- export interface StatsEntrypointAsset {
302
+ export interface JsStatsEntrypointAsset {
280
303
  name: string
281
304
  size: number
282
305
  }
283
- export interface StatsEntrypoint {
306
+ export interface JsStatsEntrypoint {
284
307
  name: string
285
- assets: Array<StatsEntrypointAsset>
308
+ assets: Array<JsStatsEntrypointAsset>
286
309
  chunks: Array<string>
287
310
  assetsSize: number
288
311
  }
289
- export interface StatsCompilation {
290
- assets: Array<StatsAsset>
291
- modules: Array<StatsModule>
292
- chunks: Array<StatsChunk>
293
- entrypoints: Array<StatsEntrypoint>
294
- errors: Array<StatsError>
312
+ export interface JsStatsCompilation {
313
+ assets: Array<JsStatsAsset>
314
+ modules: Array<JsStatsModule>
315
+ chunks: Array<JsStatsChunk>
316
+ entrypoints: Array<JsStatsEntrypoint>
317
+ errors: Array<JsStatsError>
295
318
  errorsCount: number
296
- warnings: Array<StatsWarning>
319
+ warnings: Array<JsStatsWarning>
297
320
  warningsCount: number
298
321
  }
299
- export interface OnLoadContext {
300
- id: string
301
- }
302
322
  export function initCustomTraceSubscriber(): void
303
323
  export class JsCompilation {
304
- updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSource) => JsCompatSource), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo)): void
305
- getAssets(): Readonly<Asset>[]
306
- emitAsset(filename: string, source: JsCompatSource, assetInfo: AssetInfo): void
324
+ updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSource) => JsCompatSource), assetInfoUpdateOrFunction?: JsAssetInfo | ((assetInfo: JsAssetInfo) => JsAssetInfo)): void
325
+ getAssets(): Readonly<JsAsset>[]
326
+ getAsset(name: string): JsAsset | null
327
+ emitAsset(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
328
+ deleteAsset(filename: string): void
307
329
  get assets(): Record<string, JsCompatSource>
330
+ get entrypoints(): Record<string, JsChunkGroup>
308
331
  }
309
332
  export class Rspack {
310
- constructor(options: RawOptions, pluginCallbacks?: PluginCallbacks | undefined | null)
333
+ constructor(options: RawOptions, jsHooks?: JsHooks | undefined | null)
311
334
  /**
312
335
  * Build with the given option passed to the constructor
313
336
  *
314
337
  * Warning:
315
338
  * Calling this method recursively might cause a deadlock.
316
339
  */
317
- unsafe_build(callback: (err: null | Error, result: StatsCompilation) => void): void
340
+ unsafe_build(callback: (err: null | Error, result: JsStatsCompilation) => void): void
318
341
  /**
319
342
  * Rebuild with the given option passed to the constructor
320
343
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/binding",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Node binding for rspack",
5
5
  "main": "binding.js",
6
6
  "types": "binding.d.ts",
@@ -17,11 +17,15 @@
17
17
  "license": "ISC",
18
18
  "devDependencies": {
19
19
  "@napi-rs/cli": "^2.6.2",
20
- "why-is-node-running": "2.2.1"
20
+ "why-is-node-running": "2.2.1",
21
+ "npm-run-all": "4.1.5"
21
22
  },
22
23
  "scripts": {
23
- "build": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json",
24
+ "build:debug": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json",
25
+ "build:debug:x64": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json --target x86_64-apple-darwin",
26
+ "build:release:all": "run-p build:release build:release:x64 build:release:linux",
24
27
  "build:release": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json",
25
- "build_linux:release": "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"
28
+ "build:release:x64": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json --target x86_64-apple-darwin",
29
+ "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"
26
30
  }
27
31
  }
Binary file
Binary file