@rspack/binding 0.0.0-01dbf86423-20221210100716
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 +406 -0
- package/binding.js +221 -0
- package/package.json +31 -0
- package/rspack.darwin-arm64.node +0 -0
package/binding.d.ts
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
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
|
|
19
|
+
}
|
|
20
|
+
export interface RawCssModulesConfig {
|
|
21
|
+
localsConvention?: string
|
|
22
|
+
localIdentName?: string
|
|
23
|
+
exportsOnly?: boolean
|
|
24
|
+
}
|
|
25
|
+
export interface RawDecoratorOptions {
|
|
26
|
+
legacy: boolean
|
|
27
|
+
emitMetadata: boolean
|
|
28
|
+
useDefineForClassFields: boolean
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* It seems napi not support enum well
|
|
32
|
+
*/
|
|
33
|
+
export interface RawHtmlPluginConfig {
|
|
34
|
+
/** emitted file name in output path */
|
|
35
|
+
filename?: string | void
|
|
36
|
+
/** template html file */
|
|
37
|
+
template?: string
|
|
38
|
+
templateParameters?: Record<string, string>
|
|
39
|
+
/** `head`, `body` or None */
|
|
40
|
+
inject?: string | void
|
|
41
|
+
/** path or `auto` */
|
|
42
|
+
publicPath?: string
|
|
43
|
+
/** `blocking`, `defer`, or `module` */
|
|
44
|
+
scriptLoading?: string | void
|
|
45
|
+
/** entry_chunk_name (only entry chunks are supported) */
|
|
46
|
+
chunks?: Array<string>
|
|
47
|
+
excludedChunks?: Array<string>
|
|
48
|
+
sri?: string | void
|
|
49
|
+
minify?: boolean
|
|
50
|
+
title?: string
|
|
51
|
+
favicon?: string
|
|
52
|
+
meta?: Record<string, Record<string, string>>
|
|
53
|
+
}
|
|
54
|
+
export interface RawPostCssConfig {
|
|
55
|
+
pxtorem?: RawPxToRemConfig
|
|
56
|
+
}
|
|
57
|
+
export interface RawPxToRemConfig {
|
|
58
|
+
rootValue?: number
|
|
59
|
+
unitPrecision?: number
|
|
60
|
+
selectorBlackList?: Array<string>
|
|
61
|
+
propList?: Array<string>
|
|
62
|
+
replace?: boolean
|
|
63
|
+
mediaQuery?: boolean
|
|
64
|
+
minPixelValue?: number
|
|
65
|
+
}
|
|
66
|
+
export interface RawProgressPluginConfig {
|
|
67
|
+
prefix?: string
|
|
68
|
+
}
|
|
69
|
+
export interface RawReactOptions {
|
|
70
|
+
runtime?: string
|
|
71
|
+
importSource?: string
|
|
72
|
+
pragma?: string
|
|
73
|
+
pragmaFrag?: string
|
|
74
|
+
throwIfNamespace?: boolean
|
|
75
|
+
development?: boolean
|
|
76
|
+
useBuiltins?: boolean
|
|
77
|
+
useSpread?: boolean
|
|
78
|
+
refresh?: boolean
|
|
79
|
+
}
|
|
80
|
+
export interface Minification {
|
|
81
|
+
passes?: number
|
|
82
|
+
enable?: boolean
|
|
83
|
+
}
|
|
84
|
+
export interface RawBuiltins {
|
|
85
|
+
html?: Array<RawHtmlPluginConfig>
|
|
86
|
+
css?: RawCssPluginConfig
|
|
87
|
+
postcss?: RawPostCssConfig
|
|
88
|
+
minify?: Minification
|
|
89
|
+
polyfill?: boolean
|
|
90
|
+
browserslist?: Array<string>
|
|
91
|
+
define?: Record<string, string>
|
|
92
|
+
treeShaking?: boolean
|
|
93
|
+
sideEffects?: boolean
|
|
94
|
+
progress?: RawProgressPluginConfig
|
|
95
|
+
react?: RawReactOptions
|
|
96
|
+
decorator?: RawDecoratorOptions
|
|
97
|
+
}
|
|
98
|
+
export interface RawCacheOptions {
|
|
99
|
+
cacheType: string
|
|
100
|
+
maxGenerations: number
|
|
101
|
+
maxAge: number
|
|
102
|
+
profile: boolean
|
|
103
|
+
buildDependencies: Array<string>
|
|
104
|
+
cacheDirectory: string
|
|
105
|
+
cacheLocation: string
|
|
106
|
+
name: string
|
|
107
|
+
version: string
|
|
108
|
+
}
|
|
109
|
+
export interface RawDevServer {
|
|
110
|
+
hot?: boolean
|
|
111
|
+
}
|
|
112
|
+
export interface RawEntryItem {
|
|
113
|
+
import: Array<string>
|
|
114
|
+
runtime?: string
|
|
115
|
+
}
|
|
116
|
+
export interface RawExperiments {
|
|
117
|
+
lazyCompilation: boolean
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* `loader` is for js side loader, `builtin_loader` is for rust side loader,
|
|
121
|
+
* which is mapped to real rust side loader by [get_builtin_loader].
|
|
122
|
+
*
|
|
123
|
+
* `options` is
|
|
124
|
+
* - a `None` on rust side and handled by js side `getOptions` when
|
|
125
|
+
* using with `loader`.
|
|
126
|
+
* - a `Some(string)` on rust side, deserialized by `serde_json::from_str`
|
|
127
|
+
* and passed to rust side loader in [get_builtin_loader] when using with
|
|
128
|
+
* `builtin_loader`.
|
|
129
|
+
*/
|
|
130
|
+
export interface RawModuleRuleUse {
|
|
131
|
+
loader?: (...args: any[]) => any
|
|
132
|
+
builtinLoader?: string
|
|
133
|
+
options?: string
|
|
134
|
+
loaderName?: string
|
|
135
|
+
}
|
|
136
|
+
export interface RawModuleRuleCondition {
|
|
137
|
+
/** Condition can be either a `string` or `Regexp`. */
|
|
138
|
+
type: "string" | "regexp"
|
|
139
|
+
/**
|
|
140
|
+
* Based on the condition type, the value can be either a `string` or `Regexp`.
|
|
141
|
+
* - "string": The value will be matched against the string.
|
|
142
|
+
* - "regexp": The value will be matched against the raw regexp source from JS side.
|
|
143
|
+
*/
|
|
144
|
+
matcher?: string
|
|
145
|
+
}
|
|
146
|
+
export interface RawModuleRule {
|
|
147
|
+
/**
|
|
148
|
+
* A condition matcher matching an absolute path.
|
|
149
|
+
* - String: To match the input must start with the provided string. I. e. an absolute directory path, or absolute path to the file.
|
|
150
|
+
* - Regexp: It's tested with the input.
|
|
151
|
+
*/
|
|
152
|
+
test?: RawModuleRuleCondition
|
|
153
|
+
include?: Array<RawModuleRuleCondition>
|
|
154
|
+
exclude?: Array<RawModuleRuleCondition>
|
|
155
|
+
/**
|
|
156
|
+
* A condition matcher matching an absolute path.
|
|
157
|
+
* See `test` above
|
|
158
|
+
*/
|
|
159
|
+
resource?: RawModuleRuleCondition
|
|
160
|
+
/**
|
|
161
|
+
* A condition matcher against the resource query.
|
|
162
|
+
* TODO: align with webpack's `?` prefixed `resourceQuery`
|
|
163
|
+
*/
|
|
164
|
+
resourceQuery?: RawModuleRuleCondition
|
|
165
|
+
func?: (...args: any[]) => any
|
|
166
|
+
use?: Array<RawModuleRuleUse>
|
|
167
|
+
type?: "js" | "jsx" | "ts" | "tsx" | "css" | "json" | "asset" | "asset/resource" | "asset/source" | "asset/inline"
|
|
168
|
+
}
|
|
169
|
+
export interface RawAssetParserDataUrlOption {
|
|
170
|
+
maxSize?: number
|
|
171
|
+
}
|
|
172
|
+
export interface RawAssetParserOptions {
|
|
173
|
+
dataUrlCondition?: RawAssetParserDataUrlOption
|
|
174
|
+
}
|
|
175
|
+
export interface RawParserOptions {
|
|
176
|
+
asset?: RawAssetParserOptions
|
|
177
|
+
}
|
|
178
|
+
export interface RawModuleOptions {
|
|
179
|
+
rules: Array<RawModuleRule>
|
|
180
|
+
parser?: RawParserOptions
|
|
181
|
+
}
|
|
182
|
+
export interface RawOptimizationOptions {
|
|
183
|
+
splitChunks?: RawSplitChunksOptions
|
|
184
|
+
moduleIds?: string
|
|
185
|
+
}
|
|
186
|
+
export interface RawOutputOptions {
|
|
187
|
+
path?: string
|
|
188
|
+
publicPath?: string
|
|
189
|
+
assetModuleFilename?: string
|
|
190
|
+
filename?: string
|
|
191
|
+
chunkFilename?: string
|
|
192
|
+
cssFilename?: string
|
|
193
|
+
cssChunkFilename?: string
|
|
194
|
+
uniqueName?: string
|
|
195
|
+
library?: string
|
|
196
|
+
}
|
|
197
|
+
export interface RawResolveOptions {
|
|
198
|
+
preferRelative?: boolean
|
|
199
|
+
extensions?: Array<string>
|
|
200
|
+
mainFiles?: Array<string>
|
|
201
|
+
mainFields?: Array<string>
|
|
202
|
+
browserField?: boolean
|
|
203
|
+
conditionNames?: Array<string>
|
|
204
|
+
alias?: Record<string, string | false>
|
|
205
|
+
symlinks?: boolean
|
|
206
|
+
tsConfigPath?: string
|
|
207
|
+
}
|
|
208
|
+
export interface RawSnapshotStrategy {
|
|
209
|
+
hash: boolean
|
|
210
|
+
timestamp: boolean
|
|
211
|
+
}
|
|
212
|
+
export interface RawSnapshotOptions {
|
|
213
|
+
resolveBuildDependencies: RawSnapshotStrategy
|
|
214
|
+
buildDependencies: RawSnapshotStrategy
|
|
215
|
+
resolve: RawSnapshotStrategy
|
|
216
|
+
module: RawSnapshotStrategy
|
|
217
|
+
}
|
|
218
|
+
export interface RawSplitChunksOptions {
|
|
219
|
+
cacheGroups?: Record<string, RawCacheGroupOptions>
|
|
220
|
+
/** What kind of chunks should be selected. */
|
|
221
|
+
chunks?: string
|
|
222
|
+
}
|
|
223
|
+
export interface RawCacheGroupOptions {
|
|
224
|
+
test: string
|
|
225
|
+
/** What kind of chunks should be selected. */
|
|
226
|
+
chunks?: string
|
|
227
|
+
name: string
|
|
228
|
+
}
|
|
229
|
+
export interface RawStatsOptions {
|
|
230
|
+
colors: boolean
|
|
231
|
+
}
|
|
232
|
+
export interface RawOptions {
|
|
233
|
+
entry?: Record<string, RawEntryItem>
|
|
234
|
+
mode?: string
|
|
235
|
+
target?: string[]
|
|
236
|
+
context?: string
|
|
237
|
+
output?: RawOutputOptions
|
|
238
|
+
resolve?: RawResolveOptions
|
|
239
|
+
module?: RawModuleOptions
|
|
240
|
+
builtins?: RawBuiltins
|
|
241
|
+
externals?: Record<string, string>
|
|
242
|
+
externalsType?: string
|
|
243
|
+
devtool?: string
|
|
244
|
+
optimization?: RawOptimizationOptions
|
|
245
|
+
stats?: RawStatsOptions
|
|
246
|
+
devServer?: RawDevServer
|
|
247
|
+
snapshot?: RawSnapshotOptions
|
|
248
|
+
cache?: RawCacheOptions
|
|
249
|
+
experiments?: RawExperiments
|
|
250
|
+
}
|
|
251
|
+
export interface JsAssetInfoRelated {
|
|
252
|
+
sourceMap?: string
|
|
253
|
+
}
|
|
254
|
+
export interface JsAssetInfo {
|
|
255
|
+
/**
|
|
256
|
+
* if the asset can be long term cached forever (contains a hash)
|
|
257
|
+
* whether the asset is minimized
|
|
258
|
+
*/
|
|
259
|
+
minimized: boolean
|
|
260
|
+
/**
|
|
261
|
+
* the value(s) of the full hash used for this asset
|
|
262
|
+
* the value(s) of the chunk hash used for this asset
|
|
263
|
+
* the value(s) of the module hash used for this asset
|
|
264
|
+
* the value(s) of the content hash used for this asset
|
|
265
|
+
* when asset was created from a source file (potentially transformed), the original filename relative to compilation context
|
|
266
|
+
* size in bytes, only set after asset has been emitted
|
|
267
|
+
* when asset is only used for development and doesn't count towards user-facing assets
|
|
268
|
+
*/
|
|
269
|
+
development: boolean
|
|
270
|
+
/** when asset ships data for updating an existing application (HMR) */
|
|
271
|
+
hotModuleReplacement: boolean
|
|
272
|
+
/**
|
|
273
|
+
* when asset is javascript and an ESM
|
|
274
|
+
* related object to other assets, keyed by type of relation (only points from parent to child)
|
|
275
|
+
*/
|
|
276
|
+
related: JsAssetInfoRelated
|
|
277
|
+
}
|
|
278
|
+
export interface JsAsset {
|
|
279
|
+
name: string
|
|
280
|
+
source: JsCompatSource
|
|
281
|
+
info: JsAssetInfo
|
|
282
|
+
}
|
|
283
|
+
export interface JsChunk {
|
|
284
|
+
files: Array<string>
|
|
285
|
+
}
|
|
286
|
+
export interface JsChunkGroup {
|
|
287
|
+
chunks: Array<JsChunk>
|
|
288
|
+
}
|
|
289
|
+
export interface JsHooks {
|
|
290
|
+
done: (...args: any[]) => any
|
|
291
|
+
processAssets: (...args: any[]) => any
|
|
292
|
+
compilation: (...args: any[]) => any
|
|
293
|
+
thisCompilation: (...args: any[]) => any
|
|
294
|
+
}
|
|
295
|
+
export interface JsCompatSource {
|
|
296
|
+
/** Whether the underlying data structure is a `RawSource` */
|
|
297
|
+
isRaw: boolean
|
|
298
|
+
/** Whether the underlying value is a buffer or string */
|
|
299
|
+
isBuffer: boolean
|
|
300
|
+
source: Buffer
|
|
301
|
+
map?: Buffer
|
|
302
|
+
}
|
|
303
|
+
export interface JsStatsError {
|
|
304
|
+
message: string
|
|
305
|
+
formatted: string
|
|
306
|
+
}
|
|
307
|
+
export interface JsStatsWarning {
|
|
308
|
+
message: string
|
|
309
|
+
formatted: string
|
|
310
|
+
}
|
|
311
|
+
export interface JsStatsAsset {
|
|
312
|
+
type: string
|
|
313
|
+
name: string
|
|
314
|
+
size: number
|
|
315
|
+
chunks: Array<string>
|
|
316
|
+
chunkNames: Array<string>
|
|
317
|
+
info: JsStatsAssetInfo
|
|
318
|
+
emitted: boolean
|
|
319
|
+
}
|
|
320
|
+
export interface JsStatsAssetInfo {
|
|
321
|
+
development: boolean
|
|
322
|
+
hotModuleReplacement: boolean
|
|
323
|
+
}
|
|
324
|
+
export interface JsStatsModule {
|
|
325
|
+
type: string
|
|
326
|
+
moduleType: string
|
|
327
|
+
identifier: string
|
|
328
|
+
name: string
|
|
329
|
+
id: string
|
|
330
|
+
chunks: Array<string>
|
|
331
|
+
size: number
|
|
332
|
+
}
|
|
333
|
+
export interface JsStatsChunk {
|
|
334
|
+
type: string
|
|
335
|
+
files: Array<string>
|
|
336
|
+
id: string
|
|
337
|
+
entry: boolean
|
|
338
|
+
initial: boolean
|
|
339
|
+
names: Array<string>
|
|
340
|
+
size: number
|
|
341
|
+
}
|
|
342
|
+
export interface JsStatsEntrypointAsset {
|
|
343
|
+
name: string
|
|
344
|
+
size: number
|
|
345
|
+
}
|
|
346
|
+
export interface JsStatsEntrypoint {
|
|
347
|
+
name: string
|
|
348
|
+
assets: Array<JsStatsEntrypointAsset>
|
|
349
|
+
chunks: Array<string>
|
|
350
|
+
assetsSize: number
|
|
351
|
+
}
|
|
352
|
+
export interface JsStatsCompilation {
|
|
353
|
+
assets: Array<JsStatsAsset>
|
|
354
|
+
modules: Array<JsStatsModule>
|
|
355
|
+
chunks: Array<JsStatsChunk>
|
|
356
|
+
entrypoints: Array<JsStatsEntrypoint>
|
|
357
|
+
errors: Array<JsStatsError>
|
|
358
|
+
errorsCount: number
|
|
359
|
+
warnings: Array<JsStatsWarning>
|
|
360
|
+
warningsCount: number
|
|
361
|
+
}
|
|
362
|
+
export function initCustomTraceSubscriber(): void
|
|
363
|
+
export class JsCompilation {
|
|
364
|
+
updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSource) => JsCompatSource), assetInfoUpdateOrFunction?: JsAssetInfo | ((assetInfo: JsAssetInfo) => JsAssetInfo)): void
|
|
365
|
+
getAssets(): Readonly<JsAsset>[]
|
|
366
|
+
getAsset(name: string): JsAsset | null
|
|
367
|
+
emitAsset(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
|
|
368
|
+
deleteAsset(filename: string): void
|
|
369
|
+
get assets(): Record<string, JsCompatSource>
|
|
370
|
+
get entrypoints(): Record<string, JsChunkGroup>
|
|
371
|
+
}
|
|
372
|
+
export class Rspack {
|
|
373
|
+
constructor(options: RawOptions, jsHooks?: JsHooks | undefined | null)
|
|
374
|
+
/**
|
|
375
|
+
* Build with the given option passed to the constructor
|
|
376
|
+
*
|
|
377
|
+
* Warning:
|
|
378
|
+
* Calling this method recursively might cause a deadlock.
|
|
379
|
+
*/
|
|
380
|
+
unsafe_build(callback: (err: null | Error, result: JsStatsCompilation) => void): void
|
|
381
|
+
/**
|
|
382
|
+
* Rebuild with the given option passed to the constructor
|
|
383
|
+
*
|
|
384
|
+
* Warning:
|
|
385
|
+
* Calling this method recursively will cause a deadlock.
|
|
386
|
+
*/
|
|
387
|
+
unsafe_rebuild(callback: (err: null | Error, result: Record<string, {content: string, kind: number}>) => void): void
|
|
388
|
+
/**
|
|
389
|
+
* Get the last compilation
|
|
390
|
+
*
|
|
391
|
+
* Warning:
|
|
392
|
+
*
|
|
393
|
+
* Calling this method under the build or rebuild method might cause a deadlock.
|
|
394
|
+
*
|
|
395
|
+
* **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.
|
|
396
|
+
*/
|
|
397
|
+
unsafe_last_compilation(f: (arg0: JsCompilation) => void): void
|
|
398
|
+
/**
|
|
399
|
+
* Destroy the compiler
|
|
400
|
+
*
|
|
401
|
+
* Warning:
|
|
402
|
+
*
|
|
403
|
+
* Anything related to this compiler will be invalidated after this method is called.
|
|
404
|
+
*/
|
|
405
|
+
unsafe_drop(): void
|
|
406
|
+
}
|
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,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rspack/binding",
|
|
3
|
+
"version": "0.0.0-01dbf86423-20221210100716",
|
|
4
|
+
"description": "Node binding for rspack",
|
|
5
|
+
"main": "binding.js",
|
|
6
|
+
"types": "binding.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"binding.js",
|
|
12
|
+
"binding.d.ts",
|
|
13
|
+
"*.node"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@napi-rs/cli": "^2.6.2",
|
|
20
|
+
"why-is-node-running": "2.2.1",
|
|
21
|
+
"npm-run-all": "4.1.5"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
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",
|
|
27
|
+
"build:release": "napi build --release --platform --js false --dts binding.d.ts --config napirs.rc.json",
|
|
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"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
Binary file
|