From efb78d1828ff805395e03ffbb9a22cde42e892ce Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Sun, 27 Feb 2022 15:09:31 +0200 Subject: [PATCH] Use any for the loader type --- .../webpack/loaders/next-middleware-wasm-loader.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-middleware-wasm-loader.ts b/packages/next/build/webpack/loaders/next-middleware-wasm-loader.ts index b01f80ce97e0..c57095f56341 100644 --- a/packages/next/build/webpack/loaders/next-middleware-wasm-loader.ts +++ b/packages/next/build/webpack/loaders/next-middleware-wasm-loader.ts @@ -1,4 +1,3 @@ -import type { webpack } from 'next/dist/compiled/webpack/webpack' import crypto from 'crypto' export type WasmBinding = { @@ -6,22 +5,17 @@ export type WasmBinding = { name: string } -const MiddlewareWasmLoader: webpack.loader.Loader = function ( - source, - _sourceMap -) { +export default function MiddlewareWasmLoader(this: any, source: Buffer) { const name = `wasm_${sha1(source)}` const filePath = `server/middleware-chunks/${name}.wasm` const binding: WasmBinding = { filePath, name } this._module.buildInfo.nextWasmMiddlewareBinding = binding this.emitFile(`/${filePath}`, source, null) - return `module.exports = globalThis[${JSON.stringify(name)}];` + return `module.exports = name;` } export const raw = true -export default MiddlewareWasmLoader - function sha1(source: string | Buffer) { return crypto.createHash('sha1').update(source).digest('hex') }