1
1
import { 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'
4
3
5
4
import type { Manifest , ManifestFunction } from '@netlify/edge-functions'
6
5
import { glob } from 'fast-glob'
@@ -9,8 +8,6 @@ import { pathToRegexp } from 'path-to-regexp'
9
8
10
9
import { EDGE_HANDLER_NAME , PluginContext } from '../plugin-context.js'
11
10
12
- const toPosixPath = ( path : string ) => path . split ( sep ) . join ( posixSep )
13
-
14
11
const writeEdgeManifest = async ( ctx : PluginContext , manifest : Manifest ) => {
15
12
await mkdir ( ctx . edgeFunctionsDir , { recursive : true } )
16
13
await writeFile ( join ( ctx . edgeFunctionsDir , 'manifest.json' ) , JSON . stringify ( manifest , null , 2 ) )
@@ -126,23 +123,9 @@ const copyHandlerDependencies = async (
126
123
const outputFile = join ( destDir , `server/${ name } .js` )
127
124
128
125
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 } ";` )
139
126
for ( const wasmChunk of wasm ?? [ ] ) {
140
127
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 ] ) } )` )
146
129
}
147
130
}
148
131
0 commit comments