11import { cp , mkdir , readFile , rm , writeFile } from 'node:fs/promises'
2- import { dirname , join , relative , sep } from 'node:path'
3- import { sep as posixSep } from 'node:path/posix'
2+ import { dirname , join } from 'node:path'
43
54import type { Manifest , ManifestFunction } from '@netlify/edge-functions'
65import { glob } from 'fast-glob'
@@ -9,8 +8,6 @@ import { pathToRegexp } from 'path-to-regexp'
98
109import { EDGE_HANDLER_NAME , PluginContext } from '../plugin-context.js'
1110
12- const toPosixPath = ( path : string ) => path . split ( sep ) . join ( posixSep )
13-
1411const writeEdgeManifest = async ( ctx : PluginContext , manifest : Manifest ) => {
1512 await mkdir ( ctx . edgeFunctionsDir , { recursive : true } )
1613 await writeFile ( join ( ctx . edgeFunctionsDir , 'manifest.json' ) , JSON . stringify ( manifest , null , 2 ) )
@@ -126,23 +123,9 @@ const copyHandlerDependencies = async (
126123 const outputFile = join ( destDir , `server/${ name } .js` )
127124
128125 if ( wasm ?. length ) {
129- const base64ModulePath = join (
130- destDir ,
131- 'edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts' ,
132- )
133-
134- const base64ModulePathRelativeToOutputFile = toPosixPath (
135- relative ( dirname ( outputFile ) , base64ModulePath ) ,
136- )
137-
138- parts . push ( `import { decode as _base64Decode } from "${ base64ModulePathRelativeToOutputFile } ";` )
139126 for ( const wasmChunk of wasm ?? [ ] ) {
140127 const data = await readFile ( join ( srcDir , wasmChunk . filePath ) )
141- parts . push (
142- `const ${ wasmChunk . name } = _base64Decode(${ JSON . stringify (
143- data . toString ( 'base64' ) ,
144- ) } ).buffer`,
145- )
128+ parts . push ( `const ${ wasmChunk . name } = Uint8Array.from(${ JSON . stringify ( [ ...data ] ) } )` )
146129 }
147130 }
148131
0 commit comments