@rspack/binding 0.0.7 → 0.0.8
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 +227 -21
- package/package.json +1 -1
- package/rspack.darwin-arm64.node +0 -0
- package/rspack.linux-x64-gnu.node +0 -0
package/binding.d.ts
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
export class ExternalObject<T> {
|
|
7
|
-
readonly '': {
|
|
8
|
-
readonly '': unique symbol
|
|
9
|
-
[K: symbol]: T
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
6
|
export interface RawCssPluginConfig {
|
|
13
7
|
/**
|
|
14
8
|
* ## Example
|
|
@@ -22,6 +16,11 @@ export interface RawCssPluginConfig {
|
|
|
22
16
|
*/
|
|
23
17
|
presetEnv: Array<string>
|
|
24
18
|
}
|
|
19
|
+
export interface RawDecoratorOptions {
|
|
20
|
+
legacy: boolean
|
|
21
|
+
emitMetadata: boolean
|
|
22
|
+
useDefineForClassFields: boolean
|
|
23
|
+
}
|
|
25
24
|
/**
|
|
26
25
|
* It seems napi not support enum well
|
|
27
26
|
*/
|
|
@@ -30,6 +29,7 @@ export interface RawHtmlPluginConfig {
|
|
|
30
29
|
filename?: string | void
|
|
31
30
|
/** template html file */
|
|
32
31
|
template?: string
|
|
32
|
+
templateParameters?: Record<string, string>
|
|
33
33
|
/** `head`, `body` or None */
|
|
34
34
|
inject?: string | void
|
|
35
35
|
/** path or `auto` */
|
|
@@ -40,10 +40,49 @@ export interface RawHtmlPluginConfig {
|
|
|
40
40
|
chunks?: Array<string>
|
|
41
41
|
excludedChunks?: Array<string>
|
|
42
42
|
sri?: string | void
|
|
43
|
+
minify?: boolean
|
|
44
|
+
title?: string
|
|
45
|
+
favicon?: string
|
|
46
|
+
meta?: Record<string, Record<string, string>>
|
|
47
|
+
}
|
|
48
|
+
export interface RawPostCssConfig {
|
|
49
|
+
pxtorem?: RawPxToRemConfig
|
|
50
|
+
}
|
|
51
|
+
export interface RawPxToRemConfig {
|
|
52
|
+
rootValue?: number
|
|
53
|
+
unitPrecision?: number
|
|
54
|
+
selectorBlackList?: Array<string>
|
|
55
|
+
propList?: Array<string>
|
|
56
|
+
replace?: boolean
|
|
57
|
+
mediaQuery?: boolean
|
|
58
|
+
minPixelValue?: number
|
|
59
|
+
}
|
|
60
|
+
export interface RawProgressPluginConfig {
|
|
61
|
+
prefix?: string
|
|
62
|
+
}
|
|
63
|
+
export interface RawReactOptions {
|
|
64
|
+
runtime?: string
|
|
65
|
+
importSource?: string
|
|
66
|
+
pragma?: string
|
|
67
|
+
pragmaFrag?: string
|
|
68
|
+
throwIfNamespace?: boolean
|
|
69
|
+
development?: boolean
|
|
70
|
+
useBuiltins?: boolean
|
|
71
|
+
useSpread?: boolean
|
|
72
|
+
refresh?: boolean
|
|
43
73
|
}
|
|
44
74
|
export interface RawBuiltins {
|
|
45
75
|
html?: Array<RawHtmlPluginConfig>
|
|
46
76
|
css?: RawCssPluginConfig
|
|
77
|
+
postcss?: RawPostCssConfig
|
|
78
|
+
minify?: boolean
|
|
79
|
+
polyfill?: boolean
|
|
80
|
+
browserslist?: Array<string>
|
|
81
|
+
define?: Record<string, string>
|
|
82
|
+
treeShaking?: boolean
|
|
83
|
+
progress?: RawProgressPluginConfig
|
|
84
|
+
react?: RawReactOptions
|
|
85
|
+
decorator?: RawDecoratorOptions
|
|
47
86
|
}
|
|
48
87
|
/**
|
|
49
88
|
* `loader` is for js side loader, `builtin_loader` is for rust side loader,
|
|
@@ -83,6 +122,9 @@ export interface RawModuleOptions {
|
|
|
83
122
|
rules: Array<RawModuleRule>
|
|
84
123
|
parser?: RawParserOptions
|
|
85
124
|
}
|
|
125
|
+
export interface RawOptimizationOptions {
|
|
126
|
+
splitChunks?: RawSplitChunksOptions
|
|
127
|
+
}
|
|
86
128
|
export interface RawOutputOptions {
|
|
87
129
|
path?: string
|
|
88
130
|
publicPath?: string
|
|
@@ -93,6 +135,28 @@ export interface RawOutputOptions {
|
|
|
93
135
|
}
|
|
94
136
|
export interface RawResolveOptions {
|
|
95
137
|
preferRelative?: boolean
|
|
138
|
+
extensions?: Array<string>
|
|
139
|
+
mainFiles?: Array<string>
|
|
140
|
+
mainFields?: Array<string>
|
|
141
|
+
browserField?: boolean
|
|
142
|
+
conditionNames?: Array<string>
|
|
143
|
+
alias?: Record<string, string | false>
|
|
144
|
+
symlinks?: boolean
|
|
145
|
+
tsconfig?: string
|
|
146
|
+
}
|
|
147
|
+
export interface RawSplitChunksOptions {
|
|
148
|
+
cacheGroups: Record<string, RawCacheGroupOptions>
|
|
149
|
+
/** What kind of chunks should be selected. */
|
|
150
|
+
chunks?: string
|
|
151
|
+
}
|
|
152
|
+
export interface RawCacheGroupOptions {
|
|
153
|
+
test: string
|
|
154
|
+
/** What kind of chunks should be selected. */
|
|
155
|
+
chunks?: string
|
|
156
|
+
name: string
|
|
157
|
+
}
|
|
158
|
+
export interface RawStatsOptions {
|
|
159
|
+
colors: boolean
|
|
96
160
|
}
|
|
97
161
|
export interface RawOptions {
|
|
98
162
|
entry?: Record<string, string>
|
|
@@ -103,13 +167,12 @@ export interface RawOptions {
|
|
|
103
167
|
resolve?: RawResolveOptions
|
|
104
168
|
module?: RawModuleOptions
|
|
105
169
|
builtins?: RawBuiltins
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
170
|
+
externals?: Record<string, string>
|
|
171
|
+
externalsType?: string
|
|
172
|
+
devtool?: string
|
|
173
|
+
optimization?: RawOptimizationOptions
|
|
174
|
+
stats?: RawStatsOptions
|
|
111
175
|
}
|
|
112
|
-
export function initCustomTraceSubscriber(): void
|
|
113
176
|
export interface AssetContent {
|
|
114
177
|
buffer?: Buffer
|
|
115
178
|
source?: string
|
|
@@ -118,20 +181,163 @@ export interface UpdateAssetOptions {
|
|
|
118
181
|
asset: AssetContent
|
|
119
182
|
filename: string
|
|
120
183
|
}
|
|
184
|
+
export interface AssetInfoRelated {
|
|
185
|
+
sourceMap?: string
|
|
186
|
+
}
|
|
187
|
+
export interface AssetInfo {
|
|
188
|
+
/**
|
|
189
|
+
* if the asset can be long term cached forever (contains a hash)
|
|
190
|
+
* whether the asset is minimized
|
|
191
|
+
*/
|
|
192
|
+
minimized: boolean
|
|
193
|
+
/**
|
|
194
|
+
* the value(s) of the full hash used for this asset
|
|
195
|
+
* the value(s) of the chunk hash used for this asset
|
|
196
|
+
* the value(s) of the module hash used for this asset
|
|
197
|
+
* the value(s) of the content hash used for this asset
|
|
198
|
+
* when asset was created from a source file (potentially transformed), the original filename relative to compilation context
|
|
199
|
+
* size in bytes, only set after asset has been emitted
|
|
200
|
+
* when asset is only used for development and doesn't count towards user-facing assets
|
|
201
|
+
*/
|
|
202
|
+
development: boolean
|
|
203
|
+
/**
|
|
204
|
+
* when asset ships data for updating an existing application (HMR)
|
|
205
|
+
* when asset is javascript and an ESM
|
|
206
|
+
* related object to other assets, keyed by type of relation (only points from parent to child)
|
|
207
|
+
*/
|
|
208
|
+
related: AssetInfoRelated
|
|
209
|
+
}
|
|
210
|
+
export interface Asset {
|
|
211
|
+
name: string
|
|
212
|
+
source: JsCompatSource
|
|
213
|
+
info: AssetInfo
|
|
214
|
+
}
|
|
121
215
|
export interface PluginCallbacks {
|
|
122
216
|
doneCallback: (...args: any[]) => any
|
|
123
217
|
processAssetsCallback: (...args: any[]) => any
|
|
218
|
+
compilationCallback: (...args: any[]) => any
|
|
219
|
+
thisCompilationCallback: (...args: any[]) => any
|
|
220
|
+
}
|
|
221
|
+
export interface JsCompatSource {
|
|
222
|
+
/** Whether the underlying data structure is a `RawSource` */
|
|
223
|
+
isRaw: boolean
|
|
224
|
+
/** Whether the underlying value is a buffer or string */
|
|
225
|
+
isBuffer: boolean
|
|
226
|
+
source: Buffer
|
|
227
|
+
map?: Buffer
|
|
124
228
|
}
|
|
125
|
-
export
|
|
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 {
|
|
126
243
|
message: string
|
|
244
|
+
formatted: string
|
|
245
|
+
}
|
|
246
|
+
export interface StatsWarning {
|
|
247
|
+
message: string
|
|
248
|
+
formatted: string
|
|
249
|
+
}
|
|
250
|
+
export interface StatsAsset {
|
|
251
|
+
type: string
|
|
252
|
+
name: string
|
|
253
|
+
size: number
|
|
254
|
+
chunks: Array<string>
|
|
255
|
+
chunkNames: Array<string>
|
|
256
|
+
info: StatsAssetInfo
|
|
257
|
+
}
|
|
258
|
+
export interface StatsAssetInfo {
|
|
259
|
+
development: boolean
|
|
260
|
+
}
|
|
261
|
+
export interface StatsModule {
|
|
262
|
+
type: string
|
|
263
|
+
moduleType: string
|
|
264
|
+
identifier: string
|
|
265
|
+
name: string
|
|
266
|
+
id: string
|
|
267
|
+
chunks: Array<string>
|
|
268
|
+
size: number
|
|
269
|
+
}
|
|
270
|
+
export interface StatsChunk {
|
|
271
|
+
type: string
|
|
272
|
+
files: Array<string>
|
|
273
|
+
id: string
|
|
274
|
+
entry: boolean
|
|
275
|
+
initial: boolean
|
|
276
|
+
names: Array<string>
|
|
277
|
+
size: number
|
|
278
|
+
}
|
|
279
|
+
export interface StatsEntrypointAsset {
|
|
280
|
+
name: string
|
|
281
|
+
size: number
|
|
282
|
+
}
|
|
283
|
+
export interface StatsEntrypoint {
|
|
284
|
+
name: string
|
|
285
|
+
assets: Array<StatsEntrypointAsset>
|
|
286
|
+
chunks: Array<string>
|
|
287
|
+
assetsSize: number
|
|
127
288
|
}
|
|
128
|
-
export interface
|
|
129
|
-
|
|
289
|
+
export interface StatsCompilation {
|
|
290
|
+
assets: Array<StatsAsset>
|
|
291
|
+
modules: Array<StatsModule>
|
|
292
|
+
chunks: Array<StatsChunk>
|
|
293
|
+
entrypoints: Array<StatsEntrypoint>
|
|
294
|
+
errors: Array<StatsError>
|
|
295
|
+
errorsCount: number
|
|
296
|
+
warnings: Array<StatsWarning>
|
|
297
|
+
warningsCount: number
|
|
130
298
|
}
|
|
131
|
-
export
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
export function
|
|
135
|
-
export
|
|
136
|
-
|
|
299
|
+
export interface OnLoadContext {
|
|
300
|
+
id: string
|
|
301
|
+
}
|
|
302
|
+
export function initCustomTraceSubscriber(): void
|
|
303
|
+
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
|
|
307
|
+
get assets(): Record<string, JsCompatSource>
|
|
308
|
+
}
|
|
309
|
+
export class Rspack {
|
|
310
|
+
constructor(options: RawOptions, pluginCallbacks?: PluginCallbacks | undefined | null)
|
|
311
|
+
/**
|
|
312
|
+
* Build with the given option passed to the constructor
|
|
313
|
+
*
|
|
314
|
+
* Warning:
|
|
315
|
+
* Calling this method recursively might cause a deadlock.
|
|
316
|
+
*/
|
|
317
|
+
unsafe_build(callback: (err: null | Error, result: StatsCompilation) => void): void
|
|
318
|
+
/**
|
|
319
|
+
* Rebuild with the given option passed to the constructor
|
|
320
|
+
*
|
|
321
|
+
* Warning:
|
|
322
|
+
* Calling this method recursively will cause a deadlock.
|
|
323
|
+
*/
|
|
324
|
+
unsafe_rebuild(callback: (err: null | Error, result: Record<string, {content: string, kind: number}>) => void): void
|
|
325
|
+
/**
|
|
326
|
+
* Get the last compilation
|
|
327
|
+
*
|
|
328
|
+
* Warning:
|
|
329
|
+
*
|
|
330
|
+
* Calling this method under the build or rebuild method might cause a deadlock.
|
|
331
|
+
*
|
|
332
|
+
* **Note** that this method is not safe if you cache the _JsCompilation_ on the Node side, as it will be invalidated by the next build and accessing a dangling ptr is a UB.
|
|
333
|
+
*/
|
|
334
|
+
unsafe_last_compilation(f: (arg0: JsCompilation) => void): void
|
|
335
|
+
/**
|
|
336
|
+
* Destroy the compiler
|
|
337
|
+
*
|
|
338
|
+
* Warning:
|
|
339
|
+
*
|
|
340
|
+
* Anything related to this compiler will be invalidated after this method is called.
|
|
341
|
+
*/
|
|
342
|
+
unsafe_drop(): void
|
|
137
343
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|