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

Babel 7 upgrade #145

Merged
merged 7 commits into from
Sep 12, 2018
Merged
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
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"presets": [
"es2015"
"@babel/preset-env"
],
"plugins": [
"transform-object-rest-spread",
"transform-runtime"
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-runtime"
]
}
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
sudo: false
language: node_js
node_js:
- 4.2
- 5
- 6
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have testing on v8 and v10 right now.

Copy link
Contributor Author

@bj00rn bj00rn Sep 4, 2018

Choose a reason for hiding this comment

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

seems a little out-of-scope for this, dont you think? maybe a separate PR for this?

before_install: if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
script: npm run lint && npm test
Expand Down
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,33 @@
"main": "lib/index.js",
"author": "Eric Ferraiuolo <[email protected]>",
"dependencies": {
"babel-runtime": "^6.2.0",
"@babel/runtime": "^7.0.0",
"intl-messageformat-parser": "^1.2.0",
"mkdirp": "^0.5.1"
},
"devDependencies": {
"babel-cli": "^6.1.18",
"babel-plugin-espower": "^2.3.1",
"babel-plugin-transform-object-rest-spread": "^6.1.18",
"babel-plugin-transform-runtime": "^6.1.18",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.11.1",
"babel-register": "^6.11.6",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-plugin-espower": "^3.0.0",
"cross-env": "^3.1.4",
"eslint": "^3.14.1",
"eslint-plugin-react": "^6.1.2",
"mocha": "^3.0.2",
"power-assert": "^1.4.1",
"rimraf": "^2.4.3"
"rimraf": "^2.4.3",
"upath": "^1.1.0",
"uuid": "^3.3.2"
},
"scripts": {
"lint": "eslint src/",
"clean": "rimraf lib/",
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register",
"test": "cross-env NODE_ENV=test mocha --compilers js:@babel/register",
"build": "babel src/ --out-dir lib/",
"build:fixtures": "babel-node ./scripts/build-fixtures.js",
"preversion": "npm run lint && npm run clean && npm run build",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-fixtures.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as p from 'path';
import * as fs from 'fs';
import {transformFileSync} from 'babel-core';
import {transformFileSync} from '@babel/core';
import plugin from '../src/index';

const baseDir = p.resolve(`${__dirname}/../test/fixtures`);
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See the accompanying LICENSE file for terms.
*/

import * as p from 'path';
Copy link

Choose a reason for hiding this comment

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

Issue seems to be here where upath is clearly used in library code, but not added to normal dependencies but only devDependencies.

Copy link
Member

Choose a reason for hiding this comment

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

@serwer-WittGruppe want to test it out and open a PR with the fix?

import * as p from 'upath';
import {writeFileSync} from 'fs';
import {sync as mkdirpSync} from 'mkdirp';
import printICUMessage from './print-icu-message';
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function ({types: t}) {
let loc;
if (opts.extractSourceLocation) {
loc = {
file: p.relative(process.cwd(), file.opts.filename),
file: p.toUnix(p.relative(process.cwd(), file.opts.filename)),
...path.node.loc,
};
}
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/.babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"presets": [
"es2015",
"react"
"@babel/preset-env",
"@babel/preset-react"
],
"env": {
"test": {
Expand Down
63 changes: 37 additions & 26 deletions test/fixtures/FormattedHTMLMessage/expected.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
'use strict';
"use strict";

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

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 _react = _interopRequireWildcard(require("react"));

var _react = require('react');
var _reactIntl = require("react-intl");

var _react2 = _interopRequireDefault(_react);
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; } }

var _reactIntl = require('react-intl');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }

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

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; }
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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

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); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

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; }
var Foo =
/*#__PURE__*/
function (_Component) {
_inherits(Foo, _Component);

var Foo = function (_Component) {
_inherits(Foo, _Component);
function Foo() {
_classCallCheck(this, Foo);

function Foo() {
_classCallCheck(this, Foo);
return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments));
}

return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
_createClass(Foo, [{
key: "render",
value: function render() {
return _react.default.createElement(_reactIntl.FormattedHTMLMessage, {
id: "foo.bar.baz",
defaultMessage: "<h1>Hello World!</h1>"
});
}
}]);

_createClass(Foo, [{
key: 'render',
value: function render() {
return _react2.default.createElement(_reactIntl.FormattedHTMLMessage, {
id: 'foo.bar.baz',
defaultMessage: '<h1>Hello World!</h1>'
});
}
}]);

return Foo;
return Foo;
}(_react.Component);

exports.default = Foo;
63 changes: 37 additions & 26 deletions test/fixtures/FormattedMessage/expected.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
'use strict';
"use strict";

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

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 _react = _interopRequireWildcard(require("react"));

var _react = require('react');
var _reactIntl = require("react-intl");

var _react2 = _interopRequireDefault(_react);
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; } }

var _reactIntl = require('react-intl');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }

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

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; }
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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

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); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

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; }
var Foo =
/*#__PURE__*/
function (_Component) {
_inherits(Foo, _Component);

var Foo = function (_Component) {
_inherits(Foo, _Component);
function Foo() {
_classCallCheck(this, Foo);

function Foo() {
_classCallCheck(this, Foo);
return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments));
}

return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
_createClass(Foo, [{
key: "render",
value: function render() {
return _react.default.createElement(_reactIntl.FormattedMessage, {
id: "foo.bar.baz",
defaultMessage: "Hello World!"
});
}
}]);

_createClass(Foo, [{
key: 'render',
value: function render() {
return _react2.default.createElement(_reactIntl.FormattedMessage, {
id: 'foo.bar.baz',
defaultMessage: 'Hello World!'
});
}
}]);

return Foo;
return Foo;
}(_react.Component);

exports.default = Foo;
Loading