jsshaker 0.2.4 → 0.2.6
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/README.md +7 -30
- package/cli.js +30 -18
- package/jsshaker.darwin-arm64.node +0 -0
- package/jsshaker.darwin-x64.node +0 -0
- package/jsshaker.linux-x64-gnu.node +0 -0
- package/jsshaker.wasm32-wasi.wasm +0 -0
- package/jsshaker.win32-x64-msvc.node +0 -0
- package/package.json +6 -6
- package/index.d.ts +0 -30
- package/index.js +0 -513
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ https://github.com/kermanx/jsshaker
|
|
|
7
7
|
## WASM & N-API
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import { shakeSingleModule, shakeMultiModule } from "jsshaker";
|
|
10
|
+
import { shakeSingleModule, shakeMultiModule, shakeFsModule } from "jsshaker";
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## CLI
|
|
@@ -15,35 +15,12 @@ import { shakeSingleModule, shakeMultiModule } from "jsshaker";
|
|
|
15
15
|
```sh
|
|
16
16
|
pnpx jsshaker ./entry.js
|
|
17
17
|
|
|
18
|
-
# --preset(-p, optional): "safest" | "recommended" | "smallest" | "disabled"
|
|
19
|
-
# --minify(-m, optional): boolean
|
|
20
|
-
# --outdir(-o, optional): string
|
|
18
|
+
# --preset(-p, optional): "safest" | "recommended" | "smallest" | "disabled" - Preset configuration (default: "recommended")
|
|
19
|
+
# --minify(-m, optional): boolean - Minify output (default: false)
|
|
20
|
+
# --outdir(-o, optional): string - Output directory (default: ./out)
|
|
21
|
+
# --single(-s, optional): boolean - Shake as a single module (default: ./out.js)
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
## Vite Plugin
|
|
24
|
+
## Rollup/Vite/Rolldown Plugin
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
import { defineConfig } from "vite";
|
|
27
|
-
import { shakeMultiModule } from "jsshaker";
|
|
28
|
-
import * as fs from "fs";
|
|
29
|
-
|
|
30
|
-
export default defineConfig({
|
|
31
|
-
plugins: [
|
|
32
|
-
{
|
|
33
|
-
name: "jsshaker",
|
|
34
|
-
enforce: "post",
|
|
35
|
-
buildEnd() {
|
|
36
|
-
const { output, diagnostics } = shakeMultiModule("./dist/index.js", {
|
|
37
|
-
minify: true,
|
|
38
|
-
})
|
|
39
|
-
for (const diag of diagnostics) {
|
|
40
|
-
console.error(diag);
|
|
41
|
-
}
|
|
42
|
-
for (const file in output) {
|
|
43
|
-
fs.writeFileSync(file, output[file]);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
});
|
|
49
|
-
```
|
|
26
|
+
https://www.npmjs.com/package/rollup-plugin-jsshaker
|
package/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { parseArgs } = require("node:util");
|
|
4
|
-
const { shakeFsModule } = require("./index.js");
|
|
5
|
-
const { writeFile, mkdir } = require("node:fs/promises");
|
|
4
|
+
const { shakeFsModule, shakeSingleModule } = require("./index.js");
|
|
5
|
+
const { writeFile, mkdir, readFile } = require("node:fs/promises");
|
|
6
6
|
const { join, dirname } = require("node:path");
|
|
7
7
|
|
|
8
8
|
(async () => {
|
|
@@ -20,6 +20,10 @@ const { join, dirname } = require("node:path");
|
|
|
20
20
|
type: "string",
|
|
21
21
|
short: "o",
|
|
22
22
|
},
|
|
23
|
+
single: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
short: "s",
|
|
26
|
+
},
|
|
23
27
|
},
|
|
24
28
|
allowPositionals: true,
|
|
25
29
|
strict: false,
|
|
@@ -29,26 +33,34 @@ const { join, dirname } = require("node:path");
|
|
|
29
33
|
throw new Error("Must provide exactly one entry js file path.");
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const options = {
|
|
37
|
+
preset: values.preset,
|
|
38
|
+
minify: values.minify,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
if (!values.single) {
|
|
42
|
+
const result = shakeFsModule(positionals[0], options);
|
|
43
|
+
|
|
44
|
+
for (const message of result.diagnostics) {
|
|
45
|
+
console.warn(message);
|
|
37
46
|
}
|
|
38
|
-
);
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
for (let [path, { code }] of Object.entries(result.output)) {
|
|
49
|
+
path = join(values.outdir || "./out", path);
|
|
50
|
+
const dir = dirname(path);
|
|
51
|
+
await mkdir(dir, { recursive: true });
|
|
52
|
+
console.log('Writing', path);
|
|
53
|
+
await writeFile(path, code);
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
const content = await readFile(positionals[0], "utf-8");
|
|
57
|
+
const result = shakeSingleModule(content, options);
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
path = join(values.outdir, path);
|
|
59
|
+
for (const message of result.diagnostics) {
|
|
60
|
+
console.warn(message);
|
|
47
61
|
}
|
|
48
|
-
|
|
49
|
-
await
|
|
50
|
-
console.log('Writing', path);
|
|
51
|
-
await writeFile(path, code);
|
|
62
|
+
|
|
63
|
+
await writeFile(values.outdir || "out.js", result.output.code);
|
|
52
64
|
}
|
|
53
65
|
})().catch((err) => {
|
|
54
66
|
console.error(err);
|
|
Binary file
|
package/jsshaker.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsshaker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"browser": "browser.js",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"ohash": "^2.0.11"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"@jsshaker/binding-linux-x64-gnu": "0.2.
|
|
53
|
-
"@jsshaker/binding-win32-x64-msvc": "0.2.
|
|
54
|
-
"@jsshaker/binding-darwin-x64": "0.2.
|
|
55
|
-
"@jsshaker/binding-darwin-arm64": "0.2.
|
|
56
|
-
"@jsshaker/binding-wasm32-wasi": "0.2.
|
|
52
|
+
"@jsshaker/binding-linux-x64-gnu": "0.2.6",
|
|
53
|
+
"@jsshaker/binding-win32-x64-msvc": "0.2.6",
|
|
54
|
+
"@jsshaker/binding-darwin-x64": "0.2.6",
|
|
55
|
+
"@jsshaker/binding-darwin-arm64": "0.2.6",
|
|
56
|
+
"@jsshaker/binding-wasm32-wasi": "0.2.6"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"artifacts": "napi artifacts",
|
package/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* auto-generated by NAPI-RS */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export interface Chunk {
|
|
4
|
-
code: string
|
|
5
|
-
sourceMapJson?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface MultiModuleResult {
|
|
9
|
-
output: Record<string, Chunk>
|
|
10
|
-
diagnostics: Array<string>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Options {
|
|
14
|
-
preset?: 'safest' | 'recommended' | 'smallest' | 'disabled'
|
|
15
|
-
minify?: boolean
|
|
16
|
-
alwaysInlineLiteral?: boolean
|
|
17
|
-
jsx?: 'react'
|
|
18
|
-
sourceMap?: boolean
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare function shakeFsModule(entryPath: string, options: Options): MultiModuleResult
|
|
22
|
-
|
|
23
|
-
export declare function shakeMultiModule(sources: Record<string, string>, entry: string, options: Options): MultiModuleResult
|
|
24
|
-
|
|
25
|
-
export declare function shakeSingleModule(sourceText: string, options: Options): SingleModuleResult
|
|
26
|
-
|
|
27
|
-
export interface SingleModuleResult {
|
|
28
|
-
output: Chunk
|
|
29
|
-
diagnostics: Array<string>
|
|
30
|
-
}
|
package/index.js
DELETED
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
// prettier-ignore
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
const { createRequire } = require('node:module')
|
|
7
|
-
require = createRequire(__filename)
|
|
8
|
-
|
|
9
|
-
const { readFileSync } = require('node:fs')
|
|
10
|
-
let nativeBinding = null
|
|
11
|
-
const loadErrors = []
|
|
12
|
-
|
|
13
|
-
const isMusl = () => {
|
|
14
|
-
let musl = false
|
|
15
|
-
if (process.platform === 'linux') {
|
|
16
|
-
musl = isMuslFromFilesystem()
|
|
17
|
-
if (musl === null) {
|
|
18
|
-
musl = isMuslFromReport()
|
|
19
|
-
}
|
|
20
|
-
if (musl === null) {
|
|
21
|
-
musl = isMuslFromChildProcess()
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return musl
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
28
|
-
|
|
29
|
-
const isMuslFromFilesystem = () => {
|
|
30
|
-
try {
|
|
31
|
-
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
32
|
-
} catch {
|
|
33
|
-
return null
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const isMuslFromReport = () => {
|
|
38
|
-
let report = null
|
|
39
|
-
if (typeof process.report?.getReport === 'function') {
|
|
40
|
-
process.report.excludeNetwork = true
|
|
41
|
-
report = process.report.getReport()
|
|
42
|
-
}
|
|
43
|
-
if (!report) {
|
|
44
|
-
return null
|
|
45
|
-
}
|
|
46
|
-
if (report.header && report.header.glibcVersionRuntime) {
|
|
47
|
-
return false
|
|
48
|
-
}
|
|
49
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
50
|
-
if (report.sharedObjects.some(isFileMusl)) {
|
|
51
|
-
return true
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const isMuslFromChildProcess = () => {
|
|
58
|
-
try {
|
|
59
|
-
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
60
|
-
} catch (e) {
|
|
61
|
-
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
62
|
-
return false
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function requireNative() {
|
|
67
|
-
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
|
-
try {
|
|
69
|
-
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
loadErrors.push(err)
|
|
72
|
-
}
|
|
73
|
-
} else if (process.platform === 'android') {
|
|
74
|
-
if (process.arch === 'arm64') {
|
|
75
|
-
try {
|
|
76
|
-
return require('./jsshaker.android-arm64.node')
|
|
77
|
-
} catch (e) {
|
|
78
|
-
loadErrors.push(e)
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
const binding = require('@jsshaker/binding-android-arm64')
|
|
82
|
-
const bindingPackageVersion = require('@jsshaker/binding-android-arm64/package.json').version
|
|
83
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
84
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
85
|
-
}
|
|
86
|
-
return binding
|
|
87
|
-
} catch (e) {
|
|
88
|
-
loadErrors.push(e)
|
|
89
|
-
}
|
|
90
|
-
} else if (process.arch === 'arm') {
|
|
91
|
-
try {
|
|
92
|
-
return require('./jsshaker.android-arm-eabi.node')
|
|
93
|
-
} catch (e) {
|
|
94
|
-
loadErrors.push(e)
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
const binding = require('@jsshaker/binding-android-arm-eabi')
|
|
98
|
-
const bindingPackageVersion = require('@jsshaker/binding-android-arm-eabi/package.json').version
|
|
99
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
100
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
|
-
}
|
|
102
|
-
return binding
|
|
103
|
-
} catch (e) {
|
|
104
|
-
loadErrors.push(e)
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
108
|
-
}
|
|
109
|
-
} else if (process.platform === 'win32') {
|
|
110
|
-
if (process.arch === 'x64') {
|
|
111
|
-
try {
|
|
112
|
-
return require('./jsshaker.win32-x64-msvc.node')
|
|
113
|
-
} catch (e) {
|
|
114
|
-
loadErrors.push(e)
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
const binding = require('@jsshaker/binding-win32-x64-msvc')
|
|
118
|
-
const bindingPackageVersion = require('@jsshaker/binding-win32-x64-msvc/package.json').version
|
|
119
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
120
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
121
|
-
}
|
|
122
|
-
return binding
|
|
123
|
-
} catch (e) {
|
|
124
|
-
loadErrors.push(e)
|
|
125
|
-
}
|
|
126
|
-
} else if (process.arch === 'ia32') {
|
|
127
|
-
try {
|
|
128
|
-
return require('./jsshaker.win32-ia32-msvc.node')
|
|
129
|
-
} catch (e) {
|
|
130
|
-
loadErrors.push(e)
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
const binding = require('@jsshaker/binding-win32-ia32-msvc')
|
|
134
|
-
const bindingPackageVersion = require('@jsshaker/binding-win32-ia32-msvc/package.json').version
|
|
135
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
136
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
137
|
-
}
|
|
138
|
-
return binding
|
|
139
|
-
} catch (e) {
|
|
140
|
-
loadErrors.push(e)
|
|
141
|
-
}
|
|
142
|
-
} else if (process.arch === 'arm64') {
|
|
143
|
-
try {
|
|
144
|
-
return require('./jsshaker.win32-arm64-msvc.node')
|
|
145
|
-
} catch (e) {
|
|
146
|
-
loadErrors.push(e)
|
|
147
|
-
}
|
|
148
|
-
try {
|
|
149
|
-
const binding = require('@jsshaker/binding-win32-arm64-msvc')
|
|
150
|
-
const bindingPackageVersion = require('@jsshaker/binding-win32-arm64-msvc/package.json').version
|
|
151
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
152
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
153
|
-
}
|
|
154
|
-
return binding
|
|
155
|
-
} catch (e) {
|
|
156
|
-
loadErrors.push(e)
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
160
|
-
}
|
|
161
|
-
} else if (process.platform === 'darwin') {
|
|
162
|
-
try {
|
|
163
|
-
return require('./jsshaker.darwin-universal.node')
|
|
164
|
-
} catch (e) {
|
|
165
|
-
loadErrors.push(e)
|
|
166
|
-
}
|
|
167
|
-
try {
|
|
168
|
-
const binding = require('@jsshaker/binding-darwin-universal')
|
|
169
|
-
const bindingPackageVersion = require('@jsshaker/binding-darwin-universal/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
|
-
}
|
|
173
|
-
return binding
|
|
174
|
-
} catch (e) {
|
|
175
|
-
loadErrors.push(e)
|
|
176
|
-
}
|
|
177
|
-
if (process.arch === 'x64') {
|
|
178
|
-
try {
|
|
179
|
-
return require('./jsshaker.darwin-x64.node')
|
|
180
|
-
} catch (e) {
|
|
181
|
-
loadErrors.push(e)
|
|
182
|
-
}
|
|
183
|
-
try {
|
|
184
|
-
const binding = require('@jsshaker/binding-darwin-x64')
|
|
185
|
-
const bindingPackageVersion = require('@jsshaker/binding-darwin-x64/package.json').version
|
|
186
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
|
-
}
|
|
189
|
-
return binding
|
|
190
|
-
} catch (e) {
|
|
191
|
-
loadErrors.push(e)
|
|
192
|
-
}
|
|
193
|
-
} else if (process.arch === 'arm64') {
|
|
194
|
-
try {
|
|
195
|
-
return require('./jsshaker.darwin-arm64.node')
|
|
196
|
-
} catch (e) {
|
|
197
|
-
loadErrors.push(e)
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
const binding = require('@jsshaker/binding-darwin-arm64')
|
|
201
|
-
const bindingPackageVersion = require('@jsshaker/binding-darwin-arm64/package.json').version
|
|
202
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
|
-
}
|
|
205
|
-
return binding
|
|
206
|
-
} catch (e) {
|
|
207
|
-
loadErrors.push(e)
|
|
208
|
-
}
|
|
209
|
-
} else {
|
|
210
|
-
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
211
|
-
}
|
|
212
|
-
} else if (process.platform === 'freebsd') {
|
|
213
|
-
if (process.arch === 'x64') {
|
|
214
|
-
try {
|
|
215
|
-
return require('./jsshaker.freebsd-x64.node')
|
|
216
|
-
} catch (e) {
|
|
217
|
-
loadErrors.push(e)
|
|
218
|
-
}
|
|
219
|
-
try {
|
|
220
|
-
const binding = require('@jsshaker/binding-freebsd-x64')
|
|
221
|
-
const bindingPackageVersion = require('@jsshaker/binding-freebsd-x64/package.json').version
|
|
222
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
|
-
}
|
|
225
|
-
return binding
|
|
226
|
-
} catch (e) {
|
|
227
|
-
loadErrors.push(e)
|
|
228
|
-
}
|
|
229
|
-
} else if (process.arch === 'arm64') {
|
|
230
|
-
try {
|
|
231
|
-
return require('./jsshaker.freebsd-arm64.node')
|
|
232
|
-
} catch (e) {
|
|
233
|
-
loadErrors.push(e)
|
|
234
|
-
}
|
|
235
|
-
try {
|
|
236
|
-
const binding = require('@jsshaker/binding-freebsd-arm64')
|
|
237
|
-
const bindingPackageVersion = require('@jsshaker/binding-freebsd-arm64/package.json').version
|
|
238
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
239
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
240
|
-
}
|
|
241
|
-
return binding
|
|
242
|
-
} catch (e) {
|
|
243
|
-
loadErrors.push(e)
|
|
244
|
-
}
|
|
245
|
-
} else {
|
|
246
|
-
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
247
|
-
}
|
|
248
|
-
} else if (process.platform === 'linux') {
|
|
249
|
-
if (process.arch === 'x64') {
|
|
250
|
-
if (isMusl()) {
|
|
251
|
-
try {
|
|
252
|
-
return require('./jsshaker.linux-x64-musl.node')
|
|
253
|
-
} catch (e) {
|
|
254
|
-
loadErrors.push(e)
|
|
255
|
-
}
|
|
256
|
-
try {
|
|
257
|
-
const binding = require('@jsshaker/binding-linux-x64-musl')
|
|
258
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-x64-musl/package.json').version
|
|
259
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
260
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
261
|
-
}
|
|
262
|
-
return binding
|
|
263
|
-
} catch (e) {
|
|
264
|
-
loadErrors.push(e)
|
|
265
|
-
}
|
|
266
|
-
} else {
|
|
267
|
-
try {
|
|
268
|
-
return require('./jsshaker.linux-x64-gnu.node')
|
|
269
|
-
} catch (e) {
|
|
270
|
-
loadErrors.push(e)
|
|
271
|
-
}
|
|
272
|
-
try {
|
|
273
|
-
const binding = require('@jsshaker/binding-linux-x64-gnu')
|
|
274
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-x64-gnu/package.json').version
|
|
275
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
276
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
277
|
-
}
|
|
278
|
-
return binding
|
|
279
|
-
} catch (e) {
|
|
280
|
-
loadErrors.push(e)
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
} else if (process.arch === 'arm64') {
|
|
284
|
-
if (isMusl()) {
|
|
285
|
-
try {
|
|
286
|
-
return require('./jsshaker.linux-arm64-musl.node')
|
|
287
|
-
} catch (e) {
|
|
288
|
-
loadErrors.push(e)
|
|
289
|
-
}
|
|
290
|
-
try {
|
|
291
|
-
const binding = require('@jsshaker/binding-linux-arm64-musl')
|
|
292
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-arm64-musl/package.json').version
|
|
293
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
294
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
295
|
-
}
|
|
296
|
-
return binding
|
|
297
|
-
} catch (e) {
|
|
298
|
-
loadErrors.push(e)
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
try {
|
|
302
|
-
return require('./jsshaker.linux-arm64-gnu.node')
|
|
303
|
-
} catch (e) {
|
|
304
|
-
loadErrors.push(e)
|
|
305
|
-
}
|
|
306
|
-
try {
|
|
307
|
-
const binding = require('@jsshaker/binding-linux-arm64-gnu')
|
|
308
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-arm64-gnu/package.json').version
|
|
309
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
311
|
-
}
|
|
312
|
-
return binding
|
|
313
|
-
} catch (e) {
|
|
314
|
-
loadErrors.push(e)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
} else if (process.arch === 'arm') {
|
|
318
|
-
if (isMusl()) {
|
|
319
|
-
try {
|
|
320
|
-
return require('./jsshaker.linux-arm-musleabihf.node')
|
|
321
|
-
} catch (e) {
|
|
322
|
-
loadErrors.push(e)
|
|
323
|
-
}
|
|
324
|
-
try {
|
|
325
|
-
const binding = require('@jsshaker/binding-linux-arm-musleabihf')
|
|
326
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-arm-musleabihf/package.json').version
|
|
327
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
328
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
329
|
-
}
|
|
330
|
-
return binding
|
|
331
|
-
} catch (e) {
|
|
332
|
-
loadErrors.push(e)
|
|
333
|
-
}
|
|
334
|
-
} else {
|
|
335
|
-
try {
|
|
336
|
-
return require('./jsshaker.linux-arm-gnueabihf.node')
|
|
337
|
-
} catch (e) {
|
|
338
|
-
loadErrors.push(e)
|
|
339
|
-
}
|
|
340
|
-
try {
|
|
341
|
-
const binding = require('@jsshaker/binding-linux-arm-gnueabihf')
|
|
342
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-arm-gnueabihf/package.json').version
|
|
343
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
344
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
345
|
-
}
|
|
346
|
-
return binding
|
|
347
|
-
} catch (e) {
|
|
348
|
-
loadErrors.push(e)
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
} else if (process.arch === 'riscv64') {
|
|
352
|
-
if (isMusl()) {
|
|
353
|
-
try {
|
|
354
|
-
return require('./jsshaker.linux-riscv64-musl.node')
|
|
355
|
-
} catch (e) {
|
|
356
|
-
loadErrors.push(e)
|
|
357
|
-
}
|
|
358
|
-
try {
|
|
359
|
-
const binding = require('@jsshaker/binding-linux-riscv64-musl')
|
|
360
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-riscv64-musl/package.json').version
|
|
361
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
362
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
363
|
-
}
|
|
364
|
-
return binding
|
|
365
|
-
} catch (e) {
|
|
366
|
-
loadErrors.push(e)
|
|
367
|
-
}
|
|
368
|
-
} else {
|
|
369
|
-
try {
|
|
370
|
-
return require('./jsshaker.linux-riscv64-gnu.node')
|
|
371
|
-
} catch (e) {
|
|
372
|
-
loadErrors.push(e)
|
|
373
|
-
}
|
|
374
|
-
try {
|
|
375
|
-
const binding = require('@jsshaker/binding-linux-riscv64-gnu')
|
|
376
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-riscv64-gnu/package.json').version
|
|
377
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
378
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
379
|
-
}
|
|
380
|
-
return binding
|
|
381
|
-
} catch (e) {
|
|
382
|
-
loadErrors.push(e)
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
} else if (process.arch === 'ppc64') {
|
|
386
|
-
try {
|
|
387
|
-
return require('./jsshaker.linux-ppc64-gnu.node')
|
|
388
|
-
} catch (e) {
|
|
389
|
-
loadErrors.push(e)
|
|
390
|
-
}
|
|
391
|
-
try {
|
|
392
|
-
const binding = require('@jsshaker/binding-linux-ppc64-gnu')
|
|
393
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-ppc64-gnu/package.json').version
|
|
394
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
395
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
396
|
-
}
|
|
397
|
-
return binding
|
|
398
|
-
} catch (e) {
|
|
399
|
-
loadErrors.push(e)
|
|
400
|
-
}
|
|
401
|
-
} else if (process.arch === 's390x') {
|
|
402
|
-
try {
|
|
403
|
-
return require('./jsshaker.linux-s390x-gnu.node')
|
|
404
|
-
} catch (e) {
|
|
405
|
-
loadErrors.push(e)
|
|
406
|
-
}
|
|
407
|
-
try {
|
|
408
|
-
const binding = require('@jsshaker/binding-linux-s390x-gnu')
|
|
409
|
-
const bindingPackageVersion = require('@jsshaker/binding-linux-s390x-gnu/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
|
-
}
|
|
413
|
-
return binding
|
|
414
|
-
} catch (e) {
|
|
415
|
-
loadErrors.push(e)
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
419
|
-
}
|
|
420
|
-
} else if (process.platform === 'openharmony') {
|
|
421
|
-
if (process.arch === 'arm64') {
|
|
422
|
-
try {
|
|
423
|
-
return require('./jsshaker.openharmony-arm64.node')
|
|
424
|
-
} catch (e) {
|
|
425
|
-
loadErrors.push(e)
|
|
426
|
-
}
|
|
427
|
-
try {
|
|
428
|
-
const binding = require('@jsshaker/binding-openharmony-arm64')
|
|
429
|
-
const bindingPackageVersion = require('@jsshaker/binding-openharmony-arm64/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
|
-
}
|
|
433
|
-
return binding
|
|
434
|
-
} catch (e) {
|
|
435
|
-
loadErrors.push(e)
|
|
436
|
-
}
|
|
437
|
-
} else if (process.arch === 'x64') {
|
|
438
|
-
try {
|
|
439
|
-
return require('./jsshaker.openharmony-x64.node')
|
|
440
|
-
} catch (e) {
|
|
441
|
-
loadErrors.push(e)
|
|
442
|
-
}
|
|
443
|
-
try {
|
|
444
|
-
const binding = require('@jsshaker/binding-openharmony-x64')
|
|
445
|
-
const bindingPackageVersion = require('@jsshaker/binding-openharmony-x64/package.json').version
|
|
446
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
447
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
448
|
-
}
|
|
449
|
-
return binding
|
|
450
|
-
} catch (e) {
|
|
451
|
-
loadErrors.push(e)
|
|
452
|
-
}
|
|
453
|
-
} else if (process.arch === 'arm') {
|
|
454
|
-
try {
|
|
455
|
-
return require('./jsshaker.openharmony-arm.node')
|
|
456
|
-
} catch (e) {
|
|
457
|
-
loadErrors.push(e)
|
|
458
|
-
}
|
|
459
|
-
try {
|
|
460
|
-
const binding = require('@jsshaker/binding-openharmony-arm')
|
|
461
|
-
const bindingPackageVersion = require('@jsshaker/binding-openharmony-arm/package.json').version
|
|
462
|
-
if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
463
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
464
|
-
}
|
|
465
|
-
return binding
|
|
466
|
-
} catch (e) {
|
|
467
|
-
loadErrors.push(e)
|
|
468
|
-
}
|
|
469
|
-
} else {
|
|
470
|
-
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
471
|
-
}
|
|
472
|
-
} else {
|
|
473
|
-
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
nativeBinding = requireNative()
|
|
478
|
-
|
|
479
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
480
|
-
try {
|
|
481
|
-
nativeBinding = require('./jsshaker.wasi.cjs')
|
|
482
|
-
} catch (err) {
|
|
483
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
484
|
-
loadErrors.push(err)
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (!nativeBinding) {
|
|
488
|
-
try {
|
|
489
|
-
nativeBinding = require('@jsshaker/binding-wasm32-wasi')
|
|
490
|
-
} catch (err) {
|
|
491
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
492
|
-
loadErrors.push(err)
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
if (!nativeBinding) {
|
|
499
|
-
if (loadErrors.length > 0) {
|
|
500
|
-
throw new Error(
|
|
501
|
-
`Cannot find native binding. ` +
|
|
502
|
-
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
503
|
-
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
504
|
-
{ cause: loadErrors }
|
|
505
|
-
)
|
|
506
|
-
}
|
|
507
|
-
throw new Error(`Failed to load native binding`)
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
module.exports = nativeBinding
|
|
511
|
-
module.exports.shakeFsModule = nativeBinding.shakeFsModule
|
|
512
|
-
module.exports.shakeMultiModule = nativeBinding.shakeMultiModule
|
|
513
|
-
module.exports.shakeSingleModule = nativeBinding.shakeSingleModule
|