source: trip-planner-front/node_modules/@babel/preset-modules/lib/plugins/transform-edge-function-name/index.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5
6/**
7 * Edge 16 & 17 do not infer function.name from variable assignment.
8 * All other `function.name` behavior works fine, so we can skip most of @babel/transform-function-name.
9 * @see https://kangax.github.io/compat-table/es6/#test-function_name_property_variables_(function)
10 *
11 * Note: contrary to various Github issues, Edge 16+ *does* correctly infer the name of Arrow Functions.
12 * The variable declarator name inference issue only affects function expressions, so that's all we fix here.
13 *
14 * A Note on Minification: Terser undoes this transform *by default* unless `keep_fnames` is set to true.
15 * There is by design - if Function.name is critical to your application, you must configure
16 * your minifier to preserve function names.
17 */
18var _default = ({
19 types: t
20}) => ({
21 name: "transform-edge-function-name",
22 visitor: {
23 FunctionExpression: {
24 exit(path) {
25 if (!path.node.id && t.isIdentifier(path.parent.id)) {
26 const id = t.cloneNode(path.parent.id);
27 const binding = path.scope.getBinding(id.name); // if the binding gets reassigned anywhere, rename it
28
29 if (binding == null ? void 0 : binding.constantViolations.length) {
30 path.scope.rename(id.name);
31 }
32
33 path.node.id = id;
34 }
35 }
36
37 }
38 }
39});
40
41exports.default = _default;
42module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.