feat(options): adds protoc-gen-go-like M option #672
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds a new feature that aims to provide the same functionality as
M
for the go compiler (https://developers.google.com/protocol-buffers/docs/reference/go-generated#package). I opted for not modifying the type map, because we'll also want to figure out whether or not we need to generate the file, so we'll be accessing theoptions.M
everywhere and I found it less confusing to always get mapping information fromoptions.M
instead ofoptions.M
or the type map depending on the decision that we're making (we need to know if we need to do a relative import or just the raw provided import too).@stephenh there was an alternative approach I considered: change the type registry module to include information about whether or not the module had been remapped, but that seemed to add more complexity than the option I went with. I'm happy to revisit it though, if you think some other approach would be a better fit for the future of the codebase.
Fixes #596