Skip to content

Commit 4a95d5e

Browse files
committed
fix: use uint8array for user's wasm modules used in middleware instead of base64
1 parent 25f6f30 commit 4a95d5e

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

edge-runtime/vendor.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// It acts as a seed that populates the `vendor/` directory and should not be
33
// imported directly.
44

5-
import 'https://deno.land/std@0.175.0/encoding/base64.ts'
65
import 'https://deno.land/std@0.175.0/http/cookie.ts'
76
import 'https://deno.land/std@0.175.0/node/buffer.ts'
87
import 'https://deno.land/std@0.175.0/node/events.ts'

src/build/functions/edge.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,9 @@ const copyHandlerDependencies = async (
126126
const outputFile = join(destDir, `server/${name}.js`)
127127

128128
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}";`)
139129
for (const wasmChunk of wasm ?? []) {
140130
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-
)
131+
parts.push(`const ${wasmChunk.name} = Uint8Array.from(${JSON.stringify([...data])})`)
146132
}
147133
}
148134

0 commit comments

Comments
 (0)