From 42429dc0102522e32672b36e95e1da1c626b7a7b Mon Sep 17 00:00:00 2001 From: Gianluca Guarini Date: Sat, 4 Feb 2017 17:16:07 +0100 Subject: [PATCH] fixes https://github.com/riot/examples/issues/51 --- lib/compiler.js | 6 +++--- src/parsers_br.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index a53d57f..3a4a0dd 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,8 +1,8 @@ /** - * The riot-compiler v3.1.2 + * The riot-compiler WIP * * @module compiler - * @version v3.1.2 + * @version WIP * @license MIT * @copyright Muut Inc. + contributors */ @@ -997,5 +997,5 @@ module.exports = { css: compileCSS, js: compileJS, parsers: parsers, - version: 'v3.1.2' + version: 'WIP' } diff --git a/src/parsers_br.js b/src/parsers_br.js index 2fa357c..9e7c658 100644 --- a/src/parsers_br.js +++ b/src/parsers_br.js @@ -98,8 +98,42 @@ var parsers = (function (win) { } } _p.js = { + // Babel should be handled differently depending on the environement where we are es6: function (js, opts, url) { +/*#if NODE */ return _r('babel').transform(js, extend({ filename: url }, opts)).code +//#else */ + return _r('Babel').transform( // eslint-disable-line + js, + extend({ + filename: url, + plugins: [ + ['transform-es2015-template-literals', { loose: true }], + 'transform-es2015-literals', + 'transform-es2015-function-name', + 'transform-es2015-arrow-functions', + 'transform-es2015-block-scoped-functions', + ['transform-es2015-classes', { loose: true }], + 'transform-es2015-object-super', + 'transform-es2015-shorthand-properties', + 'transform-es2015-duplicate-keys', + ['transform-es2015-computed-properties', { loose: true }], + ['transform-es2015-for-of', { loose: true }], + 'transform-es2015-sticky-regex', + 'transform-es2015-unicode-regex', + 'check-es2015-constants', + ['transform-es2015-spread', { loose: true }], + 'transform-es2015-parameters', + ['transform-es2015-destructuring', { loose: true }], + 'transform-es2015-block-scoping', + 'transform-es2015-typeof-symbol', + ['transform-es2015-modules-commonjs', { allowTopLevelThis: true }], + ['transform-regenerator', { async: false, asyncGenerators: false }] + ] + }, + opts + )).code +//#endif }, buble: function (js, opts, url) { opts = extend({