From a0f490370c49106cb68b704a3dd12ea6d0de83d8 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 16 Jun 2016 11:59:08 -0700 Subject: JS: import well-known types from google-protobuf package. --- src/google/protobuf/compiler/js/js_generator.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/google') diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 3de61e80..5d1ba598 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -160,6 +160,14 @@ string GetJSFilename(const string& filename) { // Given a filename like foo/bar/baz.proto, returns the root directory // path ../../ string GetRootPath(const string& filename) { + if (filename.find("google/protobuf") == 0) { + // Well-known types (.proto files in the google/protobuf directory) are + // assumed to come from the 'google-protobuf' npm package. We may want to + // generalize this exception later by letting others put generated code in + // their own npm packages. + return "google-protobuf/"; + } + size_t slashes = std::count(filename.begin(), filename.end(), '/'); if (slashes == 0) { return "./"; -- cgit v1.2.3