@rspack/binding 0.0.0-0074001a71-20230224065505
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/LICENSE +22 -0
- package/README.md +16 -0
- package/binding.d.ts +544 -0
- package/binding.js +221 -0
- package/package.json +39 -0
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/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://lf3-static.bytednsdoc.com/obj/eden-cn/rjhwzy/ljhwZthlaukjlkulzlp/rspack-banner-1610-dark.png">
|
|
3
|
+
<img alt="Rspack Banner" src="https://lf3-static.bytednsdoc.com/obj/eden-cn/rjhwzy/ljhwZthlaukjlkulzlp/rspack-banner-1610.png">
|
|
4
|
+
</picture>
|
|
5
|
+
|
|
6
|
+
# @rspack/binding
|
|
7
|
+
|
|
8
|
+
Node binding for rspack.
|
|
9
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
|
|
12
|
+
See [https://rspack.org](https://rspack.org) for details.
|
|
13
|
+
|
|
14
|
+
## License
|
|
15
|
+
|
|
16
|
+
Rspack is [MIT licensed](https://github.com/modern-js-dev/rspack/blob/main/LICENSE).
|
package/binding.d.ts
ADDED
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
export interface RawPattern {
|
|
7
|
+
from: string
|
|
8
|
+
to?: string
|
|
9
|
+
context?: string
|
|
10
|
+
toType?: string
|
|
11
|
+
noErrorOnMissing: boolean
|
|
12
|
+
force: boolean
|
|
13
|
+
priority: number
|
|
14
|
+
globOptions: RawGlobOptions
|
|
15
|
+
}
|
|
16
|
+
export interface RawGlobOptions {
|
|
17
|
+
caseSensitiveMatch?: boolean
|
|
18
|
+
dot?: boolean
|
|
19
|
+
}
|
|
20
|
+
export interface RawCopyConfig {
|
|
21
|
+
patterns: Array<RawPattern>
|
|
22
|
+
}
|
|
23
|
+
export interface RawCssPluginConfig {
|
|
24
|
+
modules: RawCssModulesConfig
|
|
25
|
+
}
|
|
26
|
+
export interface RawCssModulesConfig {
|
|
27
|
+
localsConvention: string
|
|
28
|
+
localIdentName: string
|
|
29
|
+
exportsOnly: boolean
|
|
30
|
+
}
|
|
31
|
+
export interface RawDecoratorOptions {
|
|
32
|
+
legacy: boolean
|
|
33
|
+
emitMetadata: boolean
|
|
34
|
+
}
|
|
35
|
+
export interface RawHtmlPluginConfig {
|
|
36
|
+
/** emitted file name in output path */
|
|
37
|
+
filename?: string
|
|
38
|
+
/** template html file */
|
|
39
|
+
template?: string
|
|
40
|
+
templateParameters?: Record<string, string>
|
|
41
|
+
/** `head`, `body` or None */
|
|
42
|
+
inject?: "head" | "body"
|
|
43
|
+
/** path or `auto` */
|
|
44
|
+
publicPath?: string
|
|
45
|
+
/** `blocking`, `defer`, or `module` */
|
|
46
|
+
scriptLoading?: "blocking" | "defer" | "module"
|
|
47
|
+
/** entry_chunk_name (only entry chunks are supported) */
|
|
48
|
+
chunks?: Array<string>
|
|
49
|
+
excludedChunks?: Array<string>
|
|
50
|
+
sri?: "sha256" | "sha384" | "sha512"
|
|
51
|
+
minify?: boolean
|
|
52
|
+
title?: string
|
|
53
|
+
favicon?: string
|
|
54
|
+
meta?: Record<string, Record<string, string>>
|
|
55
|
+
}
|
|
56
|
+
export interface RawPostCssConfig {
|
|
57
|
+
pxtorem?: RawPxToRemConfig
|
|
58
|
+
}
|
|
59
|
+
export interface RawPxToRemConfig {
|
|
60
|
+
rootValue?: number
|
|
61
|
+
unitPrecision?: number
|
|
62
|
+
selectorBlackList?: Array<string>
|
|
63
|
+
propList?: Array<string>
|
|
64
|
+
replace?: boolean
|
|
65
|
+
mediaQuery?: boolean
|
|
66
|
+
minPixelValue?: number
|
|
67
|
+
}
|
|
68
|
+
export interface RawProgressPluginConfig {
|
|
69
|
+
prefix?: string
|
|
70
|
+
}
|
|
71
|
+
export interface RawReactOptions {
|
|
72
|
+
runtime?: "automatic" | "classic"
|
|
73
|
+
importSource?: string
|
|
74
|
+
pragma?: string
|
|
75
|
+
pragmaFrag?: string
|
|
76
|
+
throwIfNamespace?: boolean
|
|
77
|
+
development?: boolean
|
|
78
|
+
useBuiltins?: boolean
|
|
79
|
+
useSpread?: boolean
|
|
80
|
+
refresh?: boolean
|
|
81
|
+
}
|
|
82
|
+
export interface RawMinification {
|
|
83
|
+
passes: number
|
|
84
|
+
dropConsole: boolean
|
|
85
|
+
pureFuncs: Array<string>
|
|
86
|
+
}
|
|
87
|
+
export interface RawPresetEnv {
|
|
88
|
+
targets: Array<string>
|
|
89
|
+
mode?: 'usage' | 'entry'
|
|
90
|
+
coreJs?: string
|
|
91
|
+
}
|
|
92
|
+
export interface RawBuiltins {
|
|
93
|
+
html?: Array<RawHtmlPluginConfig>
|
|
94
|
+
css?: RawCssPluginConfig
|
|
95
|
+
postcss?: RawPostCssConfig
|
|
96
|
+
minifyOptions?: RawMinification
|
|
97
|
+
presetEnv?: RawPresetEnv
|
|
98
|
+
define: Record<string, string>
|
|
99
|
+
treeShaking: boolean
|
|
100
|
+
progress?: RawProgressPluginConfig
|
|
101
|
+
react: RawReactOptions
|
|
102
|
+
decorator?: RawDecoratorOptions
|
|
103
|
+
noEmitAssets: boolean
|
|
104
|
+
emotion?: string
|
|
105
|
+
devFriendlySplitChunks: boolean
|
|
106
|
+
copy?: RawCopyConfig
|
|
107
|
+
}
|
|
108
|
+
export interface RawCacheOptions {
|
|
109
|
+
type: string
|
|
110
|
+
maxGenerations: number
|
|
111
|
+
maxAge: number
|
|
112
|
+
profile: boolean
|
|
113
|
+
buildDependencies: Array<string>
|
|
114
|
+
cacheDirectory: string
|
|
115
|
+
cacheLocation: string
|
|
116
|
+
name: string
|
|
117
|
+
version: string
|
|
118
|
+
}
|
|
119
|
+
export interface RawDevServer {
|
|
120
|
+
hot: boolean
|
|
121
|
+
}
|
|
122
|
+
export interface RawEntryItem {
|
|
123
|
+
import: Array<string>
|
|
124
|
+
runtime?: string
|
|
125
|
+
}
|
|
126
|
+
export interface RawExperiments {
|
|
127
|
+
lazyCompilation: boolean
|
|
128
|
+
incrementalRebuild: boolean
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* `loader` is for js side loader, `builtin_loader` is for rust side loader,
|
|
132
|
+
* which is mapped to real rust side loader by [get_builtin_loader].
|
|
133
|
+
*
|
|
134
|
+
* `options` is
|
|
135
|
+
* - a `None` on rust side and handled by js side `getOptions` when
|
|
136
|
+
* using with `loader`.
|
|
137
|
+
* - a `Some(string)` on rust side, deserialized by `serde_json::from_str`
|
|
138
|
+
* and passed to rust side loader in [get_builtin_loader] when using with
|
|
139
|
+
* `builtin_loader`.
|
|
140
|
+
*/
|
|
141
|
+
export interface RawModuleRuleUse {
|
|
142
|
+
jsLoader?: JsLoader
|
|
143
|
+
builtinLoader?: string
|
|
144
|
+
options?: string
|
|
145
|
+
}
|
|
146
|
+
export interface JsLoader {
|
|
147
|
+
/** composed loader name, xx-loader!yy-loader!zz-loader */
|
|
148
|
+
name: string
|
|
149
|
+
func: (...args: any[]) => any
|
|
150
|
+
}
|
|
151
|
+
export interface RawModuleRuleCondition {
|
|
152
|
+
/** Condition can be either a `string` or `Regexp`. */
|
|
153
|
+
type: "string" | "regexp"
|
|
154
|
+
/**
|
|
155
|
+
* Based on the condition type, the value can be either a `string` or `Regexp`.
|
|
156
|
+
* - "string": The value will be matched against the string.
|
|
157
|
+
* - "regexp": The value will be matched against the raw regexp source from JS side.
|
|
158
|
+
*/
|
|
159
|
+
matcher?: string
|
|
160
|
+
}
|
|
161
|
+
export interface RawIssuerOptions {
|
|
162
|
+
not?: Array<RawModuleRuleCondition>
|
|
163
|
+
}
|
|
164
|
+
export interface RawModuleRule {
|
|
165
|
+
/**
|
|
166
|
+
* A condition matcher matching an absolute path.
|
|
167
|
+
* - String: To match the input must start with the provided string. I. e. an absolute directory path, or absolute path to the file.
|
|
168
|
+
* - Regexp: It's tested with the input.
|
|
169
|
+
*/
|
|
170
|
+
test?: RawModuleRuleCondition
|
|
171
|
+
include?: Array<RawModuleRuleCondition>
|
|
172
|
+
exclude?: Array<RawModuleRuleCondition>
|
|
173
|
+
/**
|
|
174
|
+
* A condition matcher matching an absolute path.
|
|
175
|
+
* See `test` above
|
|
176
|
+
*/
|
|
177
|
+
resource?: RawModuleRuleCondition
|
|
178
|
+
/**
|
|
179
|
+
* A condition matcher against the resource query.
|
|
180
|
+
* TODO: align with webpack's `?` prefixed `resourceQuery`
|
|
181
|
+
*/
|
|
182
|
+
resourceQuery?: RawModuleRuleCondition
|
|
183
|
+
sideEffects?: boolean
|
|
184
|
+
use?: Array<RawModuleRuleUse>
|
|
185
|
+
type?: string
|
|
186
|
+
parser?: RawModuleRuleParser
|
|
187
|
+
generator?: RawModuleRuleGenerator
|
|
188
|
+
resolve?: RawResolveOptions
|
|
189
|
+
issuer?: RawIssuerOptions
|
|
190
|
+
oneOf?: Array<RawModuleRule>
|
|
191
|
+
}
|
|
192
|
+
export interface RawModuleRuleGenerator {
|
|
193
|
+
filename?: string
|
|
194
|
+
}
|
|
195
|
+
export interface RawModuleRuleParser {
|
|
196
|
+
dataUrlCondition?: RawAssetParserDataUrlOption
|
|
197
|
+
}
|
|
198
|
+
export interface RawAssetParserDataUrlOption {
|
|
199
|
+
maxSize?: number
|
|
200
|
+
}
|
|
201
|
+
export interface RawAssetParserOptions {
|
|
202
|
+
dataUrlCondition?: RawAssetParserDataUrlOption
|
|
203
|
+
}
|
|
204
|
+
export interface RawParserOptions {
|
|
205
|
+
asset?: RawAssetParserOptions
|
|
206
|
+
}
|
|
207
|
+
export interface RawModuleOptions {
|
|
208
|
+
rules: Array<RawModuleRule>
|
|
209
|
+
parser?: RawParserOptions
|
|
210
|
+
}
|
|
211
|
+
export interface JsLoaderContext {
|
|
212
|
+
content: Buffer
|
|
213
|
+
additionalData?: Buffer
|
|
214
|
+
sourceMap?: Buffer
|
|
215
|
+
resource: string
|
|
216
|
+
resourcePath: string
|
|
217
|
+
resourceQuery?: string
|
|
218
|
+
resourceFragment?: string
|
|
219
|
+
cacheable: boolean
|
|
220
|
+
fileDependencies: Array<string>
|
|
221
|
+
contextDependencies: Array<string>
|
|
222
|
+
missingDependencies: Array<string>
|
|
223
|
+
buildDependencies: Array<string>
|
|
224
|
+
}
|
|
225
|
+
export interface JsLoaderResult {
|
|
226
|
+
content: Buffer
|
|
227
|
+
fileDependencies: Array<string>
|
|
228
|
+
contextDependencies: Array<string>
|
|
229
|
+
missingDependencies: Array<string>
|
|
230
|
+
buildDependencies: Array<string>
|
|
231
|
+
sourceMap?: Buffer
|
|
232
|
+
additionalData?: Buffer
|
|
233
|
+
cacheable: boolean
|
|
234
|
+
}
|
|
235
|
+
export interface RawNodeOption {
|
|
236
|
+
dirname: string
|
|
237
|
+
}
|
|
238
|
+
export interface RawOptimizationOptions {
|
|
239
|
+
splitChunks?: RawSplitChunksOptions
|
|
240
|
+
moduleIds: string
|
|
241
|
+
removeAvailableModules: boolean
|
|
242
|
+
sideEffects: string
|
|
243
|
+
}
|
|
244
|
+
export interface RawOutputOptions {
|
|
245
|
+
path: string
|
|
246
|
+
publicPath: string
|
|
247
|
+
assetModuleFilename: string
|
|
248
|
+
filename: string
|
|
249
|
+
chunkFilename: string
|
|
250
|
+
cssFilename: string
|
|
251
|
+
cssChunkFilename: string
|
|
252
|
+
uniqueName: string
|
|
253
|
+
library?: string
|
|
254
|
+
strictModuleErrorHandling: boolean
|
|
255
|
+
}
|
|
256
|
+
export interface RawResolveOptions {
|
|
257
|
+
preferRelative?: boolean
|
|
258
|
+
extensions?: Array<string>
|
|
259
|
+
mainFiles?: Array<string>
|
|
260
|
+
mainFields?: Array<string>
|
|
261
|
+
browserField?: boolean
|
|
262
|
+
conditionNames?: Array<string>
|
|
263
|
+
alias?: Record<string, string | false>
|
|
264
|
+
fallback?: Record<string, string | false>
|
|
265
|
+
symlinks?: boolean
|
|
266
|
+
tsConfigPath?: string
|
|
267
|
+
modules?: Array<string>
|
|
268
|
+
}
|
|
269
|
+
export interface RawSnapshotStrategy {
|
|
270
|
+
hash: boolean
|
|
271
|
+
timestamp: boolean
|
|
272
|
+
}
|
|
273
|
+
export interface RawSnapshotOptions {
|
|
274
|
+
resolve: RawSnapshotStrategy
|
|
275
|
+
module: RawSnapshotStrategy
|
|
276
|
+
}
|
|
277
|
+
export interface RawSplitChunksOptions {
|
|
278
|
+
cacheGroups?: Record<string, RawCacheGroupOptions>
|
|
279
|
+
/** What kind of chunks should be selected. */
|
|
280
|
+
chunks?: string
|
|
281
|
+
maxAsyncRequests?: number
|
|
282
|
+
maxInitialRequests?: number
|
|
283
|
+
minChunks?: number
|
|
284
|
+
minSize?: number
|
|
285
|
+
enforceSizeThreshold?: number
|
|
286
|
+
minRemainingSize?: number
|
|
287
|
+
}
|
|
288
|
+
export interface RawCacheGroupOptions {
|
|
289
|
+
priority?: number
|
|
290
|
+
reuseExistingChunk?: boolean
|
|
291
|
+
test?: string
|
|
292
|
+
/** What kind of chunks should be selected. */
|
|
293
|
+
chunks?: string
|
|
294
|
+
minChunks?: number
|
|
295
|
+
name?: string
|
|
296
|
+
}
|
|
297
|
+
export interface RawStatsOptions {
|
|
298
|
+
colors: boolean
|
|
299
|
+
}
|
|
300
|
+
export interface RawOptions {
|
|
301
|
+
entry: Record<string, RawEntryItem>
|
|
302
|
+
mode?: undefined | 'production' | 'development' | 'none'
|
|
303
|
+
target: Array<string>
|
|
304
|
+
context: string
|
|
305
|
+
output: RawOutputOptions
|
|
306
|
+
resolve: RawResolveOptions
|
|
307
|
+
module: RawModuleOptions
|
|
308
|
+
builtins: RawBuiltins
|
|
309
|
+
externals: Record<string, string>
|
|
310
|
+
externalsType: '' | 'node-commonjs' | 'window'
|
|
311
|
+
devtool: string
|
|
312
|
+
optimization: RawOptimizationOptions
|
|
313
|
+
stats: RawStatsOptions
|
|
314
|
+
devServer: RawDevServer
|
|
315
|
+
snapshot: RawSnapshotOptions
|
|
316
|
+
cache: RawCacheOptions
|
|
317
|
+
experiments: RawExperiments
|
|
318
|
+
node: RawNodeOption
|
|
319
|
+
}
|
|
320
|
+
export interface ThreadsafeNodeFs {
|
|
321
|
+
writeFile: (...args: any[]) => any
|
|
322
|
+
mkdir: (...args: any[]) => any
|
|
323
|
+
mkdirp: (...args: any[]) => any
|
|
324
|
+
}
|
|
325
|
+
export interface NodeFs {
|
|
326
|
+
writeFile: (...args: any[]) => any
|
|
327
|
+
mkdir: (...args: any[]) => any
|
|
328
|
+
mkdirp: (...args: any[]) => any
|
|
329
|
+
}
|
|
330
|
+
export interface JsAssetInfoRelated {
|
|
331
|
+
sourceMap?: string
|
|
332
|
+
}
|
|
333
|
+
export interface JsAssetInfo {
|
|
334
|
+
/**
|
|
335
|
+
* if the asset can be long term cached forever (contains a hash)
|
|
336
|
+
* whether the asset is minimized
|
|
337
|
+
*/
|
|
338
|
+
minimized: boolean
|
|
339
|
+
/**
|
|
340
|
+
* the value(s) of the full hash used for this asset
|
|
341
|
+
* the value(s) of the chunk hash used for this asset
|
|
342
|
+
* the value(s) of the module hash used for this asset
|
|
343
|
+
* the value(s) of the content hash used for this asset
|
|
344
|
+
* when asset was created from a source file (potentially transformed), the original filename relative to compilation context
|
|
345
|
+
* size in bytes, only set after asset has been emitted
|
|
346
|
+
* when asset is only used for development and doesn't count towards user-facing assets
|
|
347
|
+
*/
|
|
348
|
+
development: boolean
|
|
349
|
+
/** when asset ships data for updating an existing application (HMR) */
|
|
350
|
+
hotModuleReplacement: boolean
|
|
351
|
+
/**
|
|
352
|
+
* when asset is javascript and an ESM
|
|
353
|
+
* related object to other assets, keyed by type of relation (only points from parent to child)
|
|
354
|
+
*/
|
|
355
|
+
related: JsAssetInfoRelated
|
|
356
|
+
}
|
|
357
|
+
export interface JsAsset {
|
|
358
|
+
name: string
|
|
359
|
+
source?: JsCompatSource
|
|
360
|
+
info: JsAssetInfo
|
|
361
|
+
}
|
|
362
|
+
export interface JsChunk {
|
|
363
|
+
files: Array<string>
|
|
364
|
+
}
|
|
365
|
+
export interface JsChunkGroup {
|
|
366
|
+
chunks: Array<JsChunk>
|
|
367
|
+
}
|
|
368
|
+
export interface JsHooks {
|
|
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
|
|
375
|
+
compilation: (...args: any[]) => any
|
|
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
|
|
386
|
+
}
|
|
387
|
+
export interface JsCompatSource {
|
|
388
|
+
/** Whether the underlying data structure is a `RawSource` */
|
|
389
|
+
isRaw: boolean
|
|
390
|
+
/** Whether the underlying value is a buffer or string */
|
|
391
|
+
isBuffer: boolean
|
|
392
|
+
source: Buffer
|
|
393
|
+
map?: Buffer
|
|
394
|
+
}
|
|
395
|
+
export interface JsStatsError {
|
|
396
|
+
message: string
|
|
397
|
+
formatted: string
|
|
398
|
+
}
|
|
399
|
+
export interface JsStatsWarning {
|
|
400
|
+
message: string
|
|
401
|
+
formatted: string
|
|
402
|
+
}
|
|
403
|
+
export interface JsStatsAsset {
|
|
404
|
+
type: string
|
|
405
|
+
name: string
|
|
406
|
+
size: number
|
|
407
|
+
chunks: Array<string>
|
|
408
|
+
chunkNames: Array<string>
|
|
409
|
+
info: JsStatsAssetInfo
|
|
410
|
+
emitted: boolean
|
|
411
|
+
}
|
|
412
|
+
export interface JsStatsAssetInfo {
|
|
413
|
+
development: boolean
|
|
414
|
+
hotModuleReplacement: boolean
|
|
415
|
+
}
|
|
416
|
+
export interface JsStatsModule {
|
|
417
|
+
type: string
|
|
418
|
+
moduleType: string
|
|
419
|
+
identifier: string
|
|
420
|
+
name: string
|
|
421
|
+
id: string
|
|
422
|
+
chunks: Array<string>
|
|
423
|
+
size: number
|
|
424
|
+
issuer?: string
|
|
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
|
|
439
|
+
}
|
|
440
|
+
export interface JsStatsChunk {
|
|
441
|
+
type: string
|
|
442
|
+
files: Array<string>
|
|
443
|
+
id: string
|
|
444
|
+
entry: boolean
|
|
445
|
+
initial: boolean
|
|
446
|
+
names: Array<string>
|
|
447
|
+
size: number
|
|
448
|
+
}
|
|
449
|
+
export interface JsStatsEntrypointAsset {
|
|
450
|
+
name: string
|
|
451
|
+
size: number
|
|
452
|
+
}
|
|
453
|
+
export interface JsStatsEntrypoint {
|
|
454
|
+
name: string
|
|
455
|
+
assets: Array<JsStatsEntrypointAsset>
|
|
456
|
+
chunks: Array<string>
|
|
457
|
+
assetsSize: number
|
|
458
|
+
}
|
|
459
|
+
export interface JsStatsCompilation {
|
|
460
|
+
assets: Array<JsStatsAsset>
|
|
461
|
+
modules: Array<JsStatsModule>
|
|
462
|
+
chunks: Array<JsStatsChunk>
|
|
463
|
+
entrypoints: Array<JsStatsEntrypoint>
|
|
464
|
+
errors: Array<JsStatsError>
|
|
465
|
+
errorsCount: number
|
|
466
|
+
warnings: Array<JsStatsWarning>
|
|
467
|
+
warningsCount: number
|
|
468
|
+
hash: string
|
|
469
|
+
}
|
|
470
|
+
export function initCustomTraceSubscriber(): void
|
|
471
|
+
export class JsCompilation {
|
|
472
|
+
updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSource) => JsCompatSource), assetInfoUpdateOrFunction?: JsAssetInfo | ((assetInfo: JsAssetInfo) => JsAssetInfo)): void
|
|
473
|
+
getAssets(): Readonly<JsAsset>[]
|
|
474
|
+
getAsset(name: string): JsAsset | null
|
|
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
|
|
484
|
+
getAssetFilenames(): Array<string>
|
|
485
|
+
hasAsset(name: string): boolean
|
|
486
|
+
emitAsset(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
|
|
487
|
+
deleteAsset(filename: string): void
|
|
488
|
+
get entrypoints(): Record<string, JsChunkGroup>
|
|
489
|
+
get hash(): string
|
|
490
|
+
getFileDependencies(): Array<string>
|
|
491
|
+
getContextDependencies(): Array<string>
|
|
492
|
+
getMissingDependencies(): Array<string>
|
|
493
|
+
getBuildDependencies(): Array<string>
|
|
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
|
|
509
|
+
}
|
|
510
|
+
export class Rspack {
|
|
511
|
+
constructor(options: RawOptions, jsHooks: JsHooks | undefined | null, outputFilesystem: ThreadsafeNodeFS)
|
|
512
|
+
/**
|
|
513
|
+
* Build with the given option passed to the constructor
|
|
514
|
+
*
|
|
515
|
+
* Warning:
|
|
516
|
+
* Calling this method recursively might cause a deadlock.
|
|
517
|
+
*/
|
|
518
|
+
unsafe_build(callback: (err: null | Error) => void): void
|
|
519
|
+
/**
|
|
520
|
+
* Rebuild with the given option passed to the constructor
|
|
521
|
+
*
|
|
522
|
+
* Warning:
|
|
523
|
+
* Calling this method recursively will cause a deadlock.
|
|
524
|
+
*/
|
|
525
|
+
unsafe_rebuild(changed_files: string[], removed_files: string[], callback: (err: null | Error) => void): void
|
|
526
|
+
/**
|
|
527
|
+
* Get the last compilation
|
|
528
|
+
*
|
|
529
|
+
* Warning:
|
|
530
|
+
*
|
|
531
|
+
* Calling this method under the build or rebuild method might cause a deadlock.
|
|
532
|
+
*
|
|
533
|
+
* **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.
|
|
534
|
+
*/
|
|
535
|
+
unsafe_last_compilation(f: (arg0: JsCompilation) => void): void
|
|
536
|
+
/**
|
|
537
|
+
* Destroy the compiler
|
|
538
|
+
*
|
|
539
|
+
* Warning:
|
|
540
|
+
*
|
|
541
|
+
* Anything related to this compiler will be invalidated after this method is called.
|
|
542
|
+
*/
|
|
543
|
+
unsafe_drop(): void
|
|
544
|
+
}
|
package/binding.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
const { existsSync, readFileSync } = require('fs')
|
|
2
|
+
const { join } = require('path')
|
|
3
|
+
|
|
4
|
+
const { platform, arch } = process
|
|
5
|
+
|
|
6
|
+
let nativeBinding = null
|
|
7
|
+
let localFileExisted = false
|
|
8
|
+
let loadError = null
|
|
9
|
+
|
|
10
|
+
function isMusl() {
|
|
11
|
+
// For Node 10
|
|
12
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
13
|
+
try {
|
|
14
|
+
return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
20
|
+
return !glibcVersionRuntime
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
switch (platform) {
|
|
25
|
+
case 'android':
|
|
26
|
+
switch (arch) {
|
|
27
|
+
case 'arm64':
|
|
28
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.android-arm64.node'))
|
|
29
|
+
try {
|
|
30
|
+
if (localFileExisted) {
|
|
31
|
+
nativeBinding = require('./rspack.android-arm64.node')
|
|
32
|
+
} else {
|
|
33
|
+
nativeBinding = require('@rspack/binding-android-arm64')
|
|
34
|
+
}
|
|
35
|
+
} catch (e) {
|
|
36
|
+
loadError = e
|
|
37
|
+
}
|
|
38
|
+
break
|
|
39
|
+
case 'arm':
|
|
40
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.android-arm-eabi.node'))
|
|
41
|
+
try {
|
|
42
|
+
if (localFileExisted) {
|
|
43
|
+
nativeBinding = require('./rspack.android-arm-eabi.node')
|
|
44
|
+
} else {
|
|
45
|
+
nativeBinding = require('@rspack/binding-android-arm-eabi')
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
loadError = e
|
|
49
|
+
}
|
|
50
|
+
break
|
|
51
|
+
default:
|
|
52
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
53
|
+
}
|
|
54
|
+
break
|
|
55
|
+
case 'win32':
|
|
56
|
+
switch (arch) {
|
|
57
|
+
case 'x64':
|
|
58
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.win32-x64-msvc.node'))
|
|
59
|
+
try {
|
|
60
|
+
if (localFileExisted) {
|
|
61
|
+
nativeBinding = require('./rspack.win32-x64-msvc.node')
|
|
62
|
+
} else {
|
|
63
|
+
nativeBinding = require('@rspack/binding-win32-x64-msvc')
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
loadError = e
|
|
67
|
+
}
|
|
68
|
+
break
|
|
69
|
+
case 'ia32':
|
|
70
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.win32-ia32-msvc.node'))
|
|
71
|
+
try {
|
|
72
|
+
if (localFileExisted) {
|
|
73
|
+
nativeBinding = require('./rspack.win32-ia32-msvc.node')
|
|
74
|
+
} else {
|
|
75
|
+
nativeBinding = require('@rspack/binding-win32-ia32-msvc')
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {
|
|
78
|
+
loadError = e
|
|
79
|
+
}
|
|
80
|
+
break
|
|
81
|
+
case 'arm64':
|
|
82
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.win32-arm64-msvc.node'))
|
|
83
|
+
try {
|
|
84
|
+
if (localFileExisted) {
|
|
85
|
+
nativeBinding = require('./rspack.win32-arm64-msvc.node')
|
|
86
|
+
} else {
|
|
87
|
+
nativeBinding = require('@rspack/binding-win32-arm64-msvc')
|
|
88
|
+
}
|
|
89
|
+
} catch (e) {
|
|
90
|
+
loadError = e
|
|
91
|
+
}
|
|
92
|
+
break
|
|
93
|
+
default:
|
|
94
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
95
|
+
}
|
|
96
|
+
break
|
|
97
|
+
case 'darwin':
|
|
98
|
+
switch (arch) {
|
|
99
|
+
case 'x64':
|
|
100
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.darwin-x64.node'))
|
|
101
|
+
try {
|
|
102
|
+
if (localFileExisted) {
|
|
103
|
+
nativeBinding = require('./rspack.darwin-x64.node')
|
|
104
|
+
} else {
|
|
105
|
+
nativeBinding = require('@rspack/binding-darwin-x64')
|
|
106
|
+
}
|
|
107
|
+
} catch (e) {
|
|
108
|
+
loadError = e
|
|
109
|
+
}
|
|
110
|
+
break
|
|
111
|
+
case 'arm64':
|
|
112
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.darwin-arm64.node'))
|
|
113
|
+
try {
|
|
114
|
+
if (localFileExisted) {
|
|
115
|
+
nativeBinding = require('./rspack.darwin-arm64.node')
|
|
116
|
+
} else {
|
|
117
|
+
nativeBinding = require('@rspack/binding-darwin-arm64')
|
|
118
|
+
}
|
|
119
|
+
} catch (e) {
|
|
120
|
+
loadError = e
|
|
121
|
+
}
|
|
122
|
+
break
|
|
123
|
+
default:
|
|
124
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
125
|
+
}
|
|
126
|
+
break
|
|
127
|
+
case 'freebsd':
|
|
128
|
+
if (arch !== 'x64') {
|
|
129
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
130
|
+
}
|
|
131
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.freebsd-x64.node'))
|
|
132
|
+
try {
|
|
133
|
+
if (localFileExisted) {
|
|
134
|
+
nativeBinding = require('./rspack.freebsd-x64.node')
|
|
135
|
+
} else {
|
|
136
|
+
nativeBinding = require('@rspack/binding-freebsd-x64')
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
loadError = e
|
|
140
|
+
}
|
|
141
|
+
break
|
|
142
|
+
case 'linux':
|
|
143
|
+
switch (arch) {
|
|
144
|
+
case 'x64':
|
|
145
|
+
if (isMusl()) {
|
|
146
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.linux-x64-musl.node'))
|
|
147
|
+
try {
|
|
148
|
+
if (localFileExisted) {
|
|
149
|
+
nativeBinding = require('./rspack.linux-x64-musl.node')
|
|
150
|
+
} else {
|
|
151
|
+
nativeBinding = require('@rspack/binding-linux-x64-musl')
|
|
152
|
+
}
|
|
153
|
+
} catch (e) {
|
|
154
|
+
loadError = e
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.linux-x64-gnu.node'))
|
|
158
|
+
try {
|
|
159
|
+
if (localFileExisted) {
|
|
160
|
+
nativeBinding = require('./rspack.linux-x64-gnu.node')
|
|
161
|
+
} else {
|
|
162
|
+
nativeBinding = require('@rspack/binding-linux-x64-gnu')
|
|
163
|
+
}
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadError = e
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
break
|
|
169
|
+
case 'arm64':
|
|
170
|
+
if (isMusl()) {
|
|
171
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.linux-arm64-musl.node'))
|
|
172
|
+
try {
|
|
173
|
+
if (localFileExisted) {
|
|
174
|
+
nativeBinding = require('./rspack.linux-arm64-musl.node')
|
|
175
|
+
} else {
|
|
176
|
+
nativeBinding = require('@rspack/binding-linux-arm64-musl')
|
|
177
|
+
}
|
|
178
|
+
} catch (e) {
|
|
179
|
+
loadError = e
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.linux-arm64-gnu.node'))
|
|
183
|
+
try {
|
|
184
|
+
if (localFileExisted) {
|
|
185
|
+
nativeBinding = require('./rspack.linux-arm64-gnu.node')
|
|
186
|
+
} else {
|
|
187
|
+
nativeBinding = require('@rspack/binding-linux-arm64-gnu')
|
|
188
|
+
}
|
|
189
|
+
} catch (e) {
|
|
190
|
+
loadError = e
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
break
|
|
194
|
+
case 'arm':
|
|
195
|
+
localFileExisted = existsSync(join(__dirname, 'rspack.linux-arm-gnueabihf.node'))
|
|
196
|
+
try {
|
|
197
|
+
if (localFileExisted) {
|
|
198
|
+
nativeBinding = require('./rspack.linux-arm-gnueabihf.node')
|
|
199
|
+
} else {
|
|
200
|
+
nativeBinding = require('@rspack/binding-linux-arm-gnueabihf')
|
|
201
|
+
}
|
|
202
|
+
} catch (e) {
|
|
203
|
+
loadError = e
|
|
204
|
+
}
|
|
205
|
+
break
|
|
206
|
+
default:
|
|
207
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
208
|
+
}
|
|
209
|
+
break
|
|
210
|
+
default:
|
|
211
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!nativeBinding) {
|
|
215
|
+
if (loadError) {
|
|
216
|
+
throw loadError
|
|
217
|
+
}
|
|
218
|
+
throw new Error(`Failed to load native binding`)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
module.exports.default = module.exports = nativeBinding
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rspack/binding",
|
|
3
|
+
"version": "0.0.0-0074001a71-20230224065505",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Node binding for rspack",
|
|
6
|
+
"main": "binding.js",
|
|
7
|
+
"types": "binding.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"binding.js",
|
|
13
|
+
"binding.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://rspack.org",
|
|
16
|
+
"bugs": "https://github.com/modern-js-dev/rspack/issues",
|
|
17
|
+
"repository": "modern-js-dev/rspack",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@napi-rs/cli": "2.14.2",
|
|
20
|
+
"why-is-node-running": "2.2.1",
|
|
21
|
+
"npm-run-all": "4.1.5"
|
|
22
|
+
},
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@rspack/binding-darwin-x64": "0.0.0-0074001a71-20230224065505",
|
|
25
|
+
"@rspack/binding-win32-x64-msvc": "0.0.0-0074001a71-20230224065505",
|
|
26
|
+
"@rspack/binding-linux-x64-gnu": "0.0.0-0074001a71-20230224065505",
|
|
27
|
+
"@rspack/binding-darwin-arm64": "0.0.0-0074001a71-20230224065505"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build:debug": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json",
|
|
31
|
+
"build:debug:x64": "napi build --platform --js false --dts binding.d.ts --config napirs.rc.json --target x86_64-apple-darwin",
|
|
32
|
+
"build:release:all": "run-p build:release build:release:x64 build:release:linux && pnpm move-binding",
|
|
33
|
+
"build:release": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json && pnpm move-binding",
|
|
34
|
+
"build:release:x64": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json --target x86_64-apple-darwin",
|
|
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",
|
|
37
|
+
"move-binding": "node scripts/move-binding"
|
|
38
|
+
}
|
|
39
|
+
}
|