Compile classes when spread is unsupported (#13075)
This commit is contained in:
parent
3e174e9cbd
commit
d563773723
@ -320,7 +320,7 @@
|
||||
"chrome": "46",
|
||||
"opera": "33",
|
||||
"edge": "13",
|
||||
"firefox": "36",
|
||||
"firefox": "45",
|
||||
"safari": "10",
|
||||
"node": "5",
|
||||
"ios": "10",
|
||||
|
||||
@ -72,7 +72,14 @@ const es2015 = {
|
||||
],
|
||||
},
|
||||
"transform-spread": {
|
||||
features: ["spread syntax for iterable objects"],
|
||||
features: [
|
||||
"spread syntax for iterable objects",
|
||||
// We need to compile classes when spread is not supported, because
|
||||
// we cannot compile super(...args) without also rewriting the
|
||||
// "super" handling. There is a bugfix that makes it better.
|
||||
"class",
|
||||
"super",
|
||||
],
|
||||
},
|
||||
"transform-destructuring": {
|
||||
features: ["destructuring, assignment", "destructuring, declarations"],
|
||||
|
||||
@ -88,7 +88,10 @@ exports.getLowestImplementedVersion = (
|
||||
};
|
||||
|
||||
exports.generateData = (environments, features) => {
|
||||
return Object.values(features).map(options => {
|
||||
const data = {};
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
for (let [key, options] of Object.entries(features)) {
|
||||
if (!options.features) {
|
||||
options = {
|
||||
features: [options],
|
||||
@ -103,8 +106,10 @@ exports.generateData = (environments, features) => {
|
||||
});
|
||||
addElectronSupportFromChromium(plugin);
|
||||
|
||||
return plugin;
|
||||
});
|
||||
data[key] = plugin;
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
exports.writeFile = function (data, dataPath, name) {
|
||||
|
||||
5
packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/input.js
vendored
Normal file
5
packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
class A extends B {
|
||||
constructor(args) {
|
||||
super(...args)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"targets": "firefox 40",
|
||||
"presets": ["env"]
|
||||
}
|
||||
14
packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/output.js
vendored
Normal file
14
packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/output.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
var A = /*#__PURE__*/function (_B) {
|
||||
"use strict";
|
||||
|
||||
babelHelpers.inherits(A, _B);
|
||||
|
||||
var _super = babelHelpers.createSuper(A);
|
||||
|
||||
function A(args) {
|
||||
babelHelpers.classCallCheck(this, A);
|
||||
return _super.call.apply(_super, [this].concat(babelHelpers.toConsumableArray(args)));
|
||||
}
|
||||
|
||||
return A;
|
||||
}(B);
|
||||
Loading…
x
Reference in New Issue
Block a user