@babel/plugin-proposal-decorators 7.18.2 → 7.18.6

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.
package/lib/index.js CHANGED
@@ -17,8 +17,12 @@ var _transformer = require("./transformer-2021-12");
17
17
 
18
18
  var _default = (0, _helperPluginUtils.declare)((api, options) => {
19
19
  api.assertVersion(7);
20
+ {
21
+ var {
22
+ legacy
23
+ } = options;
24
+ }
20
25
  const {
21
- legacy,
22
26
  version
23
27
  } = options;
24
28
 
@@ -7,9 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  var _core = require("@babel/core");
9
9
 
10
- const buildClassDecorator = (0, _core.template)(`
10
+ const buildClassDecorator = _core.template.statement(`
11
11
  DECORATOR(CLASS_REF = INNER) || CLASS_REF;
12
12
  `);
13
+
13
14
  const buildClassPrototype = (0, _core.template)(`
14
15
  CLASS_REF.prototype;
15
16
  `);
@@ -29,7 +30,7 @@ const buildGetObjectInitializer = (0, _core.template)(`
29
30
  const WARNING_CALLS = new WeakSet();
30
31
 
31
32
  function applyEnsureOrdering(path) {
32
- const decorators = (path.isClass() ? [path].concat(path.get("body.body")) : path.get("properties")).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []);
33
+ const decorators = (path.isClass() ? [path, ...path.get("body.body")] : path.get("properties")).reduce((acc, prop) => acc.concat(prop.node.decorators || []), []);
33
34
  const identDecorators = decorators.filter(decorator => !_core.types.isIdentifier(decorator.expression));
34
35
  if (identDecorators.length === 0) return;
35
36
  return _core.types.sequenceExpression(identDecorators.map(decorator => {
@@ -72,14 +73,19 @@ function hasMethodDecorators(body) {
72
73
 
73
74
  function applyObjectDecorators(path, state) {
74
75
  if (!hasMethodDecorators(path.node.properties)) return;
75
- return applyTargetDecorators(path, state, path.node.properties);
76
+ return applyTargetDecorators(path, state, path.node.properties.filter(prop => prop.type !== "SpreadElement"));
76
77
  }
77
78
 
78
79
  function applyTargetDecorators(path, state, decoratedProps) {
79
80
  const name = path.scope.generateDeclaredUidIdentifier(path.isClass() ? "class" : "obj");
80
81
  const exprs = decoratedProps.reduce(function (acc, node) {
81
- const decorators = node.decorators || [];
82
- node.decorators = null;
82
+ let decorators = [];
83
+
84
+ if (node.decorators != null) {
85
+ decorators = node.decorators;
86
+ node.decorators = null;
87
+ }
88
+
83
89
  if (decorators.length === 0) return acc;
84
90
 
85
91
  if (node.computed) {
@@ -129,7 +135,7 @@ function decoratedClassToExpression({
129
135
  return _core.types.variableDeclaration("let", [_core.types.variableDeclarator(ref, _core.types.toExpression(node))]);
130
136
  }
131
137
 
132
- var _default = {
138
+ const visitor = {
133
139
  ExportDefaultDeclaration(path) {
134
140
  const decl = path.get("declaration");
135
141
  if (!decl.isClassDeclaration()) return;
@@ -179,4 +185,5 @@ var _default = {
179
185
  }
180
186
 
181
187
  };
188
+ var _default = visitor;
182
189
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/plugin-proposal-decorators",
3
- "version": "7.18.2",
3
+ "version": "7.18.6",
4
4
  "author": "The Babel Team (https://babel.dev/team)",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -20,24 +20,26 @@
20
20
  "decorators"
21
21
  ],
22
22
  "dependencies": {
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",
28
- "charcodes": "^0.2.0"
23
+ "@babel/helper-create-class-features-plugin": "^7.18.6",
24
+ "@babel/helper-plugin-utils": "^7.18.6",
25
+ "@babel/helper-replace-supers": "^7.18.6",
26
+ "@babel/helper-split-export-declaration": "^7.18.6",
27
+ "@babel/plugin-syntax-decorators": "^7.18.6"
29
28
  },
30
29
  "peerDependencies": {
31
30
  "@babel/core": "^7.0.0-0"
32
31
  },
33
32
  "devDependencies": {
34
- "@babel/core": "^7.18.2",
35
- "@babel/helper-plugin-test-runner": "^7.16.7",
36
- "@babel/traverse": "^7.18.2",
37
- "babel-plugin-polyfill-es-shims": "^0.6.0",
33
+ "@babel/core": "^7.18.6",
34
+ "@babel/helper-plugin-test-runner": "^7.18.6",
35
+ "@babel/traverse": "^7.18.6",
36
+ "@types/charcodes": "^0.2.0",
37
+ "babel-plugin-polyfill-es-shims": "^0.6.1",
38
+ "charcodes": "^0.2.0",
38
39
  "object.getownpropertydescriptors": "^2.1.1"
39
40
  },
40
41
  "engines": {
41
42
  "node": ">=6.9.0"
42
- }
43
+ },
44
+ "type": "commonjs"
43
45
  }