source: trip-planner-front/node_modules/@babel/plugin-transform-object-super/lib/index.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _helperPluginUtils = require("@babel/helper-plugin-utils");
9
10var _helperReplaceSupers = require("@babel/helper-replace-supers");
11
12var _core = require("@babel/core");
13
14function replacePropertySuper(path, getObjectRef, file) {
15 const replaceSupers = new _helperReplaceSupers.default({
16 getObjectRef: getObjectRef,
17 methodPath: path,
18 file: file
19 });
20 replaceSupers.replace();
21}
22
23var _default = (0, _helperPluginUtils.declare)(api => {
24 api.assertVersion(7);
25 return {
26 name: "transform-object-super",
27 visitor: {
28 ObjectExpression(path, state) {
29 let objectRef;
30
31 const getObjectRef = () => objectRef = objectRef || path.scope.generateUidIdentifier("obj");
32
33 path.get("properties").forEach(propPath => {
34 if (!propPath.isMethod()) return;
35 replacePropertySuper(propPath, getObjectRef, state);
36 });
37
38 if (objectRef) {
39 path.scope.push({
40 id: _core.types.cloneNode(objectRef)
41 });
42 path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(objectRef), path.node));
43 }
44 }
45
46 }
47 };
48});
49
50exports.default = _default;
Note: See TracBrowser for help on using the repository browser.