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

Support import_prefix and strip_import_prefix attrs in jsonnet_library #155

Open
dr-dime opened this issue Mar 10, 2022 · 2 comments
Open

Comments

@dr-dime
Copy link

dr-dime commented Mar 10, 2022

In light of #139 and #154, I think we should add import_prefix and strip_import_prefix attrs to jsonnet_library to bring virtual includes paths to jsonnet.

proto_library and cc_library had exact same issues in the past, and prefix magic solved the problem. I believe we can do the same for jsonnet.

Speaking of this, I think we also need to improve imports a little bit to make it similar to cc_library in some sense.

@0xd3e
Copy link

0xd3e commented Nov 16, 2022

@dr-dime Can you please explain you suggestion a bit more? I could try to implement it.

I'm not that experienced in writing rules, but I'd give it a try.
Maybe you could provide an example like how one would pull external dependencies and manipulate the import path.

@EdSchouten
Copy link
Collaborator

The downside of something like import_prefix is that it requires us to do a whole bunch of symlink trickery. It's not as if the Jsonnet utility implementations have extensive path remapping capabilities, meaning we need to prepare the file system to have the layout that Jsonnet expects.

With regards to strip_import_prefix, I don't think there is an actual need for that. This can already be achieved by using imports, as you've noted.

With regards to #139 and #154, these issues have now been fixed. rules_jsonnet now does the sensible thing where the workspace root path is properly prepended to import paths. This means that if jsonnet_to_json() works in a given workspace, it should also work if that same workspace is used as an external module in another project.

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

3 participants