1- import { freemem } from " node:os" ;
1+ import { freemem } from ' node:os' ;
22import wizer from '@bytecodealliance/wizer' ;
33import getWeval from '@bytecodealliance/weval' ;
44import {
@@ -34,16 +34,20 @@ function maybeWindowsPath(path) {
3434 * found as line prefixes.
3535 */
3636function stripLinesPrefixes ( input , prefixPatterns ) {
37- return input . split ( '\n' )
38- . map ( line => prefixPatterns . reduce ( ( line , n ) => line . replace ( n , '' ) , line ) )
39- . join ( '\n' ) . trim ( ) ;
37+ return input
38+ . split ( '\n' )
39+ . map ( ( line ) =>
40+ prefixPatterns . reduce ( ( line , n ) => line . replace ( n , '' ) , line ) ,
41+ )
42+ . join ( '\n' )
43+ . trim ( ) ;
4044}
4145
4246const WizerErrorCause = `Error: the \`componentize.wizer\` function trapped
4347
4448Caused by:` ;
4549
46- const WizerExitCode = " Exited with i32 exit status" ;
50+ const WizerExitCode = ' Exited with i32 exit status' ;
4751
4852function parseWizerStderr ( stderr ) {
4953 let output = `${ stderr } ` ;
@@ -75,9 +79,11 @@ function isNumeric(n) {
7579 }
7680}
7781
78- export async function componentize ( opts ,
79- _deprecatedWitWorldOrOpts = undefined ,
80- _deprecatedOpts = undefined ) {
82+ export async function componentize (
83+ opts ,
84+ _deprecatedWitWorldOrOpts = undefined ,
85+ _deprecatedOpts = undefined ,
86+ ) {
8187 let useOriginalSourceFile = true ;
8288 let jsSource ;
8389
@@ -93,7 +99,7 @@ export async function componentize(opts,
9399 } else {
94100 if ( typeof _deprecatedWitWorldOrOpts !== 'object' ) {
95101 throw new Error (
96- `componentize: second argument must be an object or a string, but is ${ typeof _deprecatedWitWorldOrOpts } `
102+ `componentize: second argument must be an object or a string, but is ${ typeof _deprecatedWitWorldOrOpts } ` ,
97103 ) ;
98104 }
99105 opts = _deprecatedWitWorldOrOpts ;
@@ -105,7 +111,7 @@ export async function componentize(opts,
105111 createHash ( 'sha256' )
106112 . update ( Math . random ( ) . toString ( ) )
107113 . digest ( 'hex' )
108- . slice ( 0 , 12 )
114+ . slice ( 0 , 12 ) ,
109115 ) ;
110116 await mkdir ( tmpDir ) ;
111117 const sourceDir = join ( tmpDir , 'sources' ) ;
@@ -145,22 +151,22 @@ export async function componentize(opts,
145151 witWorld ,
146152 maybeWindowsPath ( witPath ) ,
147153 worldName ,
148- false
154+ false ,
149155 ) ;
150156
151157 const input = join ( tmpDir , 'in.wasm' ) ;
152158 const output = join ( tmpDir , 'out.wasm' ) ;
153159
154160 await writeFile ( input , Buffer . from ( wasm ) ) ;
155- await writeFile ( join ( sourceDir , " initializer.js" ) , jsBindings ) ;
161+ await writeFile ( join ( sourceDir , ' initializer.js' ) , jsBindings ) ;
156162
157163 if ( debugBindings ) {
158164 console . log ( '--- JS Bindings ---' ) ;
159165 console . log (
160166 jsBindings
161167 . split ( '\n' )
162168 . map ( ( ln , idx ) => `${ ( idx + 1 ) . toString ( ) . padStart ( 4 , ' ' ) } | ${ ln } ` )
163- . join ( '\n' )
169+ . join ( '\n' ) ,
164170 ) ;
165171 console . log ( '--- JS Imports ---' ) ;
166172 console . log ( imports ) ;
@@ -287,12 +293,12 @@ export async function componentize(opts,
287293 `-o ${ output } ` ,
288294 ] ,
289295 {
290- stdio : [ null , stdout , " pipe" ] ,
296+ stdio : [ null , stdout , ' pipe' ] ,
291297 env,
292298 input : runtimeArgs ,
293299 shell : true ,
294300 encoding : 'utf-8' ,
295- }
301+ } ,
296302 ) ;
297303 } else {
298304 wizerProcess = spawnSync (
@@ -308,12 +314,12 @@ export async function componentize(opts,
308314 input ,
309315 ] ,
310316 {
311- stdio : [ null , stdout , " pipe" ] ,
317+ stdio : [ null , stdout , ' pipe' ] ,
312318 env,
313319 input : runtimeArgs ,
314320 shell : true ,
315321 encoding : 'utf-8' ,
316- }
322+ } ,
317323 ) ;
318324 }
319325
@@ -448,7 +454,7 @@ export async function componentize(opts,
448454
449455 // convert CABI import conventions to ESM import conventions
450456 imports = imports . map ( ( [ specifier , impt ] ) =>
451- specifier === '$root' ? [ impt , 'default' ] : [ specifier , impt ]
457+ specifier === '$root' ? [ impt , 'default' ] : [ specifier , impt ] ,
452458 ) ;
453459
454460 return {
0 commit comments