index.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var helperPluginUtils = require('@babel/helper-plugin-utils');
  4. var core = require('@babel/core');
  5. var pluginTransformParameters = require('@babel/plugin-transform-parameters');
  6. var helperCompilationTargets = require('@babel/helper-compilation-targets');
  7. var pluginTransformDestructuring = require('@babel/plugin-transform-destructuring');
  8. function shouldStoreRHSInTemporaryVariable(node) {
  9. if (!node) return false;
  10. if (node.type === "ArrayPattern") {
  11. const nonNullElements = node.elements.filter(element => element !== null && element.type !== "VoidPattern");
  12. if (nonNullElements.length > 1) return true;else return shouldStoreRHSInTemporaryVariable(nonNullElements[0]);
  13. } else if (node.type === "ObjectPattern") {
  14. const {
  15. properties
  16. } = node;
  17. if (properties.length > 1) return true;else if (properties.length === 0) return false;else {
  18. const firstProperty = properties[0];
  19. if (firstProperty.type === "ObjectProperty") {
  20. return shouldStoreRHSInTemporaryVariable(firstProperty.value);
  21. } else {
  22. return shouldStoreRHSInTemporaryVariable(firstProperty);
  23. }
  24. }
  25. } else if (node.type === "AssignmentPattern") {
  26. return shouldStoreRHSInTemporaryVariable(node.left);
  27. } else if (node.type === "RestElement") {
  28. if (node.argument.type === "Identifier") return true;
  29. return shouldStoreRHSInTemporaryVariable(node.argument);
  30. } else {
  31. return false;
  32. }
  33. }
  34. var compatData = {
  35. "Object.assign": {
  36. chrome: "49",
  37. opera: "36",
  38. edge: "13",
  39. firefox: "36",
  40. safari: "10",
  41. node: "6",
  42. deno: "1",
  43. ios: "10",
  44. samsung: "5",
  45. opera_mobile: "36",
  46. electron: "0.37"
  47. }
  48. };
  49. const node = core.types.identifier("a");
  50. const property = core.types.objectProperty(core.types.identifier("key"), node);
  51. const pattern = core.types.objectPattern([property]);
  52. var ZERO_REFS = core.types.isReferenced(node, property, pattern) ? 1 : 0;
  53. var index = helperPluginUtils.declare((api, opts) => {
  54. var _api$assumption, _api$assumption2, _api$assumption3, _api$assumption4;
  55. api.assertVersion("^7.0.0-0 || ^8.0.0-0 || >8.0.0-alpha <8.0.0-beta");
  56. const targets = api.targets();
  57. const supportsObjectAssign = !helperCompilationTargets.isRequired("Object.assign", targets, {
  58. compatData
  59. });
  60. const {
  61. useBuiltIns = supportsObjectAssign,
  62. loose = false
  63. } = opts;
  64. if (typeof loose !== "boolean") {
  65. throw new Error(".loose must be a boolean, or undefined");
  66. }
  67. const ignoreFunctionLength = (_api$assumption = api.assumption("ignoreFunctionLength")) != null ? _api$assumption : loose;
  68. const objectRestNoSymbols = (_api$assumption2 = api.assumption("objectRestNoSymbols")) != null ? _api$assumption2 : loose;
  69. const pureGetters = (_api$assumption3 = api.assumption("pureGetters")) != null ? _api$assumption3 : loose;
  70. const setSpreadProperties = (_api$assumption4 = api.assumption("setSpreadProperties")) != null ? _api$assumption4 : loose;
  71. function getExtendsHelper(file) {
  72. return useBuiltIns ? core.types.memberExpression(core.types.identifier("Object"), core.types.identifier("assign")) : file.addHelper("extends");
  73. }
  74. function* iterateObjectRestElement(path) {
  75. switch (path.type) {
  76. case "ArrayPattern":
  77. for (const elementPath of path.get("elements")) {
  78. if (elementPath.isRestElement()) {
  79. yield* iterateObjectRestElement(elementPath.get("argument"));
  80. } else {
  81. yield* iterateObjectRestElement(elementPath);
  82. }
  83. }
  84. break;
  85. case "ObjectPattern":
  86. for (const propertyPath of path.get("properties")) {
  87. if (propertyPath.isRestElement()) {
  88. yield propertyPath;
  89. } else {
  90. yield* iterateObjectRestElement(propertyPath.get("value"));
  91. }
  92. }
  93. break;
  94. case "AssignmentPattern":
  95. yield* iterateObjectRestElement(path.get("left"));
  96. break;
  97. }
  98. }
  99. function hasObjectRestElement(path) {
  100. const objectRestPatternIterator = iterateObjectRestElement(path);
  101. return !objectRestPatternIterator.next().done;
  102. }
  103. function visitObjectRestElements(path, visitor) {
  104. for (const restElementPath of iterateObjectRestElement(path)) {
  105. visitor(restElementPath);
  106. }
  107. }
  108. function hasSpread(node) {
  109. for (const prop of node.properties) {
  110. if (core.types.isSpreadElement(prop)) {
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. function extractNormalizedKeys(pattern) {
  117. const propsList = pattern.get("properties").map(p => p.node);
  118. const keys = [];
  119. let allPrimitives = true;
  120. let hasTemplateLiteral = false;
  121. for (const prop of propsList) {
  122. const key = prop.key;
  123. if (core.types.isIdentifier(key) && !prop.computed) {
  124. keys.push(core.types.stringLiteral(key.name));
  125. } else if (core.types.isTemplateLiteral(key)) {
  126. keys.push(core.types.cloneNode(key));
  127. hasTemplateLiteral = true;
  128. } else if (core.types.isLiteral(key)) {
  129. keys.push(core.types.stringLiteral(String(key.value)));
  130. } else {
  131. if (core.types.isAssignmentExpression(key) && core.types.isIdentifier(key.left)) {
  132. keys.push(core.types.cloneNode(key.left));
  133. } else {
  134. keys.push(core.types.cloneNode(key));
  135. }
  136. const keyToCheck = core.types.isAssignmentExpression(key) ? key.right : key;
  137. if (core.types.isMemberExpression(keyToCheck, {
  138. computed: false
  139. }) && core.types.isIdentifier(keyToCheck.object, {
  140. name: "Symbol"
  141. }) || core.types.isCallExpression(keyToCheck) && core.types.matchesPattern(keyToCheck.callee, "Symbol.for")) ; else {
  142. allPrimitives = false;
  143. }
  144. }
  145. }
  146. return {
  147. keys,
  148. allPrimitives,
  149. hasTemplateLiteral
  150. };
  151. }
  152. function replaceImpureComputedKeys(properties, scope) {
  153. const tempVariableDeclarations = [];
  154. for (const property of properties) {
  155. const keyExpression = property.get("key");
  156. if (keyExpression.isAssignmentExpression() && keyExpression.get("left").isIdentifier()) {
  157. const identName = keyExpression.node.left.name;
  158. if (scope.hasUid(identName)) {
  159. continue;
  160. }
  161. }
  162. if (property.node.computed && !keyExpression.isPure()) {
  163. const tempVariableName = scope.generateUidBasedOnNode(keyExpression.node);
  164. const tempVariableDeclaration = core.types.variableDeclarator(core.types.identifier(tempVariableName), keyExpression.node);
  165. tempVariableDeclarations.push(tempVariableDeclaration);
  166. keyExpression.replaceWith(core.types.identifier(tempVariableName));
  167. }
  168. }
  169. return tempVariableDeclarations;
  170. }
  171. function removeUnusedExcludedKeys(path) {
  172. const bindings = path.getOuterBindingIdentifierPaths();
  173. Object.keys(bindings).forEach(bindingName => {
  174. const bindingParentPath = bindings[bindingName].parentPath;
  175. if (path.scope.getBinding(bindingName).references > ZERO_REFS || !bindingParentPath.isObjectProperty()) {
  176. return;
  177. }
  178. bindingParentPath.remove();
  179. });
  180. }
  181. function collectComputedKeysInSourceOrder(destructuringPattern) {
  182. const computedProperties = [];
  183. function visitPattern(pattern) {
  184. if (pattern.isObjectPattern()) {
  185. const properties = pattern.get("properties");
  186. for (const property of properties) {
  187. if (property.isRestElement()) continue;
  188. if (property.node.computed) {
  189. computedProperties.push(property);
  190. }
  191. const nestedPattern = property.get("value");
  192. visitPattern(nestedPattern);
  193. }
  194. } else if (pattern.isArrayPattern()) {
  195. for (const element of pattern.get("elements")) {
  196. if (!element) continue;
  197. if (element.isRestElement()) {
  198. const restArgument = element.get("argument");
  199. visitPattern(restArgument);
  200. } else {
  201. visitPattern(element);
  202. }
  203. }
  204. } else if (pattern.isAssignmentPattern()) {
  205. visitPattern(pattern.get("left"));
  206. }
  207. }
  208. visitPattern(destructuringPattern);
  209. return computedProperties;
  210. }
  211. function createObjectRest(path, file, objRef) {
  212. const props = path.get("properties");
  213. const last = props[props.length - 1];
  214. core.types.assertRestElement(last.node);
  215. const restElement = core.types.cloneNode(last.node);
  216. last.remove();
  217. const impureComputedPropertyDeclarators = replaceImpureComputedKeys(path.get("properties"), path.scope);
  218. const {
  219. keys,
  220. allPrimitives,
  221. hasTemplateLiteral
  222. } = extractNormalizedKeys(path);
  223. if (keys.length === 0) {
  224. return [impureComputedPropertyDeclarators, restElement.argument, core.types.callExpression(getExtendsHelper(file), [core.types.objectExpression([]), core.types.sequenceExpression([core.types.callExpression(file.addHelper("objectDestructuringEmpty"), [core.types.cloneNode(objRef)]), core.types.cloneNode(objRef)])])];
  225. }
  226. let keyExpression;
  227. if (!allPrimitives) {
  228. keyExpression = core.types.callExpression(core.types.memberExpression(core.types.arrayExpression(keys), core.types.identifier("map")), [file.addHelper("toPropertyKey")]);
  229. } else {
  230. keyExpression = core.types.arrayExpression(keys);
  231. if (!hasTemplateLiteral && !core.types.isProgram(path.scope.block)) {
  232. const program = path.findParent(path => path.isProgram());
  233. const id = path.scope.generateUidIdentifier("excluded");
  234. program.scope.push({
  235. id,
  236. init: keyExpression,
  237. kind: "const"
  238. });
  239. keyExpression = core.types.cloneNode(id);
  240. }
  241. }
  242. return [impureComputedPropertyDeclarators, restElement.argument, core.types.callExpression(file.addHelper(`objectWithoutProperties${objectRestNoSymbols ? "Loose" : ""}`), [core.types.cloneNode(objRef), keyExpression])];
  243. }
  244. function replaceRestElement(parentPath, paramPath, container) {
  245. if (paramPath.isAssignmentPattern()) {
  246. replaceRestElement(parentPath, paramPath.get("left"), container);
  247. return;
  248. }
  249. if (paramPath.isArrayPattern() && hasObjectRestElement(paramPath)) {
  250. const elements = paramPath.get("elements");
  251. for (let i = 0; i < elements.length; i++) {
  252. replaceRestElement(parentPath, elements[i], container);
  253. }
  254. }
  255. if (paramPath.isObjectPattern() && hasObjectRestElement(paramPath)) {
  256. const uid = parentPath.scope.generateUidIdentifier("ref");
  257. const declar = core.types.variableDeclaration("let", [core.types.variableDeclarator(paramPath.node, uid)]);
  258. if (container) {
  259. container.push(declar);
  260. } else {
  261. parentPath.ensureBlock();
  262. parentPath.get("body").unshiftContainer("body", declar);
  263. }
  264. paramPath.replaceWith(core.types.cloneNode(uid));
  265. }
  266. }
  267. return {
  268. name: "transform-object-rest-spread",
  269. manipulateOptions: (_, parser) => parser.plugins.push("objectRestSpread"),
  270. visitor: {
  271. Function(path) {
  272. const params = path.get("params");
  273. const paramsWithRestElement = new Set();
  274. const idsInRestParams = new Set();
  275. for (let i = 0; i < params.length; ++i) {
  276. const param = params[i];
  277. if (hasObjectRestElement(param)) {
  278. paramsWithRestElement.add(i);
  279. for (const name of Object.keys(param.getBindingIdentifiers())) {
  280. idsInRestParams.add(name);
  281. }
  282. }
  283. }
  284. let idInRest = false;
  285. const IdentifierHandler = function (path, functionScope) {
  286. const name = path.node.name;
  287. if (path.scope.getBinding(name) === functionScope.getBinding(name) && idsInRestParams.has(name)) {
  288. idInRest = true;
  289. path.stop();
  290. }
  291. };
  292. let i;
  293. for (i = 0; i < params.length && !idInRest; ++i) {
  294. const param = params[i];
  295. if (!paramsWithRestElement.has(i)) {
  296. if (param.isReferencedIdentifier() || param.isBindingIdentifier()) {
  297. IdentifierHandler(param, path.scope);
  298. } else {
  299. param.traverse({
  300. "Scope|TypeAnnotation|TSTypeAnnotation": path => path.skip(),
  301. "ReferencedIdentifier|BindingIdentifier": IdentifierHandler
  302. }, path.scope);
  303. }
  304. }
  305. }
  306. if (!idInRest) {
  307. for (let i = 0; i < params.length; ++i) {
  308. const param = params[i];
  309. if (paramsWithRestElement.has(i)) {
  310. replaceRestElement(path, param);
  311. }
  312. }
  313. } else {
  314. const shouldTransformParam = idx => idx >= i - 1 || paramsWithRestElement.has(idx);
  315. pluginTransformParameters.convertFunctionParams(path, ignoreFunctionLength, shouldTransformParam, replaceRestElement);
  316. }
  317. },
  318. VariableDeclarator(path, file) {
  319. if (!path.get("id").isObjectPattern()) {
  320. return;
  321. }
  322. let insertionPath = path;
  323. const originalPath = path;
  324. if (hasObjectRestElement(path.get("id"))) {
  325. const destructuringPattern = originalPath.get("id");
  326. const propertiesWithComputedKeys = collectComputedKeysInSourceOrder(destructuringPattern);
  327. for (const property of propertiesWithComputedKeys) {
  328. const computedKeyExpression = property.get("key");
  329. if (computedKeyExpression.isAssignmentExpression() && computedKeyExpression.get("left").isIdentifier() && originalPath.scope.hasUid(computedKeyExpression.node.left.name)) {
  330. continue;
  331. }
  332. if (!computedKeyExpression.isPure()) {
  333. const tempVariableName = originalPath.scope.generateUidBasedOnNode(computedKeyExpression.node);
  334. const tempIdentifier = core.types.identifier(tempVariableName);
  335. originalPath.scope.push({
  336. id: tempIdentifier,
  337. kind: "var"
  338. });
  339. computedKeyExpression.replaceWith(core.types.assignmentExpression("=", core.types.cloneNode(tempIdentifier), computedKeyExpression.node));
  340. }
  341. }
  342. }
  343. visitObjectRestElements(path.get("id"), path => {
  344. if (shouldStoreRHSInTemporaryVariable(originalPath.node.id) && !core.types.isIdentifier(originalPath.node.init)) {
  345. const initRef = path.scope.generateUidIdentifierBasedOnNode(originalPath.node.init, "ref");
  346. originalPath.insertBefore(core.types.variableDeclarator(initRef, originalPath.node.init));
  347. originalPath.replaceWith(core.types.variableDeclarator(originalPath.node.id, core.types.cloneNode(initRef)));
  348. return;
  349. }
  350. let ref = originalPath.node.init;
  351. const refPropertyPath = [];
  352. let kind;
  353. path.findParent(path => {
  354. if (path.isObjectProperty()) {
  355. refPropertyPath.unshift(path);
  356. } else if (path.isVariableDeclarator()) {
  357. kind = path.parentPath.node.kind;
  358. return true;
  359. }
  360. });
  361. const impureObjRefComputedDeclarators = replaceImpureComputedKeys(refPropertyPath, path.scope);
  362. refPropertyPath.forEach(prop => {
  363. const keyPath = prop.get("key");
  364. let keyForMemberExpression = keyPath.node;
  365. if (core.types.isAssignmentExpression(keyPath.node)) {
  366. keyForMemberExpression = keyPath.node.left;
  367. }
  368. ref = core.types.memberExpression(ref, core.types.cloneNode(keyForMemberExpression), prop.node.computed || core.types.isLiteral(keyPath.node));
  369. });
  370. const objectPatternPath = path.parentPath;
  371. const [impureComputedPropertyDeclarators, argument, callExpression] = createObjectRest(objectPatternPath, file, ref);
  372. if (pureGetters) {
  373. removeUnusedExcludedKeys(objectPatternPath);
  374. }
  375. core.types.assertIdentifier(argument);
  376. insertionPath.insertBefore(impureComputedPropertyDeclarators);
  377. insertionPath.insertBefore(impureObjRefComputedDeclarators);
  378. insertionPath = insertionPath.insertAfter(core.types.variableDeclarator(argument, callExpression))[0];
  379. path.scope.registerBinding(kind, insertionPath);
  380. if (objectPatternPath.node.properties.length === 0) {
  381. objectPatternPath.findParent(path => path.isObjectProperty() || path.isVariableDeclarator()).remove();
  382. }
  383. });
  384. },
  385. ExportNamedDeclaration(path) {
  386. var _path$splitExportDecl;
  387. const declaration = path.get("declaration");
  388. if (!declaration.isVariableDeclaration()) return;
  389. const hasRest = declaration.get("declarations").some(path => hasObjectRestElement(path.get("id")));
  390. if (!hasRest) return;
  391. (_path$splitExportDecl = path.splitExportDeclaration) != null ? _path$splitExportDecl : path.splitExportDeclaration = require("@babel/traverse").NodePath.prototype.splitExportDeclaration;
  392. path.splitExportDeclaration();
  393. },
  394. CatchClause(path) {
  395. const paramPath = path.get("param");
  396. replaceRestElement(path, paramPath);
  397. },
  398. AssignmentExpression(path, file) {
  399. const leftPath = path.get("left");
  400. if (leftPath.isObjectPattern() && hasObjectRestElement(leftPath)) {
  401. const nodes = [];
  402. const refName = path.scope.generateUidBasedOnNode(path.node.right, "ref");
  403. nodes.push(core.types.variableDeclaration("var", [core.types.variableDeclarator(core.types.identifier(refName), path.node.right)]));
  404. const [impureComputedPropertyDeclarators, argument, callExpression] = createObjectRest(leftPath, file, core.types.identifier(refName));
  405. if (impureComputedPropertyDeclarators.length > 0) {
  406. nodes.push(core.types.variableDeclaration("var", impureComputedPropertyDeclarators));
  407. }
  408. const nodeWithoutSpread = core.types.cloneNode(path.node);
  409. nodeWithoutSpread.right = core.types.identifier(refName);
  410. nodes.push(core.types.expressionStatement(nodeWithoutSpread));
  411. nodes.push(core.types.expressionStatement(core.types.assignmentExpression("=", argument, callExpression)));
  412. nodes.push(core.types.expressionStatement(core.types.identifier(refName)));
  413. path.replaceWithMultiple(nodes);
  414. }
  415. },
  416. ForXStatement(path) {
  417. const {
  418. node,
  419. scope
  420. } = path;
  421. const leftPath = path.get("left");
  422. if (!leftPath.isVariableDeclaration()) {
  423. if (!hasObjectRestElement(leftPath)) {
  424. return;
  425. }
  426. const temp = scope.generateUidIdentifier("ref");
  427. node.left = core.types.variableDeclaration("var", [core.types.variableDeclarator(temp)]);
  428. path.ensureBlock();
  429. const statementBody = path.node.body.body;
  430. const nodes = [];
  431. if (statementBody.length === 0 && path.isCompletionRecord()) {
  432. nodes.unshift(core.types.expressionStatement(scope.buildUndefinedNode()));
  433. }
  434. nodes.unshift(core.types.expressionStatement(core.types.assignmentExpression("=", leftPath.node, core.types.cloneNode(temp))));
  435. pluginTransformDestructuring.unshiftForXStatementBody(path, nodes);
  436. scope.crawl();
  437. return;
  438. } else {
  439. const patternPath = leftPath.get("declarations")[0].get("id");
  440. if (!hasObjectRestElement(patternPath)) {
  441. return;
  442. }
  443. const left = leftPath.node;
  444. const pattern = patternPath.node;
  445. const key = scope.generateUidIdentifier("ref");
  446. node.left = core.types.variableDeclaration(left.kind, [core.types.variableDeclarator(key, null)]);
  447. path.ensureBlock();
  448. pluginTransformDestructuring.unshiftForXStatementBody(path, [core.types.variableDeclaration(node.left.kind, [core.types.variableDeclarator(pattern, core.types.cloneNode(key))])]);
  449. scope.crawl();
  450. return;
  451. }
  452. },
  453. ArrayPattern(path) {
  454. const objectPatterns = [];
  455. const {
  456. scope
  457. } = path;
  458. const uidIdentifiers = [];
  459. visitObjectRestElements(path, path => {
  460. const objectPattern = path.parentPath;
  461. const uid = scope.generateUidIdentifier("ref");
  462. objectPatterns.push({
  463. left: objectPattern.node,
  464. right: uid
  465. });
  466. uidIdentifiers.push(uid);
  467. objectPattern.replaceWith(core.types.cloneNode(uid));
  468. path.skip();
  469. });
  470. if (objectPatterns.length > 0) {
  471. const patternParentPath = path.findParent(path => !(path.isPattern() || path.isObjectProperty()));
  472. const patternParent = patternParentPath.node;
  473. switch (patternParent.type) {
  474. case "VariableDeclarator":
  475. patternParentPath.insertAfter(objectPatterns.map(({
  476. left,
  477. right
  478. }) => core.types.variableDeclarator(left, right)));
  479. break;
  480. case "AssignmentExpression":
  481. {
  482. for (const uidIdentifier of uidIdentifiers) {
  483. scope.push({
  484. id: core.types.cloneNode(uidIdentifier)
  485. });
  486. }
  487. patternParentPath.insertAfter(objectPatterns.map(({
  488. left,
  489. right
  490. }) => core.types.assignmentExpression("=", left, right)));
  491. }
  492. break;
  493. default:
  494. throw new Error(`Unexpected pattern parent type: ${patternParent.type}`);
  495. }
  496. }
  497. },
  498. ObjectExpression(path, file) {
  499. if (!hasSpread(path.node)) return;
  500. let helper;
  501. if (setSpreadProperties) {
  502. helper = getExtendsHelper(file);
  503. } else {
  504. try {
  505. helper = file.addHelper("objectSpread2");
  506. } catch (_unused) {
  507. this.file.declarations.objectSpread2 = null;
  508. helper = file.addHelper("objectSpread");
  509. }
  510. }
  511. let exp = null;
  512. let props = [];
  513. function make() {
  514. const hadProps = props.length > 0;
  515. const obj = core.types.objectExpression(props);
  516. props = [];
  517. if (!exp) {
  518. exp = core.types.callExpression(helper, [obj]);
  519. return;
  520. }
  521. if (pureGetters) {
  522. if (hadProps) {
  523. exp.arguments.push(obj);
  524. }
  525. return;
  526. }
  527. exp = core.types.callExpression(core.types.cloneNode(helper), [exp, ...(hadProps ? [core.types.objectExpression([]), obj] : [])]);
  528. }
  529. for (const prop of path.node.properties) {
  530. if (core.types.isSpreadElement(prop)) {
  531. make();
  532. exp.arguments.push(prop.argument);
  533. } else {
  534. props.push(prop);
  535. }
  536. }
  537. if (props.length) make();
  538. path.replaceWith(exp);
  539. }
  540. }
  541. };
  542. });
  543. exports.default = index;
  544. //# sourceMappingURL=index.js.map