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

How to control the location of IDL and types. #3533

Open
spacecaterpillar opened this issue Feb 3, 2025 · 0 comments
Open

How to control the location of IDL and types. #3533

spacecaterpillar opened this issue Feb 3, 2025 · 0 comments

Comments

@spacecaterpillar
Copy link

spacecaterpillar commented Feb 3, 2025

The documentation says:

workspace
types
Adds a directory where you want the .ts file to be copied when running anchor build. This is helpful when you want to keep this file in version control, like when using it on the frontend, which will probably not have access to the target directory generated by anchor.

Example:

[workspace]
types = "app/src/idl/"

But this is confusing. The auto-generated files include both IDL json (by default in target/idl) and typescript/js (by default in target/types). How can I control the location of both of these? The documentation confusingly suggests that "types" will control the "typescript" file and then proceeds to set the value of that parameter to a directory that mentions "idl", which is a strictly different kind of autogenerated output.

This is super basic stuff. Can we get some clarity and it fixed?

I want to be able to control where "target/idl/.json" file is generated, and also where the "target/types/.ts" file is generated.

Even more, since I have various compile time constants that depend on my environmet (production, staging, development), I would actually like to set the value of these customized locations so that they depend on the value of a config in a dotenv file. Is that possible? If not, is there a way to do a post-script for "anchor build"? Then, I could keep the files generated to the standard location (which will not be verision-controlled), and then I'd copy it into a dotenv-specific directory after running "anchor build". I do not want to run a separate command, as people will forgot to do that.

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

No branches or pull requests

1 participant