diff --git a/package-lock.json b/package-lock.json index 563a884..2514c73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "emp-wasm", - "version": "0.2.2", + "version": "0.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "emp-wasm", - "version": "0.2.2", + "version": "0.2.3", "license": "MIT", "dependencies": { "ee-typed": "^0.1.1", diff --git a/package.json b/package.json index e13f925..467466f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "emp-wasm", - "version": "0.2.2", + "version": "0.2.3", "description": "Wasm build of authenticated garbling from [emp-toolkit/emp-ag2pc](https://github.com/emp-toolkit/emp-ag2pc).", "type": "module", "main": "dist/src/ts/index.js", diff --git a/scripts/build.ts b/scripts/build.ts index fafed23..99b0ed4 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -111,6 +111,8 @@ async function fixEmscriptenCode(gitRoot: string) { const path = join(gitRoot, 'dist/build/jslib.js'); let content = await fs.readFile(path, 'utf-8'); + content = `function echo(x) { return x; }\n${content}`; + content = replace( content, ['function intArrayFromBase64(s) { if (typeof ENVIRONMENT_IS_NODE'], @@ -134,14 +136,17 @@ async function fixEmscriptenCode(gitRoot: string) { // This doesn't really affect behavior, but it fixes a nextjs issue where // it analyzes the require statically and fails even when the code works as // a whole. + // FIXME: I can no longer reproduce nextjs failing without this replacement. + // It's easier to just leave it in for now but in future this should help + // motivate its removal if nextjs still doesn't seem to need it anymore. 'var fs=(()=>{try{return require("fs")}catch(e){throw e}})();' ); - // For deno compatibility + // For deno and nextjs compatibility content = replace( content, ['import("module")', "import('module')"], - 'import("node:module")', + 'import(echo("node:module"))', ); await fs.writeFile(path, content);