You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Benjamin Gould (JIRA)" <ji...@apache.org> on 2016/10/06 19:17:20 UTC

[jira] [Commented] (THRIFT-3546) NodeJS code should not be namespaced (and is currently not strict-mode compliant)

    [ https://issues.apache.org/jira/browse/THRIFT-3546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15552898#comment-15552898 ] 

Benjamin Gould commented on THRIFT-3546:
----------------------------------------

I have a fix for this that eliminates the namespace object heirarchy in node.js generated code, and adds a compiler flag that can be used for backwards compatibility if necessary.

I think that not generating the namespace objects for node.js/browserify is a sensible default behavior because for node.js/browserify it is idiomatic to use require() rather than relying on objects being in the global namespace (which makes me doubt that very many developers if any are relying on that behavior).

Github PR coming shortly.

> NodeJS code should not be namespaced (and is currently not strict-mode compliant)
> ---------------------------------------------------------------------------------
>
>                 Key: THRIFT-3546
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3546
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Compiler
>    Affects Versions: 0.9.3
>            Reporter: Yunchi Luo
>
> Code generated for NodeJS, whether with a js namespace specified or not, seems to fail strict mode. Specifically, it doesn't always generate "var" when needed. This might not sound like a big issue but it's quite a pain to deal with...
> It is standard nowadays to enable strict mode for Javascript code (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode). And babel, which is one of most popular ES6 => ES5 transpilers, while does not force strict mode, does seem to break when you don't use "var".
> I think the best solution here is really to just stop using namespaces in node code. Every type will be declared with "var", and if exported, also assigned to "module.exports".
> I don't believe namespaces currently generated in the node code is directly used anywhere or is even accessible outside the file?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)