@babel/plugin-proposal-decorators 7.17.12 → 7.18.9

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
 
@@ -263,13 +263,14 @@ function transformClass(path, state, constantSuper) {
263
263
  const {
264
264
  key,
265
265
  value,
266
- static: isStatic
266
+ static: isStatic,
267
+ computed
267
268
  } = element.node;
268
269
  const newId = generateClassPrivateUid();
269
270
  const valueNode = value ? _core.types.cloneNode(value) : undefined;
270
271
  const newField = generateClassProperty(newId, valueNode, isStatic);
271
272
  const [newPath] = element.replaceWith(newField);
272
- addProxyAccessorsFor(newPath, key, newId, element.node.computed);
273
+ addProxyAccessorsFor(newPath, key, newId, computed);
273
274
  }
274
275
  }
275
276
 
@@ -406,7 +407,7 @@ function transformClass(path, state, constantSuper) {
406
407
  methodPath: element,
407
408
  objectRef: classLocal,
408
409
  superRef: path.node.superClass,
409
- file: state,
410
+ file: state.file,
410
411
  refToPreserve: classLocal
411
412
  });
412
413
  replaceSupers.replace();
@@ -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.17.12",
3
+ "version": "7.18.9",
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.17.12",
24
- "@babel/helper-plugin-utils": "^7.17.12",
25
- "@babel/helper-replace-supers": "^7.16.7",
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.9",
24
+ "@babel/helper-plugin-utils": "^7.18.9",
25
+ "@babel/helper-replace-supers": "^7.18.9",
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.17.12",
35
- "@babel/helper-plugin-test-runner": "^7.16.7",
36
- "@babel/traverse": "^7.17.12",
37
- "babel-plugin-polyfill-es-shims": "^0.6.0",
33
+ "@babel/core": "^7.18.9",
34
+ "@babel/helper-plugin-test-runner": "^7.18.6",
35
+ "@babel/traverse": "^7.18.9",
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
  }