Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Babylon plugins for features already merged to the ECMAScript spec #8448

Merged
merged 3 commits into from Nov 5, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,16 +1,6 @@
// @flow

const pluginNameMap = {
asyncGenerators: {
syntax: {
name: "@babel/plugin-syntax-async-generators",
url: "https://git.io/vb4SY",
},
transform: {
name: "@babel/plugin-proposal-async-generator-functions",
url: "https://git.io/vb4yp",
},
},
classProperties: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
Expand Down Expand Up @@ -143,26 +133,6 @@ const pluginNameMap = {
url: "https://git.io/vb4yS",
},
},
objectRestSpread: {
syntax: {
name: "@babel/plugin-syntax-object-rest-spread",
url: "https://git.io/vb4y5",
},
transform: {
name: "@babel/plugin-proposal-object-rest-spread",
url: "https://git.io/vb4Ss",
},
},
optionalCatchBinding: {
syntax: {
name: "@babel/plugin-syntax-optional-catch-binding",
url: "https://git.io/vb4Sn",
},
transform: {
name: "@babel/plugin-proposal-optional-catch-binding",
url: "https://git.io/vb4SI",
},
},
optionalChaining: {
syntax: {
name: "@babel/plugin-syntax-optional-chaining",
Expand Down Expand Up @@ -203,6 +173,41 @@ const pluginNameMap = {
url: "https://git.io/vb4Sm",
},
},

// TODO: This plugins are now supported by default by @babel/parser: they can
// be removed from this list. Although removing them isn't a breaking change,
// it's better to keep a nice error message for users using older versions of
// the parser. They can be removed in Babel 8.
asyncGenerators: {
syntax: {
name: "@babel/plugin-syntax-async-generators",
url: "https://git.io/vb4SY",
},
transform: {
name: "@babel/plugin-proposal-async-generator-functions",
url: "https://git.io/vb4yp",
},
},
objectRestSpread: {
syntax: {
name: "@babel/plugin-syntax-object-rest-spread",
url: "https://git.io/vb4y5",
},
transform: {
name: "@babel/plugin-proposal-object-rest-spread",
url: "https://git.io/vb4Ss",
},
},
optionalCatchBinding: {
syntax: {
name: "@babel/plugin-syntax-optional-catch-binding",
url: "https://git.io/vb4Sn",
},
transform: {
name: "@babel/plugin-proposal-optional-catch-binding",
url: "https://git.io/vb4SI",
},
},
};

const getNameURLCombination = ({ name, url }) => `${name} (${url})`;
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/test/api.js
Expand Up @@ -769,10 +769,10 @@ describe("api", function() {
options,
function(err) {
expect(err.message).toMatch(
"Support for the experimental syntax 'asyncGenerators' isn't currently enabled (1:15):",
"Support for the experimental syntax 'logicalAssignment' isn't currently enabled (1:3):",
);
expect(err.message).toMatch(
"Add @babel/plugin-proposal-async-generator-functions (https://git.io/vb4yp) to the " +
"Add @babel/plugin-proposal-logical-assignment-operators (https://git.io/vAlRe) to the " +
"'plugins' section of your Babel config to enable transformation.",
);
done();
Expand Down
@@ -1,4 +1 @@
async function* agf() {
await 1;
yield 2;
}
a ||= 2;

This file was deleted.

@@ -1 +1 @@
{ "plugins": ["asyncGenerators", "classProperties"] }
{ "plugins": ["classProperties"] }

This file was deleted.

This file was deleted.

7 changes: 1 addition & 6 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -1322,7 +1322,6 @@ export default class ExpressionParser extends LValParser {
}

if (this.match(tt.ellipsis)) {
this.expectPlugin("objectRestSpread");
prop = this.parseSpread(isPattern ? { start: 0 } : undefined);
if (isPattern) {
this.toAssignable(prop, true, "object pattern");
Expand Down Expand Up @@ -1382,11 +1381,7 @@ export default class ExpressionParser extends LValParser {
prop.computed = false;
} else {
isAsync = true;
if (this.match(tt.star)) {
this.expectPlugin("asyncGenerators");
this.next();
isGenerator = true;
}
isGenerator = this.eat(tt.star);
this.parsePropertyName(prop);
}
} else {
Expand Down
11 changes: 1 addition & 10 deletions packages/babel-parser/src/parser/statement.js
Expand Up @@ -391,7 +391,6 @@ export default class StatementParser extends ExpressionParser {

let forAwait = false;
if (this.state.inAsync && this.isContextual("await")) {
this.expectPlugin("asyncGenerators");
forAwait = true;
this.next();
}
Expand Down Expand Up @@ -556,7 +555,6 @@ export default class StatementParser extends ExpressionParser {
this.checkLVal(clause.param, true, clashes, "catch clause");
this.expect(tt.parenR);
} else {
this.expectPlugin("optionalCatchBinding");
clause.param = null;
}
clause.body = this.parseBlock();
Expand Down Expand Up @@ -853,9 +851,6 @@ export default class StatementParser extends ExpressionParser {
this.initFunction(node, isAsync);

if (this.match(tt.star)) {
if (node.async) {
this.expectPlugin("asyncGenerators");
}
node.generator = true;
this.next();
}
Expand Down Expand Up @@ -1153,11 +1148,7 @@ export default class StatementParser extends ExpressionParser {
}
} else if (isSimple && key.name === "async" && !this.isLineTerminator()) {
// an async method
const isGenerator = this.match(tt.star);
if (isGenerator) {
this.expectPlugin("asyncGenerators");
this.next();
}
const isGenerator = this.eat(tt.star);

method.kind = "method";
// The so-called parsed name would have been "async": get the real name.
Expand Down
5 changes: 2 additions & 3 deletions packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -1070,7 +1070,6 @@ export default class Tokenizer extends LocationParser {
readString(quote: number): void {
let out = "",
chunkStart = ++this.state.pos;
const hasJsonStrings = this.hasPlugin("jsonStrings");
for (;;) {
if (this.state.pos >= this.input.length) {
this.raise(this.state.start, "Unterminated string constant");
Expand All @@ -1083,8 +1082,8 @@ export default class Tokenizer extends LocationParser {
out += this.readEscapedChar(false);
chunkStart = this.state.pos;
} else if (
hasJsonStrings &&
(ch === charCodes.lineSeparator || ch === charCodes.paragraphSeparator)
ch === charCodes.lineSeparator ||
ch === charCodes.paragraphSeparator
) {
++this.state.pos;
++this.state.curLine;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,3 +1,3 @@
{
"plugins": ["classPrivateMethods", "asyncGenerators"]
"plugins": ["classPrivateMethods"]
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.