mirror of
https://github.com/privacy-scaling-explorations/emp-wasm.git
synced 2026-01-09 18:17:55 -05:00
fix nextjs by preventing static analysis of import
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "emp-wasm",
|
"name": "emp-wasm",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "emp-wasm",
|
"name": "emp-wasm",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ee-typed": "^0.1.1",
|
"ee-typed": "^0.1.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "emp-wasm",
|
"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).",
|
"description": "Wasm build of authenticated garbling from [emp-toolkit/emp-ag2pc](https://github.com/emp-toolkit/emp-ag2pc).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/src/ts/index.js",
|
"main": "dist/src/ts/index.js",
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ async function fixEmscriptenCode(gitRoot: string) {
|
|||||||
const path = join(gitRoot, 'dist/build/jslib.js');
|
const path = join(gitRoot, 'dist/build/jslib.js');
|
||||||
let content = await fs.readFile(path, 'utf-8');
|
let content = await fs.readFile(path, 'utf-8');
|
||||||
|
|
||||||
|
content = `function echo(x) { return x; }\n${content}`;
|
||||||
|
|
||||||
content = replace(
|
content = replace(
|
||||||
content,
|
content,
|
||||||
['function intArrayFromBase64(s) { if (typeof ENVIRONMENT_IS_NODE'],
|
['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
|
// 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
|
// it analyzes the require statically and fails even when the code works as
|
||||||
// a whole.
|
// 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}})();'
|
'var fs=(()=>{try{return require("fs")}catch(e){throw e}})();'
|
||||||
);
|
);
|
||||||
|
|
||||||
// For deno compatibility
|
// For deno and nextjs compatibility
|
||||||
content = replace(
|
content = replace(
|
||||||
content,
|
content,
|
||||||
['import("module")', "import('module')"],
|
['import("module")', "import('module')"],
|
||||||
'import("node:module")',
|
'import(echo("node:module"))',
|
||||||
);
|
);
|
||||||
|
|
||||||
await fs.writeFile(path, content);
|
await fs.writeFile(path, content);
|
||||||
|
|||||||
Reference in New Issue
Block a user