ANN: JavaScrypthon 0.5, now with embedded evaluation of transpiled code

Alberto Berti azazel+python-announce at arstecnica.it
Sat Nov 26 08:13:15 EST 2016


Hi all,

i'm pleased to announce that JavaScripthon 0.5 has been released to
PyPI. JavaScrypthon can translate a subset of Python 3.5 code to  ES6
JavaScript producing beautiful and lean  code, while supporting some of
the latest Python features.

Changelog
(https://github.com/azazel75/metapensiero.pj/blob/master/CHANGES.rst):

- translate ``tmpl("A string with js ${interpolation}")`` to ES6 template
  literals;
- preliminary support to translate names like ``d_foo`` and ``dd_bar`` to
  ``$foo`` and ``$$bar``;
- addded translation of the ``assert`` statement;
- fixed a bug in ``try...except...finally`` statement when there's no
  ``except`` section;
- added translation for ``foo is not bar`` that seems to have dedicated ast
  node;
- if the function is defined in a method but starts with ``fn_`` do not convert
  it to an arrow function. Useful to *not* maintain ``this``;
- added translation for ``callable`` and ``hasattr/getattr/setattr``;
- updated for loops to support more than one target, so now its possible to
  write loops like ``for k, v in iterable(a_map):``;
- updated documentation;
- added a new cli option ``-s`` to translate source from the command line or
  the standard input;
- fixed a pair of bugs on sourcemaps;
- added a new cli option ``--eval`` to also evaluate the produced JavaScript
  using the embedded interpreter;
- added a new cli option ``--dump-ast`` to print out the ast tree of the
  passed in string;
- added sorting to the rendered snippets/decorators/assignments so that their
  order does not change at every ricompilation;
- do not re-declare variables declare in outer scopes;

- updated BabelJS to version 6.18.1;
- allow to import modules with dashes inside by using dunder-inside-words
  notation (``foo__bar`` becomes ``foo-bar``);
- reuse JavaScript interpreter context to speedup translation;
- update ``in`` operator to support ES6 collections;
- added support for method and class decorators;
- added support for class properties and descriptors;
- add ``for`` loop over JS iterables;
- allow to loop over inherited properties;
- fix a bug on ``type()`` translation;
- support for ``range()`` steps;
- add support for generator functions and ``yield`` and ``yield from``
  expressions;
- optionally load babel-polyfill before evaluating code;
- fix a bug on sourcemaps having wrong references when there are documentation
  elements;
- translate ``__get__()`` and ``__set__()`` to to JS equivalents;
- implement ``dict(foo).update(bar)`` and ``dict(foo).copy``;
- documentation improvements;


More information about the Python-announce-list mailing list