Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

feat(babel): support babel 6.x.x #90

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"stage": 0
"presets": ["es2015", "stage-0"]
}
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
sudo: false
language: node_js
node_js:
- '0.10'
- '0.12'
- 'io.js'
- 'stable'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTS supported versions are 0.10, 0.12, v4 plus latest one v5

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would not drop 0.10 for now

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"license": "WTFPL",
"dependencies": {
"babel-core": "^5.8.25",
"babel-core": "^6.1.2",
"escodegen": "^1.6.1",
"esprima": "^2.1.0",
"istanbul": "^0.4.0",
Expand All @@ -49,7 +49,10 @@
"which": "^1.0.9"
},
"devDependencies": {
"babel": "^5.8.23",
"babel-cli": "^6.1.2",
"babel-polyfill": "^6.0.16",
"babel-preset-es2015": "^6.1.2",
"babel-preset-stage-0": "^6.1.2",
"chai": "^3.2.0",
"hide-stack-frames-from": "^1.0.0",
"mocha": "^2.2.1",
Expand Down
5 changes: 2 additions & 3 deletions src/instrumenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {transform as babelTransform} from 'babel-core';
import esprima from 'esprima';
import escodegen from 'escodegen';

import {SourceMapConsumer, SourceMapGenerator} from 'source-map';
import {SourceMapConsumer} from 'source-map';

const POSITIONS = ['start', 'end'];

Expand All @@ -24,7 +24,7 @@ export class Instrumenter extends istanbul.Instrumenter {

instrumentSync(code, fileName) {

let result = this._r =
const result = this._r =
babelTransform(code, { ...this.babelOptions, filename: fileName });
this._babelMap = new SourceMapConsumer(result.map);

Expand Down Expand Up @@ -151,4 +151,3 @@ export class Instrumenter extends istanbul.Instrumenter {
};

}

2 changes: 1 addition & 1 deletion src/isparta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from 'istanbul';
export {Store, Collector, hook, Report, config, Reporter, utils, matcherFor, Writer, ContentWriter, FileWriter, _yuiLoadHook, TreeSummarizer, assetsDir} from 'istanbul';
export {Instrumenter} from './instrumenter';
export {VERSION} from '../package.json';
48 changes: 20 additions & 28 deletions test/fixtures/es6-classes/compiled.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"use strict";
'use strict';

var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
Object.defineProperty(exports, "__esModule", {
value: true
});

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

//

Expand All @@ -11,36 +15,24 @@ var Animal = (function () {
_classCallCheck(this, Animal);
}

_prototypeProperties(Animal, {
getName: {
value: function getName() {
return "Animal";
},
writable: true,
configurable: true
_createClass(Animal, [{
key: 'sayHi',
value: function sayHi() {
return 'Hi, I am a ' + this.type() + '.';
}
}, {
sayHi: {
value: function sayHi() {
return "Hi, I am a " + this.type() + ".";
},
writable: true,
configurable: true
},
sayOther: {
value: function sayOther() {
return "WAT?!";
},
writable: true,
configurable: true
key: 'sayOther',
value: function sayOther() {
return 'WAT?!';
}
}], [{
key: 'getName',
value: function getName() {
return 'Animal';
}
});
}]);

return Animal;
})();

exports.Animal = Animal;
Object.defineProperty(exports, "__esModule", {
value: true
});

54 changes: 18 additions & 36 deletions test/fixtures/es6-classes/expectedCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ module.exports = {

fnMap: []
.concat(generateNSkipedFunction(
{name: '(anonymous_1)', line: 9},
{name: 'defineProperties', line: 9},
{name: '(anonymous_3)', line: 9},
{name: '_classCallCheck', line: 11}
{name: '(anonymous_1)', line: 3},
{name: 'defineProperties', line: 3},
{name: '(anonymous_3)', line: 3},
{name: '_classCallCheck', line: 9}
))
.concat([
// 5th fn
Expand All @@ -85,44 +85,26 @@ module.exports = {
.concat(generateNSkipedFunction(
{name: 'Animal', line: 14}
))
.concat([
// 7th fn
{
name: 'sayHi', line: 20,
loc: {
start: {line: 4, column: 7},
end: {line: 4, column: 10}
}
},
// 8th fn
{
name: 'sayOther', line: 25,
loc: {
start: {line: 8, column: 10},
end: {line: 8, column: 13}
}
},
// 9th fn
{
name: 'getName', line: 30,
loc: {
start: {line: 12, column: 16},
end: {line: 12, column: 19}
}
}
])
,
.concat(generateNSkipedFunction(
{name: 'sayHi', line: 20}
))
.concat(generateNSkipedFunction(
{name: 'sayOther', line: 25}
))
.concat(generateNSkipedFunction(
{name: 'getName', line: 30}
)),

branchMap: generateNSkipedBranch(
// 1th branch
{line: 9, type: 'binary-expr'},
{line: 3, type: 'binary-expr'},
// 2th branch
{line: 9, type: 'if'},
{line: 3, type: 'if'},
// 3th branch
{line: 9, type: 'if'},
{line: 3, type: 'if'},
// 4th branch
{line: 9, type: 'if'},
{line: 3, type: 'if'},
// 5th branch
{line: 11, type: 'if'}
{line: 9, type: 'if'}
)
};
12 changes: 6 additions & 6 deletions test/fixtures/virgin/expectedCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
// 4. return baz(bar ? 0 : 1);
// 5. };
start: {line: 3, column: 0},
end: {line: 5, column: 2}
end: {line: 5, column: 1}
},
{
// 4. return baz(bar ? 0 : 1);
Expand All @@ -30,7 +30,7 @@ module.exports = {
// 8. if (true) {
// 9. var a = 5;
// 10. }
start: {line: 8, column: 0},
start: {line: 5, column: 2},
end: {line: 10, column: 1},
skip: true
},
Expand Down Expand Up @@ -73,13 +73,13 @@ module.exports = {
line: 8, type: 'if',
locations: [
{
start: {line: 8, column: 0},
end: {line: 8, column: 0},
start: {line: 5, column: 2},
end: {line: 5, column: 2},
skip: true
},
{
start: {line: 8, column: 0},
end: {line: 8, column: 0},
start: {line: 5, column: 2},
end: {line: 5, column: 2},
skip: true
}
]
Expand Down
3 changes: 2 additions & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--compilers babel:babel/register
--compilers babel:babel-core/register
--require babel-polyfill