source: imaps-frontend/node_modules/@babel/plugin-bugfix-safari-class-field-initializer-scope/lib/index.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.2 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var helperPluginUtils = require('@babel/helper-plugin-utils');
6var core = require('@babel/core');
7
8function needsWrapping(node) {
9 if (core.types.isLiteral(node) && !core.types.isTemplateLiteral(node)) {
10 return false;
11 }
12 if (core.types.isCallExpression(node) || core.types.isOptionalCallExpression(node) || core.types.isNewExpression(node)) {
13 return needsWrapping(node.callee) || node.arguments.some(needsWrapping);
14 }
15 if (core.types.isTemplateLiteral(node)) {
16 return node.expressions.some(needsWrapping);
17 }
18 if (core.types.isTaggedTemplateExpression(node)) {
19 return needsWrapping(node.tag) || needsWrapping(node.quasi);
20 }
21 if (core.types.isArrayExpression(node)) {
22 return node.elements.some(needsWrapping);
23 }
24 if (core.types.isObjectExpression(node)) {
25 return node.properties.some(prop => {
26 if (core.types.isObjectProperty(prop)) {
27 return needsWrapping(prop.value) || prop.computed && needsWrapping(prop.key);
28 }
29 if (core.types.isObjectMethod(prop)) {
30 return false;
31 }
32 return false;
33 });
34 }
35 if (core.types.isMemberExpression(node) || core.types.isOptionalMemberExpression(node)) {
36 return needsWrapping(node.object) || node.computed && needsWrapping(node.property);
37 }
38 if (core.types.isFunctionExpression(node) || core.types.isArrowFunctionExpression(node) || core.types.isClassExpression(node)) {
39 return false;
40 }
41 if (core.types.isThisExpression(node)) {
42 return false;
43 }
44 if (core.types.isSequenceExpression(node)) {
45 return node.expressions.some(needsWrapping);
46 }
47 return true;
48}
49function wrapInitializer(path) {
50 const {
51 value
52 } = path.node;
53 if (value && needsWrapping(value)) {
54 path.node.value = core.types.callExpression(core.types.arrowFunctionExpression([], value), []);
55 }
56}
57var index = helperPluginUtils.declare(api => {
58 api.assertVersion("^7.16.0");
59 return {
60 name: "plugin-bugfix-safari-class-field-initializer-scope",
61 visitor: {
62 ClassProperty(path) {
63 wrapInitializer(path);
64 },
65 ClassPrivateProperty(path) {
66 wrapInitializer(path);
67 }
68 }
69 };
70});
71
72exports.default = index;
73//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.