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

WIP bundled noir_wasm + source resolver #3781

Closed
wants to merge 4 commits into from
Closed

Conversation

signorecello
Copy link
Contributor

This is a WIP on bundling and supporting multi target for noir_wasm, obviously don’t merge

@TomAFrench
Copy link
Member

I think you're aware already but we're making big changes to the wasm compiler atm so we should hold off on this for a bit.

@signorecello
Copy link
Contributor Author

Yes I'm part of that discussion actually, this PR is mostly to provide some context for @Thunkar

@TomAFrench TomAFrench closed this Jan 8, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 11, 2024
…ger` for consistency with native interface (#3891)

# Description

Merging the work done here:

AztecProtocol/aztec-packages#3696
#3781
#3760

Plus some extras to make the API nicer.

## Problem

Closes(?) #3695

## Summary

Makes noir_wasm easier to work with, including dependency resolution and
bundling. This package can be used from both node and the browser with
identical API leveraging a virtual filesystem.

Uses webpack for bundling, which is done in two steps: 

1) rust -> wasm (cjs/esm)
2) TS + wasm (cjs/esm) -> universal package for web

Tests have been migrated to mocha and playwright.

## Additional Context

~~I really want to test it
[here](https://github.com/signorecello/noir-playground) before merging,
but it's in a state in which it can be reviewed before we commit to an
API.~~
Done: signorecello/noir-playground#32

Even though the initial memFS-backed FileManager developed by @alexghr
is still here, it is not used for the web version due to import
problems. The way it works now, webpack uses `memfs` directly it to
alias the node `fs` module (which seems to be its intended use case) and
allows us to use the nodejs `fs` API everywhere.

## Documentation

Documentation is required for usage, but should basically be:

```typescript

// Node.js

import { compile, createFileManager } from '@noir-lang/noir_wasm'; // Rename!!

const fm = createFileManager(myProjectPath);
const myCompiledCode = await compile(fm);
```

```typescript

// Browser

import { compile, createFileManager } from '@noir-lang/noir_wasm'; // Rename!!

const fm = createFileManager('/');
for (const path of files) {
  await fm.writeFile(path, await getFileAsStream(path));
}
const myCompiledCode = await compile(fm);
```

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: sirasistant <[email protected]>
Co-authored-by: Tom French <[email protected]>
Co-authored-by: Tom French <[email protected]>
@TomAFrench TomAFrench deleted the zpedro/noir_wasm branch November 20, 2024 12:02
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