Skip to content

Commit

Permalink
Enable class static blocks by default (#13713)
Browse files Browse the repository at this point in the history
* Remove classStaticBlock plugin

* Update tests

* Remove class static blocks from proposalPlugins

* Update tests

* Remove classStaticBlock from mapping for test262

* chore: update babel-types

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
  • Loading branch information
sosukesuzuki and JLHwung committed Oct 28, 2021
1 parent 99a3fef commit ddc45a5
Show file tree
Hide file tree
Showing 181 changed files with 179 additions and 114 deletions.
5 changes: 2 additions & 3 deletions packages/babel-compat-data/scripts/data/plugin-features.js
Expand Up @@ -163,12 +163,11 @@ const es2022 = {
],
},
"proposal-private-methods": "private class methods",
};

const shippedProposal = {
"proposal-class-static-block": "Class static initialization blocks",
};

const shippedProposal = {};

// Run plugins for modern features first
module.exports = Object.assign(
{},
Expand Down
@@ -1,4 +1,3 @@
{
"minified": true,
"plugins": ["classStaticBlock"]
"minified": true
}

This file was deleted.

1 change: 0 additions & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -1619,7 +1619,6 @@ export default class StatementParser extends ExpressionParser {
classBody: N.ClassBody,
member: N.StaticBlock & { decorators?: Array<N.Decorator> },
) {
this.expectPlugin("classStaticBlock", member.start);
// Start a new lexical scope
this.scope.enter(SCOPE_CLASS | SCOPE_STATIC_BLOCK | SCOPE_SUPER);
// Start a new scope with regard to loop labels
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,6 +1,3 @@
{
"plugins": [
"classStaticBlock",
["decorators", { "decoratorsBeforeExport": true }]
]
"plugins": [["decorators", { "decoratorsBeforeExport": true }]]
}
@@ -1,3 +1,3 @@
{
"plugins": ["classStaticBlock", "decorators-legacy"]
"plugins": ["decorators-legacy"]
}

This file was deleted.

This file was deleted.

@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:17)"
}
}
@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:19)"
}
}
@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:16)"
}
}
@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:18)"
}
}
@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:18)"
}
}
@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:17)"
}
}
@@ -1,12 +1,5 @@
{
"plugins": [
[
"classStaticBlock"
],
[
"typescript"
]
],
"plugins": ["typescript"],
"sourceType": "module",
"throws": "Unexpected token (2:18)"
}
}
@@ -1,4 +1,4 @@
{
"plugins": ["classStaticBlock", "typescript"],
"plugins": ["typescript"],
"sourceType": "module"
}
2 changes: 1 addition & 1 deletion packages/babel-parser/typings/babel-parser.d.ts
Expand Up @@ -125,7 +125,7 @@ export type ParserPlugin =
| "classPrivateMethods"
| "classPrivateProperties"
| "classProperties"
| "classStaticBlock"
| "classStaticBlock" // Enabled by default
| "decimal"
| "decorators"
| "decorators-legacy"
Expand Down
4 changes: 1 addition & 3 deletions packages/babel-preset-env/data/shipped-proposals.js
Expand Up @@ -2,9 +2,7 @@
// These mappings represent the syntax proposals that have been
// shipped by browsers, and are enabled by the `shippedProposals` option.

const proposalPlugins = new Set([
"proposal-class-static-block",
]);
const proposalPlugins = new Set();

// use intermediary object to enforce alphabetical key order
const pluginSyntaxObject = {
Expand Down
Expand Up @@ -16,6 +16,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { android, chrome < 94, edge, firefox < 93, ios, node, opera, safari, samsung }
proposal-private-property-in-object { android, chrome < 91, edge, firefox < 90, ios < 15, node, opera, safari < 15, samsung }
proposal-class-properties { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
proposal-private-methods { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
Expand Down
Expand Up @@ -16,6 +16,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { android, chrome < 94, edge, firefox < 93, ios, node, opera, safari, samsung }
proposal-private-property-in-object { android, chrome < 91, edge, firefox < 90, ios < 15, node, opera, safari < 15, samsung }
proposal-class-properties { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
proposal-private-methods { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { chrome < 94 }
proposal-private-property-in-object { chrome < 91 }
proposal-class-properties { chrome < 84 }
proposal-private-methods { chrome < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { chrome < 94 }
proposal-private-property-in-object { chrome < 91 }
proposal-class-properties { chrome < 84 }
proposal-private-methods { chrome < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { edge }
proposal-private-property-in-object { edge }
proposal-class-properties { edge < 84 }
proposal-private-methods { edge < 84 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { safari }
proposal-private-property-in-object { safari < 15 }
proposal-class-properties { safari < 15 }
proposal-private-methods { safari < 15 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { safari }
proposal-private-property-in-object { safari < 15 }
proposal-class-properties { safari < 15 }
proposal-private-methods { safari < 15 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { safari }
proposal-private-property-in-object { safari < 15 }
proposal-class-properties { safari < 15 }
proposal-private-methods { safari < 15 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { safari }
proposal-private-property-in-object { safari < 15 }
proposal-class-properties { safari < 15 }
proposal-private-methods { safari < 15 }
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { safari }
syntax-private-property-in-object
syntax-class-properties
syntax-numeric-separator
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { safari }
syntax-private-property-in-object
syntax-class-properties
syntax-numeric-separator
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { chrome < 94 }
proposal-private-property-in-object { chrome < 91 }
syntax-class-properties
syntax-numeric-separator
Expand Down
Expand Up @@ -8,6 +8,7 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-class-static-block { chrome < 94 }
proposal-private-property-in-object { chrome < 91 }
syntax-class-properties
syntax-numeric-separator
Expand Down
Expand Up @@ -16,6 +16,7 @@ Using targets:
Using modules transform: false

Using plugins:
proposal-class-static-block { android, chrome < 94, edge, firefox < 93, ios, node, opera, safari, samsung }
proposal-private-property-in-object { android, chrome < 91, edge, firefox < 90, ios < 15, node, opera, safari < 15, samsung }
proposal-class-properties { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
proposal-private-methods { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
Expand Down
Expand Up @@ -16,6 +16,7 @@ Using targets:
Using modules transform: false

Using plugins:
proposal-class-static-block { android, chrome < 94, edge, firefox < 93, ios, node, opera, safari, samsung }
proposal-private-property-in-object { android, chrome < 91, edge, firefox < 90, ios < 15, node, opera, safari < 15, samsung }
proposal-class-properties { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
proposal-private-methods { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
Expand Down

0 comments on commit ddc45a5

Please sign in to comment.