@swc/minifier 1.3.92 → 1.12.2
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/package.json +21 -34
- package/scripts/cli_artifacts.sh +22 -0
- package/src/binding.d.ts +17 -6
- package/src/binding.js +336 -228
- package/src/index.ts +4 -4
- package/binding.d.ts +0 -4
- package/binding.js +0 -266
- package/index.d.ts +0 -11
- package/index.js +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swc/minifier",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "Super-fast alternative for terser",
|
|
5
5
|
"homepage": "https://swc.rs",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"url": "https://github.com/swc-project/swc/issues"
|
|
23
23
|
},
|
|
24
24
|
"napi": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
"binaryName": "minifier",
|
|
26
|
+
"targets": [
|
|
27
|
+
"x86_64-apple-darwin",
|
|
28
|
+
"x86_64-pc-windows-msvc",
|
|
29
|
+
"x86_64-unknown-linux-gnu",
|
|
30
|
+
"x86_64-unknown-linux-musl",
|
|
31
|
+
"i686-pc-windows-msvc",
|
|
32
|
+
"armv7-unknown-linux-gnueabihf",
|
|
33
|
+
"aarch64-unknown-linux-gnu",
|
|
34
|
+
"aarch64-apple-darwin",
|
|
35
|
+
"aarch64-unknown-linux-musl",
|
|
36
|
+
"aarch64-pc-windows-msvc"
|
|
37
|
+
]
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -42,41 +42,28 @@
|
|
|
42
42
|
},
|
|
43
43
|
"types": "./index.d.ts",
|
|
44
44
|
"scripts": {
|
|
45
|
-
"artifacts": "napi artifacts --
|
|
45
|
+
"artifacts": "napi artifacts --npm-dir scripts/npm",
|
|
46
46
|
"prepublishOnly": "tsc -d && napi prepublish -p scripts/npm --tagstyle npm",
|
|
47
47
|
"pack": "wasm-pack",
|
|
48
48
|
"build:ts": "tsc -d",
|
|
49
49
|
"build:wasm": "npm-run-all \"pack -- build ../../bindings/binding_minifier_wasm --scope swc {1} -t {2}\" --",
|
|
50
|
-
"build": "tsc -d && napi build --platform --
|
|
51
|
-
"build:dev": "tsc -d && napi build --platform --
|
|
50
|
+
"build": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_minifier_node --output-dir . --release",
|
|
51
|
+
"build:dev": "tsc -d && napi build --platform --js ./src/binding.js --dts ./src/binding.d.ts --manifest-path ../../bindings/Cargo.toml -p binding_minifier_node --output-dir .",
|
|
52
52
|
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' echo 'no test'",
|
|
53
|
-
"version": "napi version -
|
|
53
|
+
"version": "napi version --npm-dir scripts/npm"
|
|
54
54
|
},
|
|
55
55
|
"funding": {
|
|
56
56
|
"type": "opencollective",
|
|
57
57
|
"url": "https://opencollective.com/swc"
|
|
58
58
|
},
|
|
59
|
-
"packageManager": "yarn@3.5.0",
|
|
60
59
|
"dependencies": {
|
|
61
|
-
"@swc/counter": "
|
|
62
|
-
"@swc/types": "
|
|
60
|
+
"@swc/counter": "^0.1.3",
|
|
61
|
+
"@swc/types": "^0.1.23"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@napi-rs/cli": "^
|
|
64
|
+
"@napi-rs/cli": "^3.0.0-alpha.22",
|
|
66
65
|
"@types/node": "^20.7.1",
|
|
67
66
|
"cross-env": "^7.0.3",
|
|
68
67
|
"typescript": "^5.2.2"
|
|
69
|
-
},
|
|
70
|
-
"optionalDependencies": {
|
|
71
|
-
"@swc/minifier-win32-x64-msvc": "1.3.92",
|
|
72
|
-
"@swc/minifier-darwin-x64": "1.3.92",
|
|
73
|
-
"@swc/minifier-linux-x64-gnu": "1.3.92",
|
|
74
|
-
"@swc/minifier-linux-x64-musl": "1.3.92",
|
|
75
|
-
"@swc/minifier-win32-ia32-msvc": "1.3.92",
|
|
76
|
-
"@swc/minifier-linux-arm64-gnu": "1.3.92",
|
|
77
|
-
"@swc/minifier-linux-arm-gnueabihf": "1.3.92",
|
|
78
|
-
"@swc/minifier-darwin-arm64": "1.3.92",
|
|
79
|
-
"@swc/minifier-linux-arm64-musl": "1.3.92",
|
|
80
|
-
"@swc/minifier-win32-arm64-msvc": "1.3.92"
|
|
81
68
|
}
|
|
82
69
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
mkdir -p ./artifacts_cli
|
|
4
|
+
# Naive substitution to napi artifacts for the cli binary.
|
|
5
|
+
for filename in artifacts/*/*.node
|
|
6
|
+
do
|
|
7
|
+
BINDING_NAME=${filename#*.}
|
|
8
|
+
BINDING_ABI=${BINDING_NAME%%.*}
|
|
9
|
+
CLI_BINARY_PATH=${filename%%.*}
|
|
10
|
+
|
|
11
|
+
echo "Preparing build artifacts:"
|
|
12
|
+
echo "Binding name $BINDING_NAME"
|
|
13
|
+
echo "Filename $filename"
|
|
14
|
+
echo "Cli binary path $CLI_BINARY_PATH"
|
|
15
|
+
|
|
16
|
+
if [ -f "$CLI_BINARY_PATH" ]; then
|
|
17
|
+
chmod +x $CLI_BINARY_PATH
|
|
18
|
+
mv -v $CLI_BINARY_PATH ./artifacts_cli/swc-$BINDING_ABI
|
|
19
|
+
elif [ -f "$CLI_BINARY_PATH.exe" ]; then
|
|
20
|
+
mv -v $CLI_BINARY_PATH.exe ./artifacts_cli/swc-$BINDING_ABI.exe
|
|
21
|
+
fi
|
|
22
|
+
done
|
package/src/binding.d.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export declare function getTargetTriple(): string
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
|
6
|
+
|
|
7
|
+
export declare function minify(code: Buffer, opts: Buffer, extras: NapiMinifyExtra, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
8
|
+
|
|
9
|
+
export declare function minifySync(code: Buffer, opts: Buffer, extras: NapiMinifyExtra): TransformOutput
|
|
10
|
+
|
|
11
|
+
export interface NapiMinifyExtra {
|
|
12
|
+
mangleNameCache?: object
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare function newMangleNameCache(): object
|
|
5
16
|
|
|
6
17
|
export interface TransformOutput {
|
|
7
18
|
code: string
|
|
8
19
|
map?: string
|
|
20
|
+
output?: string
|
|
21
|
+
diagnostics: Array<string>
|
|
9
22
|
}
|
|
10
|
-
|
|
11
|
-
export function minifySync(code: Buffer, opts: Buffer): TransformOutput
|
|
12
|
-
export function getTargetTriple(): string
|
|
13
|
-
export function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
|
23
|
+
|
|
14
24
|
/** Hack for `Type Generation` */
|
|
15
25
|
export interface TransformOutput {
|
|
16
26
|
code: string
|
|
17
27
|
map?: string
|
|
18
28
|
}
|
|
29
|
+
|
package/src/binding.js
CHANGED
|
@@ -1,260 +1,368 @@
|
|
|
1
|
-
|
|
1
|
+
// prettier-ignore
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
/* prettier-ignore */
|
|
4
|
-
|
|
5
3
|
/* auto-generated by NAPI-RS */
|
|
6
4
|
|
|
7
|
-
const {
|
|
8
|
-
const { join } = require('path')
|
|
9
|
-
|
|
10
|
-
const { platform, arch } = process
|
|
5
|
+
const { readFileSync } = require('fs')
|
|
11
6
|
|
|
12
7
|
let nativeBinding = null
|
|
13
|
-
|
|
14
|
-
let loadError = null
|
|
8
|
+
const loadErrors = []
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
|
|
36
|
+
if (!report) {
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
43
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
23
44
|
return true
|
|
24
45
|
}
|
|
25
|
-
} else {
|
|
26
|
-
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
-
return !glibcVersionRuntime
|
|
28
46
|
}
|
|
47
|
+
return false
|
|
29
48
|
}
|
|
30
49
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
const isMuslFromChildProcess = () => {
|
|
51
|
+
try {
|
|
52
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function requireNative() {
|
|
60
|
+
if (process.platform === 'android') {
|
|
61
|
+
if (process.arch === 'arm64') {
|
|
62
|
+
try {
|
|
63
|
+
return require('./minifier.android-arm64.node')
|
|
64
|
+
} catch (e) {
|
|
65
|
+
loadErrors.push(e)
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return require('@swc/minifier-android-arm64')
|
|
69
|
+
} catch (e) {
|
|
70
|
+
loadErrors.push(e)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} else if (process.arch === 'arm') {
|
|
74
|
+
try {
|
|
75
|
+
return require('./minifier.android-arm-eabi.node')
|
|
76
|
+
} catch (e) {
|
|
77
|
+
loadErrors.push(e)
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
return require('@swc/minifier-android-arm-eabi')
|
|
81
|
+
} catch (e) {
|
|
82
|
+
loadErrors.push(e)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} else {
|
|
86
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
87
|
+
}
|
|
88
|
+
} else if (process.platform === 'win32') {
|
|
89
|
+
if (process.arch === 'x64') {
|
|
90
|
+
try {
|
|
91
|
+
return require('./minifier.win32-x64-msvc.node')
|
|
92
|
+
} catch (e) {
|
|
93
|
+
loadErrors.push(e)
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return require('@swc/minifier-win32-x64-msvc')
|
|
97
|
+
} catch (e) {
|
|
98
|
+
loadErrors.push(e)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
} else if (process.arch === 'ia32') {
|
|
102
|
+
try {
|
|
103
|
+
return require('./minifier.win32-ia32-msvc.node')
|
|
104
|
+
} catch (e) {
|
|
105
|
+
loadErrors.push(e)
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
return require('@swc/minifier-win32-ia32-msvc')
|
|
109
|
+
} catch (e) {
|
|
110
|
+
loadErrors.push(e)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} else if (process.arch === 'arm64') {
|
|
114
|
+
try {
|
|
115
|
+
return require('./minifier.win32-arm64-msvc.node')
|
|
116
|
+
} catch (e) {
|
|
117
|
+
loadErrors.push(e)
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return require('@swc/minifier-win32-arm64-msvc')
|
|
121
|
+
} catch (e) {
|
|
122
|
+
loadErrors.push(e)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
} else {
|
|
126
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
127
|
+
}
|
|
128
|
+
} else if (process.platform === 'darwin') {
|
|
129
|
+
try {
|
|
130
|
+
return require('./minifier.darwin-universal.node')
|
|
131
|
+
} catch (e) {
|
|
132
|
+
loadErrors.push(e)
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
return require('@swc/minifier-darwin-universal')
|
|
136
|
+
} catch (e) {
|
|
137
|
+
loadErrors.push(e)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (process.arch === 'x64') {
|
|
141
|
+
try {
|
|
142
|
+
return require('./minifier.darwin-x64.node')
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadErrors.push(e)
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
return require('@swc/minifier-darwin-x64')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadErrors.push(e)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
} else if (process.arch === 'arm64') {
|
|
153
|
+
try {
|
|
154
|
+
return require('./minifier.darwin-arm64.node')
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e)
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
return require('@swc/minifier-darwin-arm64')
|
|
160
|
+
} catch (e) {
|
|
161
|
+
loadErrors.push(e)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
} else {
|
|
165
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
166
|
+
}
|
|
167
|
+
} else if (process.platform === 'freebsd') {
|
|
168
|
+
if (process.arch === 'x64') {
|
|
169
|
+
try {
|
|
170
|
+
return require('./minifier.freebsd-x64.node')
|
|
171
|
+
} catch (e) {
|
|
172
|
+
loadErrors.push(e)
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
return require('@swc/minifier-freebsd-x64')
|
|
176
|
+
} catch (e) {
|
|
177
|
+
loadErrors.push(e)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
} else if (process.arch === 'arm64') {
|
|
181
|
+
try {
|
|
182
|
+
return require('./minifier.freebsd-arm64.node')
|
|
183
|
+
} catch (e) {
|
|
184
|
+
loadErrors.push(e)
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
return require('@swc/minifier-freebsd-arm64')
|
|
188
|
+
} catch (e) {
|
|
189
|
+
loadErrors.push(e)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
} else {
|
|
193
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
194
|
+
}
|
|
195
|
+
} else if (process.platform === 'linux') {
|
|
196
|
+
if (process.arch === 'x64') {
|
|
197
|
+
if (isMusl()) {
|
|
36
198
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
199
|
+
return require('./minifier.linux-x64-musl.node')
|
|
200
|
+
} catch (e) {
|
|
201
|
+
loadErrors.push(e)
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return require('@swc/minifier-linux-x64-musl')
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadErrors.push(e)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
} else {
|
|
48
210
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
case 'win32':
|
|
63
|
-
switch (arch) {
|
|
64
|
-
case 'x64':
|
|
65
|
-
localFileExisted = existsSync(
|
|
66
|
-
join(__dirname, 'minifier.win32-x64-msvc.node')
|
|
67
|
-
)
|
|
211
|
+
return require('./minifier.linux-x64-gnu.node')
|
|
212
|
+
} catch (e) {
|
|
213
|
+
loadErrors.push(e)
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
return require('@swc/minifier-linux-x64-gnu')
|
|
217
|
+
} catch (e) {
|
|
218
|
+
loadErrors.push(e)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
} else if (process.arch === 'arm64') {
|
|
223
|
+
if (isMusl()) {
|
|
68
224
|
try {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
join(__dirname, 'minifier.win32-ia32-msvc.node')
|
|
81
|
-
)
|
|
225
|
+
return require('./minifier.linux-arm64-musl.node')
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
return require('@swc/minifier-linux-arm64-musl')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
} else {
|
|
82
236
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
237
|
+
return require('./minifier.linux-arm64-gnu.node')
|
|
238
|
+
} catch (e) {
|
|
239
|
+
loadErrors.push(e)
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
return require('@swc/minifier-linux-arm64-gnu')
|
|
243
|
+
} catch (e) {
|
|
244
|
+
loadErrors.push(e)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
} else if (process.arch === 'arm') {
|
|
249
|
+
if (isMusl()) {
|
|
96
250
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
-
}
|
|
109
|
-
break
|
|
110
|
-
case 'darwin':
|
|
111
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.darwin-universal.node'))
|
|
112
|
-
try {
|
|
113
|
-
if (localFileExisted) {
|
|
114
|
-
nativeBinding = require('./minifier.darwin-universal.node')
|
|
251
|
+
return require('./minifier.linux-arm-musleabihf.node')
|
|
252
|
+
} catch (e) {
|
|
253
|
+
loadErrors.push(e)
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
return require('@swc/minifier-linux-arm-musleabihf')
|
|
257
|
+
} catch (e) {
|
|
258
|
+
loadErrors.push(e)
|
|
259
|
+
}
|
|
260
|
+
|
|
115
261
|
} else {
|
|
116
|
-
|
|
262
|
+
try {
|
|
263
|
+
return require('./minifier.linux-arm-gnueabihf.node')
|
|
264
|
+
} catch (e) {
|
|
265
|
+
loadErrors.push(e)
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return require('@swc/minifier-linux-arm-gnueabihf')
|
|
269
|
+
} catch (e) {
|
|
270
|
+
loadErrors.push(e)
|
|
271
|
+
}
|
|
272
|
+
|
|
117
273
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
switch (arch) {
|
|
121
|
-
case 'x64':
|
|
122
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.darwin-x64.node'))
|
|
274
|
+
} else if (process.arch === 'riscv64') {
|
|
275
|
+
if (isMusl()) {
|
|
123
276
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
join(__dirname, 'minifier.darwin-arm64.node')
|
|
136
|
-
)
|
|
277
|
+
return require('./minifier.linux-riscv64-musl.node')
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
return require('@swc/minifier-linux-riscv64-musl')
|
|
283
|
+
} catch (e) {
|
|
284
|
+
loadErrors.push(e)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
} else {
|
|
137
288
|
try {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
289
|
+
return require('./minifier.linux-riscv64-gnu.node')
|
|
290
|
+
} catch (e) {
|
|
291
|
+
loadErrors.push(e)
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
return require('@swc/minifier-linux-riscv64-gnu')
|
|
295
|
+
} catch (e) {
|
|
296
|
+
loadErrors.push(e)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
} else if (process.arch === 'ppc64') {
|
|
301
|
+
try {
|
|
302
|
+
return require('./minifier.linux-ppc64-gnu.node')
|
|
303
|
+
} catch (e) {
|
|
304
|
+
loadErrors.push(e)
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
return require('@swc/minifier-linux-ppc64-gnu')
|
|
308
|
+
} catch (e) {
|
|
309
|
+
loadErrors.push(e)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
} else if (process.arch === 's390x') {
|
|
313
|
+
try {
|
|
314
|
+
return require('./minifier.linux-s390x-gnu.node')
|
|
315
|
+
} catch (e) {
|
|
316
|
+
loadErrors.push(e)
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
return require('@swc/minifier-linux-s390x-gnu')
|
|
320
|
+
} catch (e) {
|
|
321
|
+
loadErrors.push(e)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
} else {
|
|
325
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
149
326
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
327
|
+
} else {
|
|
328
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
nativeBinding = requireNative()
|
|
333
|
+
|
|
334
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
335
|
+
try {
|
|
336
|
+
nativeBinding = require('./minifier.wasi.cjs')
|
|
337
|
+
} catch (err) {
|
|
338
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
339
|
+
console.error(err)
|
|
154
340
|
}
|
|
155
|
-
|
|
341
|
+
}
|
|
342
|
+
if (!nativeBinding) {
|
|
156
343
|
try {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
344
|
+
nativeBinding = require('@swc/minifier-wasm32-wasi')
|
|
345
|
+
} catch (err) {
|
|
346
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
347
|
+
console.error(err)
|
|
161
348
|
}
|
|
162
|
-
} catch (e) {
|
|
163
|
-
loadError = e
|
|
164
|
-
}
|
|
165
|
-
break
|
|
166
|
-
case 'linux':
|
|
167
|
-
switch (arch) {
|
|
168
|
-
case 'x64':
|
|
169
|
-
if (isMusl()) {
|
|
170
|
-
localFileExisted = existsSync(
|
|
171
|
-
join(__dirname, 'minifier.linux-x64-musl.node')
|
|
172
|
-
)
|
|
173
|
-
try {
|
|
174
|
-
if (localFileExisted) {
|
|
175
|
-
nativeBinding = require('./minifier.linux-x64-musl.node')
|
|
176
|
-
} else {
|
|
177
|
-
nativeBinding = require('@swc/minifier-linux-x64-musl')
|
|
178
|
-
}
|
|
179
|
-
} catch (e) {
|
|
180
|
-
loadError = e
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
localFileExisted = existsSync(
|
|
184
|
-
join(__dirname, 'minifier.linux-x64-gnu.node')
|
|
185
|
-
)
|
|
186
|
-
try {
|
|
187
|
-
if (localFileExisted) {
|
|
188
|
-
nativeBinding = require('./minifier.linux-x64-gnu.node')
|
|
189
|
-
} else {
|
|
190
|
-
nativeBinding = require('@swc/minifier-linux-x64-gnu')
|
|
191
|
-
}
|
|
192
|
-
} catch (e) {
|
|
193
|
-
loadError = e
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
break
|
|
197
|
-
case 'arm64':
|
|
198
|
-
if (isMusl()) {
|
|
199
|
-
localFileExisted = existsSync(
|
|
200
|
-
join(__dirname, 'minifier.linux-arm64-musl.node')
|
|
201
|
-
)
|
|
202
|
-
try {
|
|
203
|
-
if (localFileExisted) {
|
|
204
|
-
nativeBinding = require('./minifier.linux-arm64-musl.node')
|
|
205
|
-
} else {
|
|
206
|
-
nativeBinding = require('@swc/minifier-linux-arm64-musl')
|
|
207
|
-
}
|
|
208
|
-
} catch (e) {
|
|
209
|
-
loadError = e
|
|
210
|
-
}
|
|
211
|
-
} else {
|
|
212
|
-
localFileExisted = existsSync(
|
|
213
|
-
join(__dirname, 'minifier.linux-arm64-gnu.node')
|
|
214
|
-
)
|
|
215
|
-
try {
|
|
216
|
-
if (localFileExisted) {
|
|
217
|
-
nativeBinding = require('./minifier.linux-arm64-gnu.node')
|
|
218
|
-
} else {
|
|
219
|
-
nativeBinding = require('@swc/minifier-linux-arm64-gnu')
|
|
220
|
-
}
|
|
221
|
-
} catch (e) {
|
|
222
|
-
loadError = e
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
break
|
|
226
|
-
case 'arm':
|
|
227
|
-
localFileExisted = existsSync(
|
|
228
|
-
join(__dirname, 'minifier.linux-arm-gnueabihf.node')
|
|
229
|
-
)
|
|
230
|
-
try {
|
|
231
|
-
if (localFileExisted) {
|
|
232
|
-
nativeBinding = require('./minifier.linux-arm-gnueabihf.node')
|
|
233
|
-
} else {
|
|
234
|
-
nativeBinding = require('@swc/minifier-linux-arm-gnueabihf')
|
|
235
|
-
}
|
|
236
|
-
} catch (e) {
|
|
237
|
-
loadError = e
|
|
238
|
-
}
|
|
239
|
-
break
|
|
240
|
-
default:
|
|
241
|
-
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
242
349
|
}
|
|
243
|
-
|
|
244
|
-
default:
|
|
245
|
-
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
350
|
+
}
|
|
246
351
|
}
|
|
247
352
|
|
|
248
353
|
if (!nativeBinding) {
|
|
249
|
-
if (
|
|
250
|
-
|
|
354
|
+
if (loadErrors.length > 0) {
|
|
355
|
+
// TODO Link to documentation with potential fixes
|
|
356
|
+
// - The package owner could build/publish bindings for this arch
|
|
357
|
+
// - The user may need to bundle the correct files
|
|
358
|
+
// - The user may need to re-install node_modules to get new packages
|
|
359
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
251
360
|
}
|
|
252
361
|
throw new Error(`Failed to load native binding`)
|
|
253
362
|
}
|
|
254
363
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
module.exports.minify = minify
|
|
258
|
-
module.exports.minifySync = minifySync
|
|
259
|
-
module.exports.
|
|
260
|
-
module.exports.initCustomTraceSubscriber = initCustomTraceSubscriber
|
|
364
|
+
module.exports.getTargetTriple = nativeBinding.getTargetTriple
|
|
365
|
+
module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber
|
|
366
|
+
module.exports.minify = nativeBinding.minify
|
|
367
|
+
module.exports.minifySync = nativeBinding.minifySync
|
|
368
|
+
module.exports.newMangleNameCache = nativeBinding.newMangleNameCache
|
package/src/index.ts
CHANGED
|
@@ -5,16 +5,16 @@ import * as binding from './binding'
|
|
|
5
5
|
/**
|
|
6
6
|
* TODO
|
|
7
7
|
*/
|
|
8
|
-
export async function minify(code: Buffer, options: JsMinifyOptions) {
|
|
9
|
-
return await binding.minify(code, toBuffer(options))
|
|
8
|
+
export async function minify(code: string | Buffer, options: JsMinifyOptions) {
|
|
9
|
+
return await binding.minify(Buffer.from(code), toBuffer(options), {})
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* TODO
|
|
15
15
|
*/
|
|
16
|
-
export function minifySync(code: Buffer, options: JsMinifyOptions): binding.TransformOutput {
|
|
17
|
-
return binding.minifySync(code, toBuffer(options))
|
|
16
|
+
export function minifySync(code: string | Buffer, options: JsMinifyOptions): binding.TransformOutput {
|
|
17
|
+
return binding.minifySync(Buffer.from(code), toBuffer(options), {})
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|
package/binding.d.ts
DELETED
package/binding.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
/* prettier-ignore */
|
|
5
|
-
/* auto-generated by NAPI-RS */
|
|
6
|
-
const { existsSync, readFileSync } = require('fs');
|
|
7
|
-
const { join } = require('path');
|
|
8
|
-
const { platform, arch } = process;
|
|
9
|
-
let nativeBinding = null;
|
|
10
|
-
let localFileExisted = false;
|
|
11
|
-
let loadError = null;
|
|
12
|
-
function isMusl() {
|
|
13
|
-
// For Node 10
|
|
14
|
-
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
15
|
-
try {
|
|
16
|
-
const lddPath = require('child_process').execSync('which ldd').toString().trim();
|
|
17
|
-
return readFileSync(lddPath, 'utf8').includes('musl');
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
25
|
-
return !glibcVersionRuntime;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
switch (platform) {
|
|
29
|
-
case 'android':
|
|
30
|
-
switch (arch) {
|
|
31
|
-
case 'arm64':
|
|
32
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.android-arm64.node'));
|
|
33
|
-
try {
|
|
34
|
-
if (localFileExisted) {
|
|
35
|
-
nativeBinding = require('./minifier.android-arm64.node');
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
nativeBinding = require('@swc/minifier-android-arm64');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
loadError = e;
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
case 'arm':
|
|
46
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.android-arm-eabi.node'));
|
|
47
|
-
try {
|
|
48
|
-
if (localFileExisted) {
|
|
49
|
-
nativeBinding = require('./minifier.android-arm-eabi.node');
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
nativeBinding = require('@swc/minifier-android-arm-eabi');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
loadError = e;
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
61
|
-
}
|
|
62
|
-
break;
|
|
63
|
-
case 'win32':
|
|
64
|
-
switch (arch) {
|
|
65
|
-
case 'x64':
|
|
66
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.win32-x64-msvc.node'));
|
|
67
|
-
try {
|
|
68
|
-
if (localFileExisted) {
|
|
69
|
-
nativeBinding = require('./minifier.win32-x64-msvc.node');
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
nativeBinding = require('@swc/minifier-win32-x64-msvc');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
loadError = e;
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case 'ia32':
|
|
80
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.win32-ia32-msvc.node'));
|
|
81
|
-
try {
|
|
82
|
-
if (localFileExisted) {
|
|
83
|
-
nativeBinding = require('./minifier.win32-ia32-msvc.node');
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
nativeBinding = require('@swc/minifier-win32-ia32-msvc');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
loadError = e;
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
case 'arm64':
|
|
94
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.win32-arm64-msvc.node'));
|
|
95
|
-
try {
|
|
96
|
-
if (localFileExisted) {
|
|
97
|
-
nativeBinding = require('./minifier.win32-arm64-msvc.node');
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
nativeBinding = require('@swc/minifier-win32-arm64-msvc');
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
loadError = e;
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
default:
|
|
108
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
case 'darwin':
|
|
112
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.darwin-universal.node'));
|
|
113
|
-
try {
|
|
114
|
-
if (localFileExisted) {
|
|
115
|
-
nativeBinding = require('./minifier.darwin-universal.node');
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
nativeBinding = require('@swc/minifier-darwin-universal');
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
catch { }
|
|
123
|
-
switch (arch) {
|
|
124
|
-
case 'x64':
|
|
125
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.darwin-x64.node'));
|
|
126
|
-
try {
|
|
127
|
-
if (localFileExisted) {
|
|
128
|
-
nativeBinding = require('./minifier.darwin-x64.node');
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
nativeBinding = require('@swc/minifier-darwin-x64');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
loadError = e;
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
case 'arm64':
|
|
139
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.darwin-arm64.node'));
|
|
140
|
-
try {
|
|
141
|
-
if (localFileExisted) {
|
|
142
|
-
nativeBinding = require('./minifier.darwin-arm64.node');
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
nativeBinding = require('@swc/minifier-darwin-arm64');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
loadError = e;
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
case 'freebsd':
|
|
157
|
-
if (arch !== 'x64') {
|
|
158
|
-
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
159
|
-
}
|
|
160
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.freebsd-x64.node'));
|
|
161
|
-
try {
|
|
162
|
-
if (localFileExisted) {
|
|
163
|
-
nativeBinding = require('./minifier.freebsd-x64.node');
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
nativeBinding = require('@swc/minifier-freebsd-x64');
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
loadError = e;
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
case 'linux':
|
|
174
|
-
switch (arch) {
|
|
175
|
-
case 'x64':
|
|
176
|
-
if (isMusl()) {
|
|
177
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.linux-x64-musl.node'));
|
|
178
|
-
try {
|
|
179
|
-
if (localFileExisted) {
|
|
180
|
-
nativeBinding = require('./minifier.linux-x64-musl.node');
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
nativeBinding = require('@swc/minifier-linux-x64-musl');
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
catch (e) {
|
|
187
|
-
loadError = e;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.linux-x64-gnu.node'));
|
|
192
|
-
try {
|
|
193
|
-
if (localFileExisted) {
|
|
194
|
-
nativeBinding = require('./minifier.linux-x64-gnu.node');
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
nativeBinding = require('@swc/minifier-linux-x64-gnu');
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
loadError = e;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
break;
|
|
205
|
-
case 'arm64':
|
|
206
|
-
if (isMusl()) {
|
|
207
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.linux-arm64-musl.node'));
|
|
208
|
-
try {
|
|
209
|
-
if (localFileExisted) {
|
|
210
|
-
nativeBinding = require('./minifier.linux-arm64-musl.node');
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
nativeBinding = require('@swc/minifier-linux-arm64-musl');
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
catch (e) {
|
|
217
|
-
loadError = e;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.linux-arm64-gnu.node'));
|
|
222
|
-
try {
|
|
223
|
-
if (localFileExisted) {
|
|
224
|
-
nativeBinding = require('./minifier.linux-arm64-gnu.node');
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
nativeBinding = require('@swc/minifier-linux-arm64-gnu');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch (e) {
|
|
231
|
-
loadError = e;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
break;
|
|
235
|
-
case 'arm':
|
|
236
|
-
localFileExisted = existsSync(join(__dirname, 'minifier.linux-arm-gnueabihf.node'));
|
|
237
|
-
try {
|
|
238
|
-
if (localFileExisted) {
|
|
239
|
-
nativeBinding = require('./minifier.linux-arm-gnueabihf.node');
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
nativeBinding = require('@swc/minifier-linux-arm-gnueabihf');
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
catch (e) {
|
|
246
|
-
loadError = e;
|
|
247
|
-
}
|
|
248
|
-
break;
|
|
249
|
-
default:
|
|
250
|
-
throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
251
|
-
}
|
|
252
|
-
break;
|
|
253
|
-
default:
|
|
254
|
-
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
255
|
-
}
|
|
256
|
-
if (!nativeBinding) {
|
|
257
|
-
if (loadError) {
|
|
258
|
-
throw loadError;
|
|
259
|
-
}
|
|
260
|
-
throw new Error(`Failed to load native binding`);
|
|
261
|
-
}
|
|
262
|
-
const { minify, minifySync, getTargetTriple, initCustomTraceSubscriber } = nativeBinding;
|
|
263
|
-
module.exports.minify = minify;
|
|
264
|
-
module.exports.minifySync = minifySync;
|
|
265
|
-
module.exports.getTargetTriple = getTargetTriple;
|
|
266
|
-
module.exports.initCustomTraceSubscriber = initCustomTraceSubscriber;
|
package/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { JsMinifyOptions } from '@swc/types';
|
|
3
|
-
import * as binding from './binding';
|
|
4
|
-
/**
|
|
5
|
-
* TODO
|
|
6
|
-
*/
|
|
7
|
-
export declare function minify(code: Buffer, options: JsMinifyOptions): Promise<binding.TransformOutput>;
|
|
8
|
-
/**
|
|
9
|
-
* TODO
|
|
10
|
-
*/
|
|
11
|
-
export declare function minifySync(code: Buffer, options: JsMinifyOptions): binding.TransformOutput;
|
package/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.minifySync = exports.minify = void 0;
|
|
27
|
-
const binding = __importStar(require("./binding"));
|
|
28
|
-
/**
|
|
29
|
-
* TODO
|
|
30
|
-
*/
|
|
31
|
-
async function minify(code, options) {
|
|
32
|
-
return await binding.minify(code, toBuffer(options));
|
|
33
|
-
}
|
|
34
|
-
exports.minify = minify;
|
|
35
|
-
/**
|
|
36
|
-
* TODO
|
|
37
|
-
*/
|
|
38
|
-
function minifySync(code, options) {
|
|
39
|
-
return binding.minifySync(code, toBuffer(options));
|
|
40
|
-
}
|
|
41
|
-
exports.minifySync = minifySync;
|
|
42
|
-
function toBuffer(t) {
|
|
43
|
-
return Buffer.from(JSON.stringify(t));
|
|
44
|
-
}
|