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

Kh/npm corrections #7

Open
wants to merge 10 commits into
base: kw/noir-dsl
Choose a base branch
from

Conversation

kobyhallx
Copy link

As a developer
I would like to use @noir-lang/* packages in browser and nodejs
so that I don't have to maintain separate code bases.

Changes supporting this case:

  • barretenberg.js/exports/index.mjs index file supporting ESM style of usage, eg. import ... from ...

  • barretenberg.js/package.json

    • adds yarn package script to emit both ESM and CommonJS package versions into their own directories (dest commonjs folder kept for compatibility with previous code)
    • specifies exports and main files according to import/require style
    • adds browser main file
    • barretenberg.js/src/crypto/random/index.ts checks for self first as otherwise window check fails when running in WebWorker, adds an error to make debugging problems a bit easier
  • barretenberg.js/src/index.ts adds index with exports for compatibility

  • barretenberg.js/src/iso_fetch/index.ts again using self first to avoid execution problems in WebWorker

  • barretenberg.js/src/wasm/barretenberg.wasm pre-built wasm binary

  • barretenberg.js/src/wasm/barretenberg_wasm.ts relies on import.meta for loading wasm in browser environment, patches this when building for CommonJS

  • barretenberg.js/src/wasm/index.ts relies on import.meta for loading wasm in browser environment, patches this when building for CommonJS

  • barretenberg.js/src/wasm/worker_factory.ts relies on import.meta for loading wasm in browser environment, patches this when building for CommonJS, branches differently for node and browser as ThreadJS does not support this way of handling workers (attempts to fix path).

phated pushed a commit that referenced this pull request Feb 3, 2023
fix(wrapper): Set up CC & CXX in cargo build file
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.

1 participant