4cd8b23032
Follow-up to the earlier enabling of classes/variables etc. Bug Related issues linked using fixes #number Integration tests added Errors have helpful link attached, see contributing.md Feature Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. Related issues linked using fixes #number Integration tests added Documentation added Telemetry added. In case of a feature if it's used or not. Errors have helpful link attached, see contributing.md Documentation / Examples Make sure the linting passes by running pnpm lint The examples guidelines are followed from our contributing doc Co-authored-by: Steven <steven@ceriously.com>
17 lines
600 B
TypeScript
17 lines
600 B
TypeScript
import { getModuleBuildInfo } from './get-module-build-info'
|
|
import crypto from 'crypto'
|
|
|
|
function sha1(source: string | Buffer) {
|
|
return crypto.createHash('sha1').update(source).digest('hex')
|
|
}
|
|
|
|
export default function MiddlewareWasmLoader(this: any, source: Buffer) {
|
|
const name = `wasm_${sha1(source)}`
|
|
const filePath = `edge-chunks/${name}.wasm`
|
|
const buildInfo = getModuleBuildInfo(this._module)
|
|
buildInfo.nextWasmMiddlewareBinding = { filePath: `server/${filePath}`, name }
|
|
this.emitFile(`/${filePath}`, source, null)
|
|
return `module.exports = ${name};`
|
|
}
|
|
|
|
export const raw = true
|