From 1337486755518e8df4388463ab71fdc955e5a680 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 a72cf6a3..b39b0e8c 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