Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

compile should accept either file path or prebuilt sources object #15

Closed
d1ll0n opened this issue May 28, 2022 · 2 comments
Closed

compile should accept either file path or prebuilt sources object #15

d1ll0n opened this issue May 28, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@d1ll0n
Copy link
Contributor

d1ll0n commented May 28, 2022

The compile function takes a HuffCompilerArgs type as input.

type HuffCompilerArgs = {
  filePath: string;
  generateAbi: boolean;
  constructorArgs?: { type: string; value: string }[];
}

The filePath value is then passed to parseFile which passes it to getAllFileContents. getAllFileContents then reads the main file and all its imports and builds an object with the file contents of the main file and all its imports.

We should replace this with a more common pattern for compiler packages, where you can either provide an input file path or a prebuilt sources object containing all the file contents. This will make it possible to use huffc in environments without access to the filesystem, such as browsers.

@d1ll0n d1ll0n added enhancement New feature or request good first issue Good for newcomers labels May 28, 2022
@d1ll0n d1ll0n changed the title compile should accept either directory information or prebuilt sources object compile should accept either file path or prebuilt sources object May 28, 2022
@d1ll0n
Copy link
Contributor Author

d1ll0n commented May 29, 2022

I had previously made a PR to the Aztec Protocol repository to enable this kind of behavior

AztecProtocol/huff#5

There is some related discussion on that PR.

@d1ll0n
Copy link
Contributor Author

d1ll0n commented May 29, 2022

Resolved in #16

@d1ll0n d1ll0n closed this as completed May 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant