@babel/plugin-proposal-decorators 7.17.8 → 7.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,8 @@ var _pluginSyntaxDecorators = require("@babel/plugin-syntax-decorators");
11
11
 
12
12
  var _helperReplaceSupers = require("@babel/helper-replace-supers");
13
13
 
14
+ var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration");
15
+
14
16
  function incrementId(id, idx = id.length - 1) {
15
17
  if (idx === -1) {
16
18
  id.unshift(65);
@@ -204,7 +206,7 @@ function extractElementLocalAssignments(decorationInfo) {
204
206
  }
205
207
 
206
208
  function addCallAccessorsFor(element, key, getId, setId) {
207
- element.insertAfter(_core.types.classPrivateMethod("get", _core.types.cloneNode(key), [], _core.types.blockStatement([_core.types.expressionStatement(_core.types.callExpression(_core.types.cloneNode(getId), [_core.types.thisExpression()]))])));
209
+ element.insertAfter(_core.types.classPrivateMethod("get", _core.types.cloneNode(key), [], _core.types.blockStatement([_core.types.returnStatement(_core.types.callExpression(_core.types.cloneNode(getId), [_core.types.thisExpression()]))])));
208
210
  element.insertAfter(_core.types.classPrivateMethod("set", _core.types.cloneNode(key), [_core.types.identifier("v")], _core.types.blockStatement([_core.types.expressionStatement(_core.types.callExpression(_core.types.cloneNode(setId), [_core.types.thisExpression(), _core.types.identifier("v")]))])));
209
211
  }
210
212
 
@@ -261,13 +263,14 @@ function transformClass(path, state, constantSuper) {
261
263
  const {
262
264
  key,
263
265
  value,
264
- static: isStatic
266
+ static: isStatic,
267
+ computed
265
268
  } = element.node;
266
269
  const newId = generateClassPrivateUid();
267
270
  const valueNode = value ? _core.types.cloneNode(value) : undefined;
268
271
  const newField = generateClassProperty(newId, valueNode, isStatic);
269
272
  const [newPath] = element.replaceWith(newField);
270
- addProxyAccessorsFor(newPath, key, newId, element.node.computed);
273
+ addProxyAccessorsFor(newPath, key, newId, computed);
271
274
  }
272
275
  }
273
276
 
@@ -599,7 +602,7 @@ function transformClass(path, state, constantSuper) {
599
602
  }
600
603
 
601
604
  originalClass.body.body.unshift(_core.types.staticBlock([_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.arrayPattern(locals), _core.types.callExpression(state.addHelper("applyDecs"), [_core.types.thisExpression(), elementDecorations, classDecorations]))), requiresStaticInit && _core.types.expressionStatement(_core.types.callExpression(_core.types.cloneNode(staticInitLocal), [_core.types.thisExpression()]))].filter(Boolean)));
602
- path.insertBefore(assignments);
605
+ path.insertBefore(assignments.map(expr => _core.types.expressionStatement(expr)));
603
606
  path.scope.crawl();
604
607
  return path;
605
608
  }
@@ -619,22 +622,22 @@ function _default({
619
622
  name: "proposal-decorators",
620
623
  inherits: _pluginSyntaxDecorators.default,
621
624
  visitor: {
622
- ClassDeclaration(path, state) {
623
- if (VISITED.has(path)) return;
624
- const newPath = transformClass(path, state, constantSuper);
625
+ "ExportNamedDeclaration|ExportDefaultDeclaration"(path) {
626
+ var _declaration$decorato;
625
627
 
626
- if (newPath) {
627
- VISITED.add(newPath);
628
+ const {
629
+ declaration
630
+ } = path.node;
631
+
632
+ if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0) {
633
+ (0, _helperSplitExportDeclaration.default)(path);
628
634
  }
629
635
  },
630
636
 
631
- ClassExpression(path, state) {
637
+ Class(path, state) {
632
638
  if (VISITED.has(path)) return;
633
639
  const newPath = transformClass(path, state, constantSuper);
634
-
635
- if (newPath) {
636
- VISITED.add(newPath);
637
- }
640
+ if (newPath) VISITED.add(newPath);
638
641
  }
639
642
 
640
643
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/plugin-proposal-decorators",
3
- "version": "7.17.8",
3
+ "version": "7.18.2",
4
4
  "author": "The Babel Team (https://babel.dev/team)",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -20,19 +20,20 @@
20
20
  "decorators"
21
21
  ],
22
22
  "dependencies": {
23
- "@babel/helper-create-class-features-plugin": "^7.17.6",
24
- "@babel/helper-plugin-utils": "^7.16.7",
25
- "@babel/helper-replace-supers": "^7.16.7",
26
- "@babel/plugin-syntax-decorators": "^7.17.0",
23
+ "@babel/helper-create-class-features-plugin": "^7.18.0",
24
+ "@babel/helper-plugin-utils": "^7.17.12",
25
+ "@babel/helper-replace-supers": "^7.18.2",
26
+ "@babel/helper-split-export-declaration": "^7.16.7",
27
+ "@babel/plugin-syntax-decorators": "^7.17.12",
27
28
  "charcodes": "^0.2.0"
28
29
  },
29
30
  "peerDependencies": {
30
31
  "@babel/core": "^7.0.0-0"
31
32
  },
32
33
  "devDependencies": {
33
- "@babel/core": "^7.17.8",
34
+ "@babel/core": "^7.18.2",
34
35
  "@babel/helper-plugin-test-runner": "^7.16.7",
35
- "@babel/traverse": "^7.17.3",
36
+ "@babel/traverse": "^7.18.2",
36
37
  "babel-plugin-polyfill-es-shims": "^0.6.0",
37
38
  "object.getownpropertydescriptors": "^2.1.1"
38
39
  },