Skip to content

Commit

Permalink
chore: Bump proxy-compat to 0.18.2 (#288)
Browse files Browse the repository at this point in the history
* chore: bump proxy-compat version
* test: Fix tests impacted by compat changes
* fix: class-transform after babel bump to beta 44
* fix: Update snapshot tests
  • Loading branch information
pmdartus authored May 9, 2018
1 parent a4509a9 commit c594e40
Show file tree
Hide file tree
Showing 16 changed files with 689 additions and 475 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/salesforce/lwc.git"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.40",
"@babel/core": "7.0.0-beta.44",
"@types/acorn": "~4.0.3",
"@types/jest": "~22.1.3",
"@types/node": "8.9.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-transform-lwc-class/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test": "echo 'Building LWC class transformer...' && DIR=`pwd` && cd ../../ && jest $DIR"
},
"dependencies": {
"@babel/helper-module-imports": "7.0.0-beta.40",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.40",
"@babel/helper-module-imports": "7.0.0-beta.44",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.44",
"comment-parser": "^0.5.0"
}
}
12 changes: 6 additions & 6 deletions packages/babel-plugin-transform-lwc-class/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ const decorators = require('./decorators');
* - First, apply in a single AST traversal the decorators and the component transformation.
* - Then, in a second path transform class properties using the official babel plugin "babel-plugin-transform-class-properties".
*/
module.exports = function ({ types, traverse }) {
const { merge: mergeVisitors } = traverse.visitors;
module.exports = function LwcClassTransform(api) {
const { merge: mergeVisitors } = api.traverse.visitors;

const { visitor: classPropertyVisitor } = classProperty({ types }, { loose: true });
const { visitor: classPropertyVisitor } = classProperty(api, { loose: true });

return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push('decorators');
parserOpts.plugins.push('classProperties');
},
visitor: mergeVisitors([
metadata({ types }),
decorators({ types }),
component({ types }),
metadata(api),
decorators(api),
component(api),
{
Program: {
exit(path, state) {
Expand Down
8 changes: 4 additions & 4 deletions packages/lwc-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"test": "DIR=`pwd` && cd ../../ && jest $DIR"
},
"dependencies": {
"@babel/core": "7.0.0-beta.40",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.40",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.40",
"@babel/core": "7.0.0-beta.44",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.44",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.44",
"babel-plugin-transform-lwc-class": "0.20.1",
"babel-preset-compat": "0.17.43",
"babel-preset-compat": "0.18.2",
"babel-preset-minify": "0.4.0-alpha.caaefb4c",
"cssnano": "^3.10.0",
"lwc-template-compiler": "0.20.1",
Expand Down
104 changes: 70 additions & 34 deletions packages/lwc-compiler/src/__tests__/fixtures/expected-babel-compat.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import __iterableKey from 'proxy-compat/iterableKey';
import __callKey from 'proxy-compat/callKey';
import __concat from 'proxy-compat/concat';
import __callKey1 from 'proxy-compat/callKey1';
import __getKey from 'proxy-compat/getKey';
import __inKey from 'proxy-compat/inKey';
import __setKey from 'proxy-compat/setKey';
import __iterableKey from 'proxy-compat/iterableKey';
import __callKey2 from 'proxy-compat/callKey2';
import __callKey0 from 'proxy-compat/callKey0';
import __callKey3 from 'proxy-compat/callKey3';
import _regeneratorRuntime from 'babel-compat/regenerator';
import _asyncToGenerator from 'babel-compat/helpers/asyncToGenerator';
import _createClass from 'babel-compat/helpers/createClass';
import _typeof from 'babel-compat/helpers/typeof';
import _taggedTemplateLiteral from 'babel-compat/helpers/taggedTemplateLiteral';
import _toConsumableArray from 'babel-compat/helpers/toConsumableArray';
import _slicedToArray from 'babel-compat/helpers/slicedToArray';
import _defineProperty from 'babel-compat/helpers/defineProperty';
import _defineProperty2 from 'babel-compat/helpers/defineProperty';
import _classCallCheck from 'babel-compat/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-compat/helpers/possibleConstructorReturn';
import _inherits from 'babel-compat/helpers/inherits';
Expand All @@ -18,26 +23,57 @@ var _templateObject = /*#__PURE__*/ _taggedTemplateLiteral(["wow\na", "b ", ""],
_templateObject2 = /*#__PURE__*/ _taggedTemplateLiteral(["wow\nab", " ", ""], ["wow\\nab", " ", ""]),
_templateObject3 = /*#__PURE__*/ _taggedTemplateLiteral(["wow\naB", " ", ""], ["wow\\naB", " ", ""]);

// babel-plugin-check-es2015-constants
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.compatKeys(source);

if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = __concat(ownKeys, __callKey1(Object.getOwnPropertySymbols(source), "filter", function (sym) {
return __getKey(Object.getOwnPropertyDescriptor(source, sym), "enumerable");
}));
}

__callKey1(ownKeys, "forEach", function (key) {
_defineProperty(target, key, __getKey(source, key));
});
}
return target;
}

function _defineProperty(obj, key, value) {
if (__inKey(obj, key)) {
Object.compatDefineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
__setKey(obj, key, value);
}

return obj;
} // babel-plugin-check-es2015-constants
// https://github.com/babel/babel/blob/master/packages/babel-plugin-check-es2015-constants/test/fixtures/general/program/actual.js
var MULTIPLIER = 5;

for (var i in __iterableKey(arr)) {
__callKey(console, "log", __getKey(arr, i) * MULTIPLIER);
__callKey1(console, "log", __getKey(arr, i) * MULTIPLIER);
} // babel-plugin-transform-es2015-arrow-functions
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-arrow-functions/test/fixtures/arrow-functions/expression/actual.js


__callKey(arr, "map", function (x) {
return __callKey(console, "log", x * x);
__callKey1(arr, "map", function (x) {
return __callKey1(console, "log", x * x);
}); // babel-plugin-transform-es2015-block-scoping
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-block-scoping/test/fixtures/general/function/actual.js


function test() {
var foo = "bar";

__callKey(console, "log", foo);
__callKey1(console, "log", foo);
} // babel-plugin-transform-es2015-classes
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/super-class/actual.js

Expand All @@ -49,22 +85,22 @@ function (_Foo) {
function Test() {
_classCallCheck(this, Test);

return _possibleConstructorReturn(this, __callKey(__getKey(Test, "__proto__") || Object.getPrototypeOf(Test), "apply", this, arguments));
return _possibleConstructorReturn(this, __callKey2(__getKey(Test, "__proto__") || Object.getPrototypeOf(Test), "apply", this, arguments));
}

return Test;
}(Foo); //babel-plugin-transform-es2015-computed-properties
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-computed-properties/test/fixtures/loose/single/actual.js

var obj1 = _defineProperty({}, "x" + foo, "heh"); // babel-plugin-transform-es2015-destructuring
var obj1 = _defineProperty2({}, "x" + foo, "heh"); // babel-plugin-transform-es2015-destructuring
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-destructuring/test/fixtures/destructuring/object-basic/actual.js

var coords = [1, 2];

var x = __getKey(coords, "x"),
y = __getKey(coords, "y");

__callKey(console, "log", x, y); // babel-plugin-transform-es2015-for-of
__callKey2(console, "log", x, y); // babel-plugin-transform-es2015-for-of
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-for-of/test/fixtures/loose/let/actual.js


Expand All @@ -73,10 +109,10 @@ var _didIteratorError = false;
var _iteratorError = undefined;

try {
for (var _iterator = __callKey(arr, Symbol.iterator), _step; !(_iteratorNormalCompletion = __getKey(_step = __callKey(_iterator, "next"), "done")); _iteratorNormalCompletion = true) {
for (var _iterator = __callKey0(arr, Symbol.iterator), _step; !(_iteratorNormalCompletion = __getKey(_step = __callKey0(_iterator, "next"), "done")); _iteratorNormalCompletion = true) {
var _i = __getKey(_step, "value");

__callKey(console, "log", _i);
__callKey1(console, "log", _i);
} // babel-plugin-transform-es2015-parameters
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-parameters/test/fixtures/use-loose-option/default-array-destructuring/actual.js

Expand All @@ -86,7 +122,7 @@ try {
} finally {
try {
if (!_iteratorNormalCompletion && __getKey(_iterator, "return") != null) {
__callKey(_iterator, "return");
__callKey0(_iterator, "return");
}
} finally {
if (_didIteratorError) {
Expand All @@ -111,39 +147,39 @@ var obj2 = {
}; // babel-plugin-transform-es2015-spread
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-spread/test/fixtures/spread/single/actual.js

__callKey(console, "log", _toConsumableArray(foo)); // babel-plugin-transform-es2015-template-literals
__callKey1(console, "log", _toConsumableArray(foo)); // babel-plugin-transform-es2015-template-literals
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/tag/actual.js


function literal() {
var foo = bar(_templateObject, 42, __callKey(_, "foobar"));
var bar = bar(_templateObject2, 42, __callKey(_, "foobar"));
var baz = bar(_templateObject3, 42, __callKey(_, "baz"));
var foo = bar(_templateObject, 42, __callKey0(_, "foobar"));
var bar = bar(_templateObject2, 42, __callKey0(_, "foobar"));
var baz = bar(_templateObject3, 42, __callKey0(_, "baz"));
return [foo, bar, baz];
} // babel-plugin-transform-es2015-typeof-symbol
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-typeof-symbol/test/fixtures/symbols/typeof/actual.js

var s = Symbol("s");

__callKey(assert, "ok", _typeof(s) === "symbol");
__callKey1(assert, "ok", _typeof(s) === "symbol");

__callKey(assert, "equal", _typeof(s), "symbol");
__callKey2(assert, "equal", _typeof(s), "symbol");

__callKey(assert, "equal", _typeof(_typeof(__getKey(s, "foo"))), "symbol");
__callKey2(assert, "equal", _typeof(_typeof(__getKey(s, "foo"))), "symbol");

var ts = typeof s === "string";

__callKey(assert, "isNotOk", (typeof o === "undefined" ? "undefined" : _typeof(o)) === "symbol");
__callKey1(assert, "isNotOk", (typeof o === "undefined" ? "undefined" : _typeof(o)) === "symbol");

__callKey(assert, "notEqual", typeof o === "undefined" ? "undefined" : _typeof(o), "symbol");
__callKey2(assert, "notEqual", typeof o === "undefined" ? "undefined" : _typeof(o), "symbol");

__callKey(assert, "notEqual", _typeof(_typeof(__getKey(o, "foo"))), "symbol"); // babel-plugin-transform-es2015-unicode-regex
__callKey2(assert, "notEqual", _typeof(_typeof(__getKey(o, "foo"))), "symbol"); // babel-plugin-transform-es2015-unicode-regex
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-unicode-regex/test/fixtures/unicode-regex/basic/actual.js

var string = "foo💩bar";

var match = __callKey(string, "match", /foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/);
__callKey(assert, "notEqual", string, match, ts); // babel-plugin-transform-async-to-generator
var match = __callKey1(string, "match", /foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/);
__callKey3(assert, "notEqual", string, match, ts); // babel-plugin-transform-async-to-generator
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/async/actual.js


Expand All @@ -159,9 +195,9 @@ function () {
value: function () {
var _foo = _asyncToGenerator(
/*#__PURE__*/
__callKey(_regeneratorRuntime, "mark", function _callee() {
__callKey1(_regeneratorRuntime, "mark", function _callee() {
var wat;
return __callKey(_regeneratorRuntime, "wrap", function _callee$(_context) {
return __callKey3(_regeneratorRuntime, "wrap", function _callee$(_context) {
while (1) {
switch (__setKey(_context, "prev", __getKey(_context, "next"))) {
case 0:
Expand All @@ -174,14 +210,14 @@ function () {

case 3:
case "end":
return __callKey(_context, "stop");
return __callKey0(_context, "stop");
}
}
}, _callee, this);
}));

return function foo() {
return __callKey(_foo, "apply", this, arguments);
return __callKey2(_foo, "apply", this, arguments);
};
}()
}]);
Expand All @@ -192,18 +228,18 @@ function () {


var num = 1;
num = __callKey(Math, "pow", num, 2);
num = __callKey2(Math, "pow", num, 2);

__callKey(console, "log", num); // babel-plugin-transform-object-rest-spread
__callKey1(console, "log", num); // babel-plugin-transform-object-rest-spread
// https://github.com/babel/babel/blob/6.x/packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-spread/assignment/actual.js


z = Object.assign({
z = _objectSpread({
x: x
}, y);
z = {
x: x,
w: Object.assign({}, y)
w: _objectSpread({}, y)
}; // babel-plugin-transform-class-properties
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-class-properties/test/fixtures/loose/instance/actual.js

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// babel-plugin-check-es2015-constants
// https://github.com/babel/babel/blob/master/packages/babel-plugin-check-es2015-constants/test/fixtures/general/program/actual.js
const MULTIPLIER = 5;
Expand Down Expand Up @@ -92,12 +94,12 @@ num **= 2;
console.log(num); // babel-plugin-transform-object-rest-spread
// https://github.com/babel/babel/blob/6.x/packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-spread/assignment/actual.js

z = Object.assign({
z = _objectSpread({
x
}, y);
z = {
x,
w: Object.assign({}, y)
w: _objectSpread({}, y)
}; // babel-plugin-transform-class-properties
// https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-class-properties/test/fixtures/loose/instance/actual.js

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define('x-class_and_template', ['proxy-compat/getKey', 'proxy-compat/setKey', 'proxy-compat/callKey', 'babel-compat/helpers/classCallCheck', 'babel-compat/helpers/createClass', 'babel-compat/helpers/possibleConstructorReturn', 'babel-compat/helpers/inherits', 'engine'], function (__getKey, __setKey, __callKey, _classCallCheck, _createClass, _possibleConstructorReturn, _inherits, engine) {
define('x-class_and_template', ['proxy-compat/getKey', 'proxy-compat/setKey', 'proxy-compat/callKey1', 'babel-compat/helpers/classCallCheck', 'babel-compat/helpers/createClass', 'babel-compat/helpers/possibleConstructorReturn', 'babel-compat/helpers/inherits', 'engine'], function (__getKey, __setKey, __callKey1, _classCallCheck, _createClass, _possibleConstructorReturn, _inherits, engine) {

var style = undefined;

Expand Down Expand Up @@ -28,7 +28,7 @@ function (_Element) {
var _this;
_classCallCheck(this, ClassAndTemplate);

_this = _possibleConstructorReturn(this, __callKey(__getKey(ClassAndTemplate, "__proto__") || Object.getPrototypeOf(ClassAndTemplate), "call", this));
_this = _possibleConstructorReturn(this, __callKey1(__getKey(ClassAndTemplate, "__proto__") || Object.getPrototypeOf(ClassAndTemplate), "call", this));

__setKey(_this, "t", Test);
__setKey(_this, "counter", 0);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions packages/lwc-compiler/src/__tests__/regression.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ const { fixturePath, readFixture, pretify } = require('./utils');
describe('resgression test', () => {
it('#743 - Object rest spread throwing', async () => {
const actual = `const base = { foo: true }; const res = { ...base, bar: false };`;
const expected = `const base = {
foo: true
};
const res = Object.assign({}, base, {
bar: false
});`;
const expected = `function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const base = {
foo: true
};
const res = _objectSpread({}, base, {
bar: false
});`;

const { code } = await compile('/x/foo/foo.js', {
sources: {
Expand Down
6 changes: 3 additions & 3 deletions packages/lwc-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
"sauce:prod_compat": "MODE=prod_compat yarn build:prod_compat && MODE=prod_compat wdio ./scripts/wdio.sauce.conf.js"
},
"devDependencies": {
"babel-preset-compat": "0.17.43",
"compat-polyfills": "0.17.43",
"babel-preset-compat": "0.18.2",
"compat-polyfills": "0.18.2",
"deepmerge": "^1.5.2",
"dotenv": "^4.0.0",
"fs-extra": "^4.0.2",
"http-server": "^0.10.0",
"lwc-compiler": "0.20.1",
"lwc-engine": "0.20.1",
"minimist": "^1.2.0",
"rollup-plugin-compat": "0.17.43",
"rollup-plugin-compat": "0.18.2",
"rollup-plugin-lwc-compiler": "0.20.1",
"wdio-junit-reporter": "^0.3.1",
"wdio-mocha-framework": "^0.5.10",
Expand Down
Loading

0 comments on commit c594e40

Please sign in to comment.