Last change
on this file since 1ad8e64 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 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = void 0;
|
---|
7 |
|
---|
8 | var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
---|
9 |
|
---|
10 | var _helperReplaceSupers = require("@babel/helper-replace-supers");
|
---|
11 |
|
---|
12 | var _core = require("@babel/core");
|
---|
13 |
|
---|
14 | function 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 |
|
---|
23 | var _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 |
|
---|
50 | exports.default = _default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.