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

Fix fastfile build errors #3

Merged
merged 2 commits into from
Jun 28, 2024
Merged

Fix fastfile build errors #3

merged 2 commits into from
Jun 28, 2024

Conversation

veronicaz41
Copy link
Collaborator

@veronicaz41 veronicaz41 commented Jun 28, 2024

"@pcd/gpc" has dependency "@pcd/gpcircuits" which in turn depends on fastfile.

"fastfile" uses node modules "fs", "constants" and global "process" (process.browser).
We need to polyfill these in order for it to work in browser.

Otherwise, here is the build error I'm getting when running "yarn build"

../../node_modules/fastfile/src/fastfile.js
Can't import the named export 'O_CREAT' (imported as 'O_CREAT') from default-exporting module (only default export is available)

Import trace for requested module:
../../node_modules/fastfile/src/fastfile.js
../../node_modules/@pcd/gpcircuits/dist/esm/src/artifacts.js
../../node_modules/@pcd/gpcircuits/dist/esm/src/index.js
../../node_modules/@pcd/gpc/dist/esm/src/gpc.js
../../node_modules/@pcd/gpc/dist/esm/src/index.js
./app/util/generateProof.ts
./app/prover/page.tsx

This PR (see next.config.js) shows how to fix it in Next.js (uses webpack 5).


snark.js uses rollup, and here is how it does the polyfill.


zupass repo uses esbuild, and it uses the the plugin from "@esbuild-plugins/node-modules-polyfill" to do the polyfill.

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
zukyc-gpc-prover-client ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 1:35am
zukyc-gpc-verifier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 1:35am
zukyc-issuer-client ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 1:35am
zukyc-issuer-server ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 1:35am

module.exports = {
transpilePackages: ["@repo/ui"],
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false
};
config.resolve.alias = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document what this is required for? Maybe a comment here would be a good place to document the underlying issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments

@veronicaz41
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants