You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need/want to import protobuf Message from a npm library.
It mostly works (I build the library to include the 'LibMsg.proto' file alongside the 'LibMsg.ts' and 'LibMsg.js')
protoc requires that I give path to the imported .proto file;
So in MyProto.proto I can do this:
That's works: protoc finds the reference, and protoc-gen-ts emits: import * as dependency_1 from "./../../node_modules/protoPkg/lib/proto/LibProto";
Which might work for running local/nodejs, but it does not survive in webpack
(which expects/requires an import from the reference package)
What we really need is for protoc-gen-ts to emit: import * as dependency_1 from "protoPkg";
Perhaps keyed by noticing that it would otherwise emit: import 'node_modules/_pkgName_/...'
and making the bold assumption that the referenced LibProto is in fact compiled & exported from _pkgName
(it seems already to determine that LibMsg is defined in LibProto)
Seems like a simple/useful heuristic and maybe not so dangerous to require a enable/disable flag?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need/want to import protobuf Message from a npm library.
It mostly works (I build the library to include the 'LibMsg.proto' file alongside the 'LibMsg.ts' and 'LibMsg.js')
protoc requires that I give path to the imported .proto file;
So in MyProto.proto I can do this:
That's works: protoc finds the reference, and protoc-gen-ts emits:
import * as dependency_1 from "./../../node_modules/protoPkg/lib/proto/LibProto";
Which might work for running local/nodejs, but it does not survive in webpack
(which expects/requires an import from the reference package)
What we really need is for protoc-gen-ts to emit:
import * as dependency_1 from "protoPkg";
Perhaps keyed by noticing that it would otherwise emit:
import 'node_modules/_pkgName_/...'
and making the bold assumption that the referenced
LibProto
is in fact compiled & exported from_pkgName
(it seems already to determine that LibMsg is defined in LibProto)
Seems like a simple/useful heuristic and maybe not so dangerous to require a enable/disable flag?
Beta Was this translation helpful? Give feedback.
All reactions