Wasm working again for node
needs testing in browser
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { WasmFs } from '@wasmer/wasmfs';
|
||||
import path from "path";
|
||||
|
||||
let webWasmLocation = "/wasm/";
|
||||
let nodeWasmLocation = "./public/wasm/";
|
||||
let nodeWasmLocation = "../shared-operations/src/wasm/pdfcpu/";
|
||||
|
||||
let fs;
|
||||
const wasmfs = new WasmFs();
|
||||
@@ -22,7 +21,7 @@ async function configureFs() {
|
||||
}
|
||||
|
||||
async function loadWasm() {
|
||||
global.crypto = (await import("crypto")).webcrypto; // wasm dependecy
|
||||
// global.crypto = (await import("crypto")).webcrypto; // wasm dependecy
|
||||
await import("./wasm_exec.js");
|
||||
}
|
||||
|
||||
|
||||
@@ -201,14 +201,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (!global.crypto && global.require) {
|
||||
const nodeCrypto = require("crypto");
|
||||
global.crypto = {
|
||||
getRandomValues(b) {
|
||||
nodeCrypto.randomFillSync(b);
|
||||
},
|
||||
};
|
||||
}
|
||||
// if (!global.crypto && global.require) {
|
||||
// const nodeCrypto = require("crypto");
|
||||
// global.crypto = {
|
||||
// getRandomValues(b) {
|
||||
// nodeCrypto.randomFillSync(b);
|
||||
// },
|
||||
// };
|
||||
// }
|
||||
if (!global.crypto) {
|
||||
throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user