vue hello world项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
3.5 KiB

{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import type { FunctionExpression } from \"@babel/types\";\nimport type { NodePath } from \"@babel/traverse\";\n\n/**\n * Check whether a function expression can be affected by\n * https://bugs.webkit.org/show_bug.cgi?id=220517\n * @param path The function expression NodePath\n * @returns the name of function id if it should be transformed, otherwise returns false\n */\nexport function shouldTransform(\n path: NodePath<FunctionExpression>,\n): string | false {\n const { node } = path;\n const functionId = node.id;\n if (!functionId) return false;\n\n const name = functionId.name;\n // On collision, `getOwnBinding` returns the param binding\n // with the id binding be registered as constant violation\n const paramNameBinding = path.scope.getOwnBinding(name);\n if (paramNameBinding === undefined) {\n // Case 1: the function id is injected by babel-helper-name-function, which\n // assigns `NOT_LOCAL_BINDING` to the `functionId` and thus not registering id\n // in scope tracking\n // Case 2: the function id is injected by a third party plugin which does not update the\n // scope info\n return false;\n }\n if (paramNameBinding.kind !== \"param\") {\n // the function id does not reproduce in params\n return false;\n }\n\n if (paramNameBinding.identifier === paramNameBinding.path.node) {\n // the param binding is a simple parameter\n // e.g. (function a(a) {})\n return false;\n }\n\n return name;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport type { PluginPass } from \"@babel/core\";\nimport type { Visitor } from \"@babel/traverse\";\nimport { shouldTransform } from \"./util\";\n\nexport default declare(api => {\n api.assertVersion(\"^7.16.0\");\n\n return {\n name: \"plugin-bugfix-safari-id-destructuring-collision-in-function-expression\",\n\n visitor: {\n FunctionExpression(path) {\n const name = shouldTransform(path);\n if (name) {\n // Now we have (function a([a]) {})\n const { scope } = path;\n // invariant: path.node.id is always an Identifier here\n const newParamName = scope.generateUid(name);\n scope.rename(name, newParamName);\n }\n },\n } as Visitor<PluginPass>,\n };\n});\n"],"names":["shouldTransform","path","node","functionId","id","name","paramNameBinding","scope","getOwnBinding","undefined","kind","identifier","declare","api","assertVersion","visitor","FunctionExpression","newParamName","generateUid","rename"],"mappings":";;;;;;AASO,SAASA,eAAT,CACLC,IADK,EAEW;AAChB,QAAM;AAAEC,IAAAA;AAAF,MAAWD,IAAjB;AACA,QAAME,UAAU,GAAGD,IAAI,CAACE,EAAxB;AACA,MAAI,CAACD,UAAL,EAAiB,OAAO,KAAP;AAEjB,QAAME,IAAI,GAAGF,UAAU,CAACE,IAAxB;AAGA,QAAMC,gBAAgB,GAAGL,IAAI,CAACM,KAAL,CAAWC,aAAX,CAAyBH,IAAzB,CAAzB;;AACA,MAAIC,gBAAgB,KAAKG,SAAzB,EAAoC;AAMlC,WAAO,KAAP;AACD;;AACD,MAAIH,gBAAgB,CAACI,IAAjB,KAA0B,OAA9B,EAAuC;AAErC,WAAO,KAAP;AACD;;AAED,MAAIJ,gBAAgB,CAACK,UAAjB,KAAgCL,gBAAgB,CAACL,IAAjB,CAAsBC,IAA1D,EAAgE;AAG9D,WAAO,KAAP;AACD;;AAED,SAAOG,IAAP;AACD;;ACnCD,YAAeO,yBAAO,CAACC,GAAG,IAAI;AAC5BA,EAAAA,GAAG,CAACC,aAAJ,CAAkB,SAAlB;AAEA,SAAO;AACLT,IAAAA,IAAI,EAAE,wEADD;AAGLU,IAAAA,OAAO,EAAE;AACPC,MAAAA,kBAAkB,CAACf,IAAD,EAAO;AACvB,cAAMI,IAAI,GAAGL,eAAe,CAACC,IAAD,CAA5B;;AACA,YAAII,IAAJ,EAAU;AAER,gBAAM;AAAEE,YAAAA;AAAF,cAAYN,IAAlB;AAEA,gBAAMgB,YAAY,GAAGV,KAAK,CAACW,WAAN,CAAkBb,IAAlB,CAArB;AACAE,UAAAA,KAAK,CAACY,MAAN,CAAad,IAAb,EAAmBY,YAAnB;AACD;AACF;;AAVM;AAHJ,GAAP;AAgBD,CAnBqB,CAAtB;;;;"}