-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: add support for absolute imports #1971
Comments
With const {load} = require('protobufjs');
load(
[
`${__dirname}/org/common/common.proto`,
`${__dirname}/org/test/test.proto`
],
(err, root) => {
if (err) {
console.error(err);
}
console.log(root);
}) As a result of #1960 now we get the error |
david-luna
pushed a commit
to elastic/elastic-otel-node
that referenced
this issue
Feb 9, 2024
….proto` files (#66) Contains a temporary workaround for protobufjs/protobuf.js#1971. Loading a file with non relative imports fail.
Having the same issue. it's almost impossible to load complex protos due to it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
protobuf.js version: 7.2.6
The load method forces to use relative import for other `.proto` files where the spec doesn't explicitly say this.Create a project with the following proto files
and try to load
test.proto
in nodethe load process tries to load
common.proto
resolving the import from the current location oftest.proto
file giving the following errornot the import path being appended to the path of the current file being processed
Making the import relative
import "../common/common.proto"
makes the error go away but I'm not sure that this is the behavior documented in https://protobuf.dev/programming-guides/proto3/#importing. I've checkedload
&loadSync
but I've could not find a config to set a root path for imports.I guess what is expected is to have a way to define a root path from where to resolve imports. https://github.com/open-telemetry/opentelemetry-proto seems to assume this.
The text was updated successfully, but these errors were encountered: