From 77050ad5f78061b12453378d8f6a563fad2e9a2b Mon Sep 17 00:00:00 2001 From: amarcruz Date: Fri, 26 Aug 2016 16:59:09 -0500 Subject: [PATCH] =?UTF-8?q?Added=20parser=20for=20[bubl=C3=A9](https://bub?= =?UTF-8?q?le.surge.sh)=20as=20`buble`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 + CHANGELOG.md | 3 +++ lib/parsers.js | 2 +- lib/parsers/buble.js | 18 ++++++++++++++++++ package.json | 2 +- test/specs/parsers/_suite.js | 7 +++++++ test/specs/parsers/js/test.buble.js | 15 +++++++++++++++ test/specs/parsers/test.buble.tag | 15 +++++++++++++++ 8 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 lib/parsers/buble.js create mode 100644 test/specs/parsers/js/test.buble.js create mode 100644 test/specs/parsers/test.buble.tag diff --git a/.travis.yml b/.travis.yml index a8239aa..752ddd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ install: # babel presets - npm i babel-preset-es2015-riot + - npm i buble - npm i coffee-script - npm i livescript - npm i typescript-simple diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f9171..4186b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Compiler Changes +### v2.5.4 +- Added parser for [bublé](https://buble.surge.sh) as `buble`. + ### v2.5.3 - Fix #73 : resolveModuleSource must be a function - Option removed from the default Babel options. - Updated node.js to 4.4 in the Travis environment. diff --git a/lib/parsers.js b/lib/parsers.js index 2691ac5..9cada3a 100644 --- a/lib/parsers.js +++ b/lib/parsers.js @@ -26,7 +26,7 @@ var _parsers = { var _loaders = { html: { jade: TRUE, pug: TRUE }, css: { sass: TRUE, scss: TRUE, less: TRUE, stylus: TRUE }, - js: { es6: TRUE, babel: TRUE, coffee: TRUE, livescript: TRUE, typescript: TRUE } + js: { es6: TRUE, babel: TRUE, buble: TRUE, coffee: TRUE, livescript: TRUE, typescript: TRUE } } _loaders.js.coffeescript = TRUE // 4 the nostalgics diff --git a/lib/parsers/buble.js b/lib/parsers/buble.js new file mode 100644 index 0000000..8fa4ecc --- /dev/null +++ b/lib/parsers/buble.js @@ -0,0 +1,18 @@ +/* + bublé 0.13.x JS plugin. + Part of the riot-compiler, license MIT + + History + ------- + 2016-08-26: Initital release +*/ +var + mixobj = require('./_utils').mixobj, + parser = require('buble') + +module.exports = function _buble (js, opts, url) { + + opts = mixobj({ source: url }, opts) + + return parser.transform(js, opts).code +} diff --git a/package.json b/package.json index 2bbfb1f..8ef6293 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "riot-compiler", - "version": "2.5.2", + "version": "2.5.4", "description": "Compiler for riot .tag files", "main": "lib/compiler.js", "jsnext:main": "dist/es6.compiler.js", diff --git a/test/specs/parsers/_suite.js b/test/specs/parsers/_suite.js index bcbf7ed..4de982e 100644 --- a/test/specs/parsers/_suite.js +++ b/test/specs/parsers/_suite.js @@ -171,6 +171,13 @@ describe('JavaScript parsers', function () { } }) + // test.buble.tag + it('bublé', function () { + if (have('buble')) { + testParser('test', { type: 'buble' }) + } + }) + // test-attr.babel.tag (also test alias coffeescript) it('coffee with shorthands (fix #1090)', function () { if (have('coffeescript')) { diff --git a/test/specs/parsers/js/test.buble.js b/test/specs/parsers/js/test.buble.js new file mode 100644 index 0000000..cb2244e --- /dev/null +++ b/test/specs/parsers/js/test.buble.js @@ -0,0 +1,15 @@ + +riot.tag2('buble', '

{test}

', '', '', function(opts) { + + var this$1 = this; + + this.parser = 'Buble' + + var type = 'JavaScript' + this.test = "This is " + type + " with " + (this.parser) + + this.on('mount', function () { + this$1.parser = 'bublé' + }) + +}); diff --git a/test/specs/parsers/test.buble.tag b/test/specs/parsers/test.buble.tag new file mode 100644 index 0000000..f0a844e --- /dev/null +++ b/test/specs/parsers/test.buble.tag @@ -0,0 +1,15 @@ + + + +

{ test }

+ + this.parser = 'Buble' + + const type = 'JavaScript' + this.test = `This is ${ type } with ${ this.parser }` + + this.on('mount', () => { + this.parser = 'bublé' + }) + +