source: imaps-frontend/node_modules/@babel/core/lib/tools/build-external-helpers.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 4.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _default;
7function helpers() {
8 const data = require("@babel/helpers");
9 helpers = function () {
10 return data;
11 };
12 return data;
13}
14function _generator() {
15 const data = require("@babel/generator");
16 _generator = function () {
17 return data;
18 };
19 return data;
20}
21function _template() {
22 const data = require("@babel/template");
23 _template = function () {
24 return data;
25 };
26 return data;
27}
28function _t() {
29 const data = require("@babel/types");
30 _t = function () {
31 return data;
32 };
33 return data;
34}
35const {
36 arrayExpression,
37 assignmentExpression,
38 binaryExpression,
39 blockStatement,
40 callExpression,
41 cloneNode,
42 conditionalExpression,
43 exportNamedDeclaration,
44 exportSpecifier,
45 expressionStatement,
46 functionExpression,
47 identifier,
48 memberExpression,
49 objectExpression,
50 program,
51 stringLiteral,
52 unaryExpression,
53 variableDeclaration,
54 variableDeclarator
55} = _t();
56const buildUmdWrapper = replacements => _template().default.statement`
57 (function (root, factory) {
58 if (typeof define === "function" && define.amd) {
59 define(AMD_ARGUMENTS, factory);
60 } else if (typeof exports === "object") {
61 factory(COMMON_ARGUMENTS);
62 } else {
63 factory(BROWSER_ARGUMENTS);
64 }
65 })(UMD_ROOT, function (FACTORY_PARAMETERS) {
66 FACTORY_BODY
67 });
68 `(replacements);
69function buildGlobal(allowlist) {
70 const namespace = identifier("babelHelpers");
71 const body = [];
72 const container = functionExpression(null, [identifier("global")], blockStatement(body));
73 const tree = program([expressionStatement(callExpression(container, [conditionalExpression(binaryExpression("===", unaryExpression("typeof", identifier("global")), stringLiteral("undefined")), identifier("self"), identifier("global"))]))]);
74 body.push(variableDeclaration("var", [variableDeclarator(namespace, assignmentExpression("=", memberExpression(identifier("global"), namespace), objectExpression([])))]));
75 buildHelpers(body, namespace, allowlist);
76 return tree;
77}
78function buildModule(allowlist) {
79 const body = [];
80 const refs = buildHelpers(body, null, allowlist);
81 body.unshift(exportNamedDeclaration(null, Object.keys(refs).map(name => {
82 return exportSpecifier(cloneNode(refs[name]), identifier(name));
83 })));
84 return program(body, [], "module");
85}
86function buildUmd(allowlist) {
87 const namespace = identifier("babelHelpers");
88 const body = [];
89 body.push(variableDeclaration("var", [variableDeclarator(namespace, identifier("global"))]));
90 buildHelpers(body, namespace, allowlist);
91 return program([buildUmdWrapper({
92 FACTORY_PARAMETERS: identifier("global"),
93 BROWSER_ARGUMENTS: assignmentExpression("=", memberExpression(identifier("root"), namespace), objectExpression([])),
94 COMMON_ARGUMENTS: identifier("exports"),
95 AMD_ARGUMENTS: arrayExpression([stringLiteral("exports")]),
96 FACTORY_BODY: body,
97 UMD_ROOT: identifier("this")
98 })]);
99}
100function buildVar(allowlist) {
101 const namespace = identifier("babelHelpers");
102 const body = [];
103 body.push(variableDeclaration("var", [variableDeclarator(namespace, objectExpression([]))]));
104 const tree = program(body);
105 buildHelpers(body, namespace, allowlist);
106 body.push(expressionStatement(namespace));
107 return tree;
108}
109function buildHelpers(body, namespace, allowlist) {
110 const getHelperReference = name => {
111 return namespace ? memberExpression(namespace, identifier(name)) : identifier(`_${name}`);
112 };
113 const refs = {};
114 helpers().list.forEach(function (name) {
115 if (allowlist && !allowlist.includes(name)) return;
116 const ref = refs[name] = getHelperReference(name);
117 const {
118 nodes
119 } = helpers().get(name, getHelperReference, namespace ? null : `_${name}`, [], namespace ? (ast, exportName, mapExportBindingAssignments) => {
120 mapExportBindingAssignments(node => assignmentExpression("=", ref, node));
121 ast.body.push(expressionStatement(assignmentExpression("=", ref, identifier(exportName))));
122 } : null);
123 body.push(...nodes);
124 });
125 return refs;
126}
127function _default(allowlist, outputType = "global") {
128 let tree;
129 const build = {
130 global: buildGlobal,
131 module: buildModule,
132 umd: buildUmd,
133 var: buildVar
134 }[outputType];
135 if (build) {
136 tree = build(allowlist);
137 } else {
138 throw new Error(`Unsupported output type ${outputType}`);
139 }
140 return (0, _generator().default)(tree).code;
141}
1420 && 0;
143
144//# sourceMappingURL=build-external-helpers.js.map
Note: See TracBrowser for help on using the repository browser.