Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit def4084

Browse files
bj00rnokuryu
authored andcommitted
Babel 7 upgrade (#145)
1 parent 1b571e7 commit def4084

File tree

14 files changed

+3325
-212
lines changed

14 files changed

+3325
-212
lines changed

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"presets": [
3-
"es2015"
3+
"@babel/preset-env"
44
],
55
"plugins": [
6-
"transform-object-rest-spread",
7-
"transform-runtime"
6+
"@babel/plugin-proposal-object-rest-spread",
7+
"@babel/plugin-transform-runtime"
88
]
99
}

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- 4.2
5-
- 5
64
- 6
75
before_install: if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
86
script: npm run lint && npm test

package.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,33 @@
1010
"main": "lib/index.js",
1111
"author": "Eric Ferraiuolo <edf@ericf.me>",
1212
"dependencies": {
13-
"babel-runtime": "^6.2.0",
13+
"@babel/runtime": "^7.0.0",
1414
"intl-messageformat-parser": "^1.2.0",
1515
"mkdirp": "^0.5.1"
1616
},
1717
"devDependencies": {
18-
"babel-cli": "^6.1.18",
19-
"babel-plugin-espower": "^2.3.1",
20-
"babel-plugin-transform-object-rest-spread": "^6.1.18",
21-
"babel-plugin-transform-runtime": "^6.1.18",
22-
"babel-preset-es2015": "^6.1.18",
23-
"babel-preset-react": "^6.11.1",
24-
"babel-register": "^6.11.6",
18+
"@babel/cli": "^7.0.0",
19+
"@babel/core": "^7.0.0",
20+
"@babel/node": "^7.0.0",
21+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
22+
"@babel/plugin-transform-runtime": "^7.0.0",
23+
"@babel/preset-env": "^7.0.0",
24+
"@babel/preset-react": "^7.0.0",
25+
"@babel/register": "^7.0.0",
26+
"babel-plugin-espower": "^3.0.0",
2527
"cross-env": "^3.1.4",
2628
"eslint": "^3.14.1",
2729
"eslint-plugin-react": "^6.1.2",
2830
"mocha": "^3.0.2",
2931
"power-assert": "^1.4.1",
30-
"rimraf": "^2.4.3"
32+
"rimraf": "^2.4.3",
33+
"upath": "^1.1.0",
34+
"uuid": "^3.3.2"
3135
},
3236
"scripts": {
3337
"lint": "eslint src/",
3438
"clean": "rimraf lib/",
35-
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register",
39+
"test": "cross-env NODE_ENV=test mocha --compilers js:@babel/register",
3640
"build": "babel src/ --out-dir lib/",
3741
"build:fixtures": "babel-node ./scripts/build-fixtures.js",
3842
"preversion": "npm run lint && npm run clean && npm run build",

scripts/build-fixtures.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as p from 'path';
22
import * as fs from 'fs';
3-
import {transformFileSync} from 'babel-core';
3+
import {transformFileSync} from '@babel/core';
44
import plugin from '../src/index';
55

66
const baseDir = p.resolve(`${__dirname}/../test/fixtures`);

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See the accompanying LICENSE file for terms.
55
*/
66

7-
import * as p from 'path';
7+
import * as p from 'upath';
88
import {writeFileSync} from 'fs';
99
import {sync as mkdirpSync} from 'mkdirp';
1010
import printICUMessage from './print-icu-message';
@@ -152,7 +152,7 @@ export default function ({types: t}) {
152152
let loc;
153153
if (opts.extractSourceLocation) {
154154
loc = {
155-
file: p.relative(process.cwd(), file.opts.filename),
155+
file: p.toUnix(p.relative(process.cwd(), file.opts.filename)),
156156
...path.node.loc,
157157
};
158158
}

test/fixtures/.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"presets": [
3-
"es2015",
4-
"react"
3+
"@babel/preset-env",
4+
"@babel/preset-react"
55
],
66
"env": {
77
"test": {
Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
'use strict';
1+
"use strict";
22

33
Object.defineProperty(exports, "__esModule", {
4-
value: true
4+
value: true
55
});
6+
exports.default = void 0;
67

7-
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; }; }();
8+
var _react = _interopRequireWildcard(require("react"));
89

9-
var _react = require('react');
10+
var _reactIntl = require("react-intl");
1011

11-
var _react2 = _interopRequireDefault(_react);
12+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
1213

13-
var _reactIntl = require('react-intl');
14-
15-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1615

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

19-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18+
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); } }
19+
20+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21+
22+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23+
24+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25+
26+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27+
28+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
29+
30+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2031

21-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
32+
var Foo =
33+
/*#__PURE__*/
34+
function (_Component) {
35+
_inherits(Foo, _Component);
2236

23-
var Foo = function (_Component) {
24-
_inherits(Foo, _Component);
37+
function Foo() {
38+
_classCallCheck(this, Foo);
2539

26-
function Foo() {
27-
_classCallCheck(this, Foo);
40+
return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments));
41+
}
2842

29-
return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
43+
_createClass(Foo, [{
44+
key: "render",
45+
value: function render() {
46+
return _react.default.createElement(_reactIntl.FormattedHTMLMessage, {
47+
id: "foo.bar.baz",
48+
defaultMessage: "<h1>Hello World!</h1>"
49+
});
3050
}
51+
}]);
3152

32-
_createClass(Foo, [{
33-
key: 'render',
34-
value: function render() {
35-
return _react2.default.createElement(_reactIntl.FormattedHTMLMessage, {
36-
id: 'foo.bar.baz',
37-
defaultMessage: '<h1>Hello World!</h1>'
38-
});
39-
}
40-
}]);
41-
42-
return Foo;
53+
return Foo;
4354
}(_react.Component);
4455

4556
exports.default = Foo;
Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
'use strict';
1+
"use strict";
22

33
Object.defineProperty(exports, "__esModule", {
4-
value: true
4+
value: true
55
});
6+
exports.default = void 0;
67

7-
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; }; }();
8+
var _react = _interopRequireWildcard(require("react"));
89

9-
var _react = require('react');
10+
var _reactIntl = require("react-intl");
1011

11-
var _react2 = _interopRequireDefault(_react);
12+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
1213

13-
var _reactIntl = require('react-intl');
14-
15-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1615

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

19-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18+
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); } }
19+
20+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21+
22+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23+
24+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25+
26+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27+
28+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
29+
30+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2031

21-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
32+
var Foo =
33+
/*#__PURE__*/
34+
function (_Component) {
35+
_inherits(Foo, _Component);
2236

23-
var Foo = function (_Component) {
24-
_inherits(Foo, _Component);
37+
function Foo() {
38+
_classCallCheck(this, Foo);
2539

26-
function Foo() {
27-
_classCallCheck(this, Foo);
40+
return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments));
41+
}
2842

29-
return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
43+
_createClass(Foo, [{
44+
key: "render",
45+
value: function render() {
46+
return _react.default.createElement(_reactIntl.FormattedMessage, {
47+
id: "foo.bar.baz",
48+
defaultMessage: "Hello World!"
49+
});
3050
}
51+
}]);
3152

32-
_createClass(Foo, [{
33-
key: 'render',
34-
value: function render() {
35-
return _react2.default.createElement(_reactIntl.FormattedMessage, {
36-
id: 'foo.bar.baz',
37-
defaultMessage: 'Hello World!'
38-
});
39-
}
40-
}]);
41-
42-
return Foo;
53+
return Foo;
4354
}(_react.Component);
4455

4556
exports.default = Foo;

0 commit comments

Comments
 (0)