Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1646

NodeJS compiler generates invalid namespaced JavaScript

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.8
    • Fix Version/s: 0.9.2
    • Component/s: Node.js - Compiler
    • Labels:
    • Environment:

      Any.

      Description

      OVERVIEW

      In Thrift's IDL, it's possible to specify that generated code be namespaced in Javascript. Example:

      namespace js my.namespace

      struct mystruct {
      ...
      }

      When the IDL is compiled, mystruct should be available as my.namespace.mystruct. The NodeJS compiler behaves as if this were normal JavaScript, assuming that my and my.namespace have been initialized! However, because NodeJS apps use require() to load modules, mystruct will fail to initialize, as 'my' and 'my.namespace' were never initialized as objects.

      SUGGESTED RESOLUTION

      On one hand, this is a low-impact issue. Because require() allows library-consumers to namespace exported modules however they like, namespacing can be completely omitted without any negative impact to the application.

      However, this is a very easy mistake to make, and a confusing one to debug. Generated code should 'just work,' regardless of the idiosyncrasies of a particular language (JavaScript + require()).

        Attachments

          Activity

            People

            • Assignee:
              henrique Henrique Mendonca
              Reporter:
              dcromer Dan Cromer
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: