├── .travis.yml ├── test ├── tags │ └── component.tag └── runner.js ├── .gitignore ├── LICENSE ├── readme.md ├── index.js └── package.json /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "10" 4 | 5 | branches: 6 | only: 7 | - master 8 | 9 | script: 10 | npm test 11 | 12 | sudo: false 13 | 14 | notifications: 15 | email: false 16 | -------------------------------------------------------------------------------- /test/tags/component.tag: -------------------------------------------------------------------------------- 1 | 2 |

{ message }

3 | 16 |
-------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | .DS_Store 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 28 | node_modules 29 | -------------------------------------------------------------------------------- /test/runner.js: -------------------------------------------------------------------------------- 1 | require('shelljs/global') 2 | 3 | var compiler = require('riot-compiler'), 4 | expect = require('expect.js'), 5 | preset 6 | 7 | describe('Babel parser preset', function() { 8 | this.timeout(8000) // for slow pcs 9 | 10 | it('can require all the plugins', function() { 11 | preset = require('../') 12 | }) 13 | 14 | it('can compiler properly the tag', function() { 15 | compiler.parsers.js.babel = function (js, opts, url) { 16 | return require('babel-core').transform(js, preset).code 17 | } 18 | expect(compiler.compile(cat('./test/tags/component.tag'), { 19 | type: 'babel' 20 | })).to.match(/riot\.tag/) 21 | }) 22 | }) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Riot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # The default riot babel preset 2 | 3 | [![Build Status](https://travis-ci.org/riot/babel-preset-es2015-riot.svg?branch=master)](https://travis-ci.org/riot/babel-preset-es2015-riot) 4 | 5 | This preset includes all the default [babel es2015 plugins](https://github.com/babel/babel/blob/master/packages/babel-preset-es2015/index.js) 6 | Allowing the use of the `es2015 modules` also in any riot tag 7 | 8 | # Installation 9 | 10 | `$ npm install babel-preset-es2015-riot --save-dev` 11 | 12 | # Usage 13 | 14 | Add a `.babelrc` file in the root of your project 15 | 16 | ```json 17 | { 18 | "presets": [ "es2015-riot" ] 19 | } 20 | ``` 21 | 22 | If you want to use the babel helpers you must change the `.babelrc` file in this way: 23 | 24 | ```json 25 | { 26 | "presets": [ "es2015-riot" ], 27 | "plugins": [ "external-helpers-2" ] 28 | } 29 | ``` 30 | 31 | # Babel 7 32 | 33 | If you are using babel 7 you don't need to use this preset at all. 34 | You can simply configure your `.babelrc` in this way: 35 | 36 | ```js 37 | { 38 | "presets": [ 39 | [ 40 | "@babel/preset-env", 41 | { 42 | "modules": false, 43 | "targets": [ 44 | // wathever you need to support 45 | "last 2 versions" 46 | ] 47 | } 48 | ] 49 | ] 50 | } 51 | ``` 52 | 53 | Remeber to install via npm the `@babel/core@7` and `@babel/preset-env@7` dependencies -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | [require('babel-plugin-transform-es2015-template-literals'), {'loose': true}], 4 | require('babel-plugin-transform-es2015-literals'), 5 | require('babel-plugin-transform-es2015-function-name'), 6 | require('babel-plugin-transform-es2015-arrow-functions'), 7 | require('babel-plugin-transform-es2015-block-scoped-functions'), 8 | [require('babel-plugin-transform-es2015-classes'), {'loose': true}], 9 | require('babel-plugin-transform-es2015-object-super'), 10 | require('babel-plugin-transform-es2015-shorthand-properties'), 11 | require("babel-plugin-transform-es2015-duplicate-keys"), 12 | [require('babel-plugin-transform-es2015-computed-properties'), {'loose': true}], 13 | [require('babel-plugin-transform-es2015-for-of'), {'loose': true}], 14 | require('babel-plugin-transform-es2015-sticky-regex'), 15 | require('babel-plugin-transform-es2015-unicode-regex'), 16 | require('babel-plugin-check-es2015-constants'), 17 | [require('babel-plugin-transform-es2015-spread'), {'loose': true}], 18 | require('babel-plugin-transform-es2015-parameters'), 19 | [require('babel-plugin-transform-es2015-destructuring'), {'loose': true}], 20 | require('babel-plugin-transform-es2015-block-scoping'), 21 | require('babel-plugin-transform-es2015-typeof-symbol'), 22 | [require('babel-plugin-transform-es2015-modules-commonjs'), { 'allowTopLevelThis': true }], 23 | [require('babel-plugin-transform-regenerator'), { 'async': false, 'asyncGenerators': false }] 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-es2015-riot", 3 | "version": "1.1.0", 4 | "description": "The default riot babel preset ", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha test/runner" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/riot/babel-preset-es2015-riot.git" 12 | }, 13 | "keywords": [ 14 | "riot", 15 | "babel" 16 | ], 17 | "author": "Gianluca Guarini (http://gianlucaguarini.com/)", 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/riot/babel-preset-es2015-riot/issues" 21 | }, 22 | "homepage": "https://github.com/riot/babel-preset-es2015-riot#readme", 23 | "dependencies": { 24 | "babel-plugin-check-es2015-constants": "^6.8.0", 25 | "babel-plugin-transform-es2015-arrow-functions": "^6.8.0", 26 | "babel-plugin-transform-es2015-block-scoped-functions": "^6.8.0", 27 | "babel-plugin-transform-es2015-block-scoping": "^6.8.0", 28 | "babel-plugin-transform-es2015-classes": "^6.8.0", 29 | "babel-plugin-transform-es2015-computed-properties": "^6.8.0", 30 | "babel-plugin-transform-es2015-destructuring": "^6.8.0", 31 | "babel-plugin-transform-es2015-duplicate-keys": "^6.8.0", 32 | "babel-plugin-transform-es2015-for-of": "^6.8.0", 33 | "babel-plugin-transform-es2015-function-name": "^6.8.0", 34 | "babel-plugin-transform-es2015-literals": "^6.8.0", 35 | "babel-plugin-transform-es2015-modules-commonjs": "^6.8.0", 36 | "babel-plugin-transform-es2015-object-super": "^6.8.0", 37 | "babel-plugin-transform-es2015-parameters": "^6.8.0", 38 | "babel-plugin-transform-es2015-shorthand-properties": "^6.8.0", 39 | "babel-plugin-transform-es2015-spread": "^6.8.0", 40 | "babel-plugin-transform-es2015-sticky-regex": "^6.8.0", 41 | "babel-plugin-transform-es2015-template-literals": "^6.8.0", 42 | "babel-plugin-transform-es2015-typeof-symbol": "^6.8.0", 43 | "babel-plugin-transform-es2015-unicode-regex": "^6.8.0", 44 | "babel-plugin-transform-regenerator": "^6.8.0" 45 | }, 46 | "devDependencies": { 47 | "babel-core": "^6.8.0", 48 | "expect.js": "^0.3.1", 49 | "mocha": "^7.0.1", 50 | "moment": "^2.13.0", 51 | "riot-compiler": "^3.1.2", 52 | "shelljs": "^0.8.0" 53 | } 54 | } 55 | --------------------------------------------------------------------------------