@elench/testkit 0.1.64 → 0.1.65
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/lib/coverage/evidence.mjs +15 -3
- package/lib/coverage/evidence.test.mjs +13 -4
- package/lib/coverage/graph-builder.mjs +23 -24
- package/lib/coverage/next-ir-to-graph.mjs +240 -0
- package/node_modules/@elench/next-analysis/package.json +14 -0
- package/node_modules/@elench/next-analysis/src/api-routes.mjs +81 -0
- package/node_modules/@elench/next-analysis/src/api-routes.test.mjs +22 -0
- package/node_modules/@elench/next-analysis/src/app-root.mjs +7 -0
- package/node_modules/@elench/next-analysis/src/backend-links.mjs +31 -0
- package/node_modules/@elench/next-analysis/src/index.mjs +21 -0
- package/node_modules/@elench/next-analysis/src/pages.mjs +68 -0
- package/node_modules/@elench/next-analysis/src/project.mjs +94 -0
- package/node_modules/@elench/next-analysis/src/project.test.mjs +35 -0
- package/node_modules/@elench/next-analysis/src/route-tree.mjs +621 -0
- package/node_modules/@elench/next-analysis/src/routes.mjs +41 -0
- package/node_modules/@elench/next-analysis/src/routes.test.mjs +25 -0
- package/node_modules/@elench/next-analysis/src/server-actions.mjs +53 -0
- package/node_modules/@elench/next-analysis/src/server-actions.test.mjs +37 -0
- package/node_modules/@elench/next-analysis/src/shared.mjs +209 -0
- package/node_modules/@elench/next-analysis/src/swc.mjs +388 -0
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/node_modules/@next/routing/README.md +91 -0
- package/node_modules/@next/routing/dist/__tests__/captures.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/conditions.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/dynamic-after-rewrites.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/i18n-resolve-routes.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/i18n.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/middleware.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/normalize-next-data.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/redirects.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/resolve-routes.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/__tests__/rewrites.test.d.ts +1 -0
- package/node_modules/@next/routing/dist/destination.d.ts +22 -0
- package/node_modules/@next/routing/dist/i18n.d.ts +48 -0
- package/node_modules/@next/routing/dist/index.d.ts +5 -0
- package/node_modules/@next/routing/dist/index.js +1 -0
- package/node_modules/@next/routing/dist/matchers.d.ts +12 -0
- package/node_modules/@next/routing/dist/middleware.d.ts +12 -0
- package/node_modules/@next/routing/dist/next-data.d.ts +10 -0
- package/node_modules/@next/routing/dist/resolve-routes.d.ts +2 -0
- package/node_modules/@next/routing/dist/types.d.ts +97 -0
- package/node_modules/@next/routing/package.json +39 -0
- package/node_modules/@swc/core/README.md +100 -0
- package/node_modules/@swc/core/Visitor.d.ts +218 -0
- package/node_modules/@swc/core/Visitor.js +1399 -0
- package/node_modules/@swc/core/binding.d.ts +59 -0
- package/node_modules/@swc/core/binding.js +368 -0
- package/node_modules/@swc/core/index.d.ts +120 -0
- package/node_modules/@swc/core/index.js +443 -0
- package/node_modules/@swc/core/package.json +120 -0
- package/node_modules/@swc/core/postinstall.js +148 -0
- package/node_modules/@swc/core/spack.d.ts +51 -0
- package/node_modules/@swc/core/spack.js +87 -0
- package/node_modules/@swc/core/util.d.ts +1 -0
- package/node_modules/@swc/core/util.js +104 -0
- package/node_modules/@swc/core-linux-x64-gnu/README.md +3 -0
- package/node_modules/@swc/core-linux-x64-gnu/package.json +46 -0
- package/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node +0 -0
- package/node_modules/@swc/counter/CHANGELOG.md +7 -0
- package/node_modules/@swc/counter/README.md +7 -0
- package/node_modules/@swc/counter/index.js +1 -0
- package/node_modules/@swc/counter/package.json +27 -0
- package/node_modules/@swc/types/LICENSE +201 -0
- package/node_modules/@swc/types/README.md +4 -0
- package/node_modules/@swc/types/assumptions.d.ts +92 -0
- package/node_modules/@swc/types/assumptions.js +2 -0
- package/node_modules/@swc/types/index.d.ts +2049 -0
- package/node_modules/@swc/types/index.js +2 -0
- package/node_modules/@swc/types/package.json +40 -0
- package/package.json +6 -4
- package/lib/coverage/next-discovery.mjs +0 -205
- package/lib/coverage/next-static-analysis.mjs +0 -1045
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class Compiler {
|
|
5
|
+
constructor()
|
|
6
|
+
}
|
|
7
|
+
export type JsCompiler = Compiler
|
|
8
|
+
|
|
9
|
+
export declare function analyze(src: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
|
|
10
|
+
|
|
11
|
+
export declare function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }>
|
|
12
|
+
|
|
13
|
+
export declare function getTargetTriple(): string
|
|
14
|
+
|
|
15
|
+
export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
|
16
|
+
|
|
17
|
+
export declare function minify(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
18
|
+
|
|
19
|
+
export declare function minifySync(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra): TransformOutput
|
|
20
|
+
|
|
21
|
+
export interface NapiMinifyExtra {
|
|
22
|
+
mangleNameCache?: object
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare function newMangleNameCache(): object
|
|
26
|
+
|
|
27
|
+
export declare function parse(src: Buffer | string, options: Buffer, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<string>
|
|
28
|
+
|
|
29
|
+
export declare function parseFile(path: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
|
|
30
|
+
|
|
31
|
+
export declare function parseFileSync(path: string, opts: Buffer): string
|
|
32
|
+
|
|
33
|
+
export declare function parseSync(src: Buffer | string, opts: Buffer, filename?: string | undefined | null): string
|
|
34
|
+
|
|
35
|
+
export declare function print(programJson: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
36
|
+
|
|
37
|
+
export declare function printSync(program: string, options: Buffer): TransformOutput
|
|
38
|
+
|
|
39
|
+
export declare function transform(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
40
|
+
|
|
41
|
+
export declare function transformFile(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
|
42
|
+
|
|
43
|
+
export declare function transformFileSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
|
|
44
|
+
|
|
45
|
+
export interface TransformOutput {
|
|
46
|
+
code: string
|
|
47
|
+
map?: string
|
|
48
|
+
output?: string
|
|
49
|
+
extractedComments?: Array<string>
|
|
50
|
+
diagnostics: Array<string>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Hack for `Type Generation` */
|
|
54
|
+
export interface TransformOutput {
|
|
55
|
+
code: string
|
|
56
|
+
map?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare function transformSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* auto-generated by NAPI-RS */
|
|
4
|
+
|
|
5
|
+
const { readFileSync } = require('fs')
|
|
6
|
+
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
|
+
|
|
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)) {
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
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('./swc.android-arm64.node')
|
|
64
|
+
} catch (e) {
|
|
65
|
+
loadErrors.push(e)
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return require('@swc/core-android-arm64')
|
|
69
|
+
} catch (e) {
|
|
70
|
+
loadErrors.push(e)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} else if (process.arch === 'arm') {
|
|
74
|
+
try {
|
|
75
|
+
return require('./swc.android-arm-eabi.node')
|
|
76
|
+
} catch (e) {
|
|
77
|
+
loadErrors.push(e)
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
return require('@swc/core-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('./swc.win32-x64-msvc.node')
|
|
92
|
+
} catch (e) {
|
|
93
|
+
loadErrors.push(e)
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return require('@swc/core-win32-x64-msvc')
|
|
97
|
+
} catch (e) {
|
|
98
|
+
loadErrors.push(e)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
} else if (process.arch === 'ia32') {
|
|
102
|
+
try {
|
|
103
|
+
return require('./swc.win32-ia32-msvc.node')
|
|
104
|
+
} catch (e) {
|
|
105
|
+
loadErrors.push(e)
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
return require('@swc/core-win32-ia32-msvc')
|
|
109
|
+
} catch (e) {
|
|
110
|
+
loadErrors.push(e)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} else if (process.arch === 'arm64') {
|
|
114
|
+
try {
|
|
115
|
+
return require('./swc.win32-arm64-msvc.node')
|
|
116
|
+
} catch (e) {
|
|
117
|
+
loadErrors.push(e)
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return require('@swc/core-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('./swc.darwin-universal.node')
|
|
131
|
+
} catch (e) {
|
|
132
|
+
loadErrors.push(e)
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
return require('@swc/core-darwin-universal')
|
|
136
|
+
} catch (e) {
|
|
137
|
+
loadErrors.push(e)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (process.arch === 'x64') {
|
|
141
|
+
try {
|
|
142
|
+
return require('./swc.darwin-x64.node')
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadErrors.push(e)
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
return require('@swc/core-darwin-x64')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadErrors.push(e)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
} else if (process.arch === 'arm64') {
|
|
153
|
+
try {
|
|
154
|
+
return require('./swc.darwin-arm64.node')
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e)
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
return require('@swc/core-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('./swc.freebsd-x64.node')
|
|
171
|
+
} catch (e) {
|
|
172
|
+
loadErrors.push(e)
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
return require('@swc/core-freebsd-x64')
|
|
176
|
+
} catch (e) {
|
|
177
|
+
loadErrors.push(e)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
} else if (process.arch === 'arm64') {
|
|
181
|
+
try {
|
|
182
|
+
return require('./swc.freebsd-arm64.node')
|
|
183
|
+
} catch (e) {
|
|
184
|
+
loadErrors.push(e)
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
return require('@swc/core-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()) {
|
|
198
|
+
try {
|
|
199
|
+
return require('./swc.linux-x64-musl.node')
|
|
200
|
+
} catch (e) {
|
|
201
|
+
loadErrors.push(e)
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return require('@swc/core-linux-x64-musl')
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadErrors.push(e)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
try {
|
|
211
|
+
return require('./swc.linux-x64-gnu.node')
|
|
212
|
+
} catch (e) {
|
|
213
|
+
loadErrors.push(e)
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
return require('@swc/core-linux-x64-gnu')
|
|
217
|
+
} catch (e) {
|
|
218
|
+
loadErrors.push(e)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
} else if (process.arch === 'arm64') {
|
|
223
|
+
if (isMusl()) {
|
|
224
|
+
try {
|
|
225
|
+
return require('./swc.linux-arm64-musl.node')
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
return require('@swc/core-linux-arm64-musl')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
} else {
|
|
236
|
+
try {
|
|
237
|
+
return require('./swc.linux-arm64-gnu.node')
|
|
238
|
+
} catch (e) {
|
|
239
|
+
loadErrors.push(e)
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
return require('@swc/core-linux-arm64-gnu')
|
|
243
|
+
} catch (e) {
|
|
244
|
+
loadErrors.push(e)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
} else if (process.arch === 'arm') {
|
|
249
|
+
try {
|
|
250
|
+
return require('./swc.linux-arm-gnueabihf.node')
|
|
251
|
+
} catch (e) {
|
|
252
|
+
loadErrors.push(e)
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
return require('@swc/core-linux-arm-gnueabihf')
|
|
256
|
+
} catch (e) {
|
|
257
|
+
loadErrors.push(e)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
} else if (process.arch === 'riscv64') {
|
|
261
|
+
if (isMusl()) {
|
|
262
|
+
try {
|
|
263
|
+
return require('./swc.linux-riscv64-musl.node')
|
|
264
|
+
} catch (e) {
|
|
265
|
+
loadErrors.push(e)
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return require('@swc/core-linux-riscv64-musl')
|
|
269
|
+
} catch (e) {
|
|
270
|
+
loadErrors.push(e)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
} else {
|
|
274
|
+
try {
|
|
275
|
+
return require('./swc.linux-riscv64-gnu.node')
|
|
276
|
+
} catch (e) {
|
|
277
|
+
loadErrors.push(e)
|
|
278
|
+
}
|
|
279
|
+
try {
|
|
280
|
+
return require('@swc/core-linux-riscv64-gnu')
|
|
281
|
+
} catch (e) {
|
|
282
|
+
loadErrors.push(e)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
} else if (process.arch === 'ppc64') {
|
|
287
|
+
try {
|
|
288
|
+
return require('./swc.linux-ppc64-gnu.node')
|
|
289
|
+
} catch (e) {
|
|
290
|
+
loadErrors.push(e)
|
|
291
|
+
}
|
|
292
|
+
try {
|
|
293
|
+
return require('@swc/core-linux-ppc64-gnu')
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadErrors.push(e)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
} else if (process.arch === 's390x') {
|
|
299
|
+
try {
|
|
300
|
+
return require('./swc.linux-s390x-gnu.node')
|
|
301
|
+
} catch (e) {
|
|
302
|
+
loadErrors.push(e)
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
return require('@swc/core-linux-s390x-gnu')
|
|
306
|
+
} catch (e) {
|
|
307
|
+
loadErrors.push(e)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
} else {
|
|
311
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
nativeBinding = requireNative()
|
|
319
|
+
|
|
320
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
321
|
+
try {
|
|
322
|
+
nativeBinding = require('./swc.wasi.cjs')
|
|
323
|
+
} catch (err) {
|
|
324
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
325
|
+
console.error(err)
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (!nativeBinding) {
|
|
329
|
+
try {
|
|
330
|
+
nativeBinding = require('@swc/core-wasm32-wasi')
|
|
331
|
+
} catch (err) {
|
|
332
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
333
|
+
console.error(err)
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (!nativeBinding) {
|
|
340
|
+
if (loadErrors.length > 0) {
|
|
341
|
+
// TODO Link to documentation with potential fixes
|
|
342
|
+
// - The package owner could build/publish bindings for this arch
|
|
343
|
+
// - The user may need to bundle the correct files
|
|
344
|
+
// - The user may need to re-install node_modules to get new packages
|
|
345
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
346
|
+
}
|
|
347
|
+
throw new Error(`Failed to load native binding`)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
module.exports.Compiler = nativeBinding.Compiler
|
|
351
|
+
module.exports.JsCompiler = nativeBinding.JsCompiler
|
|
352
|
+
module.exports.analyze = nativeBinding.analyze
|
|
353
|
+
module.exports.bundle = nativeBinding.bundle
|
|
354
|
+
module.exports.getTargetTriple = nativeBinding.getTargetTriple
|
|
355
|
+
module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber
|
|
356
|
+
module.exports.minify = nativeBinding.minify
|
|
357
|
+
module.exports.minifySync = nativeBinding.minifySync
|
|
358
|
+
module.exports.newMangleNameCache = nativeBinding.newMangleNameCache
|
|
359
|
+
module.exports.parse = nativeBinding.parse
|
|
360
|
+
module.exports.parseFile = nativeBinding.parseFile
|
|
361
|
+
module.exports.parseFileSync = nativeBinding.parseFileSync
|
|
362
|
+
module.exports.parseSync = nativeBinding.parseSync
|
|
363
|
+
module.exports.print = nativeBinding.print
|
|
364
|
+
module.exports.printSync = nativeBinding.printSync
|
|
365
|
+
module.exports.transform = nativeBinding.transform
|
|
366
|
+
module.exports.transformFile = nativeBinding.transformFile
|
|
367
|
+
module.exports.transformFileSync = nativeBinding.transformFileSync
|
|
368
|
+
module.exports.transformSync = nativeBinding.transformSync
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Plugin, ParseOptions, Module, Output, Options, Script, Program, JsMinifyOptions, WasmAnalysisOptions } from "@swc/types";
|
|
3
|
+
export type * from "@swc/types";
|
|
4
|
+
export { newMangleNameCache as experimental_newMangleNameCache } from "./binding";
|
|
5
|
+
import { BundleInput } from "./spack";
|
|
6
|
+
import type { NapiMinifyExtra } from "./binding";
|
|
7
|
+
/**
|
|
8
|
+
* Version of the swc binding.
|
|
9
|
+
*/
|
|
10
|
+
export declare const version: string;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
|
|
13
|
+
*/
|
|
14
|
+
export declare function plugins(ps: Plugin[]): Plugin;
|
|
15
|
+
export declare class Compiler {
|
|
16
|
+
private fallbackBindingsPluginWarningDisplayed;
|
|
17
|
+
minify(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Promise<Output>;
|
|
18
|
+
minifySync(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Output;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use Rust instead.
|
|
21
|
+
*/
|
|
22
|
+
parse(src: string, options: ParseOptions & {
|
|
23
|
+
isModule: false;
|
|
24
|
+
}): Promise<Script>;
|
|
25
|
+
parse(src: string, options?: ParseOptions, filename?: string): Promise<Module>;
|
|
26
|
+
parseSync(src: string, options: ParseOptions & {
|
|
27
|
+
isModule: false;
|
|
28
|
+
}): Script;
|
|
29
|
+
parseSync(src: string, options?: ParseOptions, filename?: string): Module;
|
|
30
|
+
parseFile(path: string, options: ParseOptions & {
|
|
31
|
+
isModule: false;
|
|
32
|
+
}): Promise<Script>;
|
|
33
|
+
parseFile(path: string, options?: ParseOptions): Promise<Module>;
|
|
34
|
+
parseFileSync(path: string, options: ParseOptions & {
|
|
35
|
+
isModule: false;
|
|
36
|
+
}): Script;
|
|
37
|
+
parseFileSync(path: string, options?: ParseOptions): Module;
|
|
38
|
+
/**
|
|
39
|
+
* Note: this method should be invoked on the compiler instance used
|
|
40
|
+
* for `parse()` / `parseSync()`.
|
|
41
|
+
*/
|
|
42
|
+
print(m: Program, options?: Options): Promise<Output>;
|
|
43
|
+
/**
|
|
44
|
+
* Note: this method should be invoked on the compiler instance used
|
|
45
|
+
* for `parse()` / `parseSync()`.
|
|
46
|
+
*/
|
|
47
|
+
printSync(m: Program, options?: Options): Output;
|
|
48
|
+
transform(src: string | Program, options?: Options): Promise<Output>;
|
|
49
|
+
transformSync(src: string | Program, options?: Options): Output;
|
|
50
|
+
transformFile(path: string, options?: Options): Promise<Output>;
|
|
51
|
+
transformFileSync(path: string, options?: Options): Output;
|
|
52
|
+
bundle(options?: BundleInput | string): Promise<{
|
|
53
|
+
[name: string]: Output;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
export declare function experimental_analyze(src: string, options?: WasmAnalysisOptions): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use Rust instead.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parse(src: string, options: ParseOptions & {
|
|
61
|
+
isModule: false;
|
|
62
|
+
}): Promise<Script>;
|
|
63
|
+
export declare function parse(src: string, options?: ParseOptions): Promise<Module>;
|
|
64
|
+
export declare function parseSync(src: string, options: ParseOptions & {
|
|
65
|
+
isModule: false;
|
|
66
|
+
}): Script;
|
|
67
|
+
export declare function parseSync(src: string, options?: ParseOptions): Module;
|
|
68
|
+
export declare function parseFile(path: string, options: ParseOptions & {
|
|
69
|
+
isModule: false;
|
|
70
|
+
}): Promise<Script>;
|
|
71
|
+
export declare function parseFile(path: string, options?: ParseOptions): Promise<Module>;
|
|
72
|
+
export declare function parseFileSync(path: string, options: ParseOptions & {
|
|
73
|
+
isModule: false;
|
|
74
|
+
}): Script;
|
|
75
|
+
export declare function parseFileSync(path: string, options?: ParseOptions): Module;
|
|
76
|
+
export declare function print(m: Program, options?: Options): Promise<Output>;
|
|
77
|
+
export declare function printSync(m: Program, options?: Options): Output;
|
|
78
|
+
export declare function transform(src: string | Program, options?: Options): Promise<Output>;
|
|
79
|
+
export declare function transformSync(src: string | Program, options?: Options): Output;
|
|
80
|
+
export declare function transformFile(path: string, options?: Options): Promise<Output>;
|
|
81
|
+
export declare function transformFileSync(path: string, options?: Options): Output;
|
|
82
|
+
export declare function bundle(options?: BundleInput | string): Promise<{
|
|
83
|
+
[name: string]: Output;
|
|
84
|
+
}>;
|
|
85
|
+
export declare function minify(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Promise<Output>;
|
|
86
|
+
export declare function minifySync(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Output;
|
|
87
|
+
/**
|
|
88
|
+
* Configure custom trace configuration runs for a process lifecycle.
|
|
89
|
+
* Currently only chromium's trace event format is supported.
|
|
90
|
+
* (https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview)
|
|
91
|
+
*
|
|
92
|
+
* This should be called before calling any binding interfaces exported in `@swc/core`, such as
|
|
93
|
+
* `transform*`, or `parse*` or anything. To avoid breaking changes, each binding fn internally
|
|
94
|
+
* sets default trace subscriber if not set.
|
|
95
|
+
*
|
|
96
|
+
* Unlike other configuration, this does not belong to individual api surface using swcrc
|
|
97
|
+
* or api's parameters (`transform(..., {trace})`). This is due to current tracing subscriber
|
|
98
|
+
* can be configured only once for the global scope. Calling `registerGlobalTraceConfig` multiple
|
|
99
|
+
* time won't cause error, subsequent calls will be ignored.
|
|
100
|
+
*
|
|
101
|
+
* As name implies currently this is experimental interface may change over time without semver
|
|
102
|
+
* major breaking changes. Please provide feedbacks,
|
|
103
|
+
* or bug report at https://github.com/swc-project/swc/discussions.
|
|
104
|
+
*/
|
|
105
|
+
export declare function __experimental_registerGlobalTraceConfig(traceConfig: {
|
|
106
|
+
type: "traceEvent";
|
|
107
|
+
fileName?: string;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* @ignore
|
|
111
|
+
*
|
|
112
|
+
* Returns current binary's metadata to determine which binary is actually loaded.
|
|
113
|
+
*
|
|
114
|
+
* This is undocumented interface, does not guarantee stability across `@swc/core`'s semver
|
|
115
|
+
* as internal representation may change anytime. Use it with caution.
|
|
116
|
+
*/
|
|
117
|
+
export declare function getBinaryMetadata(): {
|
|
118
|
+
target: string | undefined;
|
|
119
|
+
};
|
|
120
|
+
export declare const DEFAULT_EXTENSIONS: readonly string[];
|