[TIMOB-13133] Ti API: Implement support for file, line, etc "macros"
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | cb-tooling |
Reporter | Bryan Hughes |
Assignee | Unknown |
Created | 2013-03-20T17:10:15.000+0000 |
Updated | 2020-02-05T07:22:45.000+0000 |
Description
Node.js has two useful "macros" of sorts: __dirname and __filename (see http://nodejs.org/api/globals.html). We should consider adding similar macros of our own:
* __file
* __line
* __function
It's worth noting that Node.js only supports __dirname and __filename because they can be inserted as module-scoped variables, but __line and __column require compile-time support. It's a lot easier for us to do compile-time support (a true macro) than it is for Node.js, but it's still worth discussing this point.
Note: for production builds, we should not insert this information. Strings should be undefined/empty string and numbers should be NaN
This should be implemented as a CLI hook that uses uglify to walk the AST tree and modify it
No comments