Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building SSR with vite fails due to fs/promises #6073

Closed
Tracked by #8881
olehmisar opened this issue Apr 28, 2024 · 7 comments
Closed
Tracked by #8881

building SSR with vite fails due to fs/promises #6073

olehmisar opened this issue Apr 28, 2024 · 7 comments
Labels
S-blocked Status: Blocked

Comments

@olehmisar
Copy link
Contributor

olehmisar commented Apr 28, 2024

I am using sveltekit and vite to build my app. Running vite build fails with this error:

vite v5.1.4 building SSR bundle for production...
✓ 955 modules transformed.
x Build failed in 9.35s
error during build:
Error: [vite:load-fallback] Could not load /node_modules/.pnpm/node-stdlib-browser@1.2.0/node_modules/node-stdlib-browser/esm/mock/empty.js/promises (imported by ../../node_modules/.pnpm/@aztec+bb.js@0.34.0/node_modules/@aztec/bb.js/dest/node/crs/node/index.js

Looks like node-stdlib-browser does NOT support fs/promises. Not sure why vite wants to use node-stdlib-browser for an SSR build but it is what it is.

I can provide a repro if this issue is going to be fixed.

@olehmisar
Copy link
Contributor Author

node-stdlib-browser is a dependency of vite-plugin-node-polyfills, which is required for aztec to work with vite

@rahul-kothari
Copy link
Contributor

unforrutnately this is blocked for a bit. Started because we need it for creating proofs, we still need a WASM endpoint for aztec/client IVC

Will tackle 5050 and some of the others though!

@saleel
Copy link
Member

saleel commented Oct 4, 2024

Below vite.config fixes the issue for me. Had to explicitly include fs/promises in nodePolyfills for some reason

import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";

export default defineConfig({
  plugins: [nodePolyfills({ include: ["fs/promises"] }), topLevelAwait()],
});

@rahul-kothari
Copy link
Contributor

@saleel could you and @critesjosh work together to ensure this is reflected in our docs? thanks!

@olehmisar
Copy link
Contributor Author

looks like this was fixed at some point.

@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Dec 10, 2024
@olehmisar
Copy link
Contributor Author

olehmisar commented Dec 14, 2024

not fixed. Failing with this error as of 0.67.0

x Build failed in 7.21s
error during build:
[vite-plugin-sveltekit-compile] ../../node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js (3:9): "promises" is not exported by "__vite-browser-external", imported by "../../node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js".
file: /Users/user/repo/node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js:3:9

1: import { bufferSchemaFor } from '@aztec/foundation/schemas';
2: import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3: import { promises as fs } from 'fs';
            ^
4: import path from 'path';
5: /**

file: /Users/user/repo/node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js:3:9

1: import { bufferSchemaFor } from '@aztec/foundation/schemas';
2: import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3: import { promises as fs } from 'fs';
            ^
4: import path from 'path';
5: /**

../../node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js (3:9): "promises" is not exported by "__vite-browser-external", imported by "../../node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js".
file: /Users/user/repo/node_modules/.pnpm/@aztec+circuits.js@0.67.0_typescript@5.5.4/node_modules/@aztec/circuits.js/dest/structs/client_ivc_proof.js:3:9

1: import { bufferSchemaFor } from '@aztec/foundation/schemas';
2: import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3: import { promises as fs } from 'fs';
            ^
4: import path from 'path';
5: /**

    at getRollupError (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
    at error (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
    at Module.error (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:13971:16)
    at Module.traceVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:14419:29)
    at ModuleScope.findVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:12121:39)
    at ChildScope.findVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at ClassBodyScope.findVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at ChildScope.findVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at FunctionScope.findVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at FunctionBodyScope.findVariable (file:///Users/user/repo/node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)

@olehmisar
Copy link
Contributor Author

it was fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants