Skip to content

Commit

Permalink
fix: handling of gh deps in noir_wasm (#4499)
Browse files Browse the repository at this point in the history
# Description

Github deps are directly added to the file manager, which causes them to
be missing the absolute path to the source file and only include the
extraction directory relative to the fm root directory. This caused the
path to the file to be formatted in an unexpected way and the compiler
to panic.

Resolves: #4355

Check one:
- [x] 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.
  • Loading branch information
Thunkar committed Mar 7, 2024
1 parent 33c1ef7 commit 1d65370
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/wasm/src/noir/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ export class Package {
handles
.filter((handle) => SOURCE_EXTENSIONS.find((ext) => handle.endsWith(ext)))
.map(async (file) => {
const suffix = file.replace(this.#srcPath, '');
// Github deps are directly added to the file manager, which causes them to be missing the absolute path to the source file
// and only include the extraction directory relative to the fm root directory
// This regexp ensures we remove the "real" source path for all dependencies, providing the compiler with what it expects for each source file:
// <absoluteSourcePath> -> <sourceAsString> for bin/contract packages
// <depAlias/relativePathToSource> -> <sourceAsString> for libs
const suffix = file.replace(new RegExp(`.*${this.#srcPath}`), '');
return {
path: this.getType() === 'lib' ? `${alias ? alias : this.#config.package.name}${suffix}` : file,
source: (await fm.readFile(file, 'utf-8')).toString(),
Expand Down

0 comments on commit 1d65370

Please sign in to comment.