1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler-cli/ngcc/src/host/umd_host", ["require", "exports", "tslib", "typescript", "@angular/compiler-cli/src/ngtsc/file_system", "@angular/compiler-cli/src/ngtsc/reflection", "@angular/compiler-cli/ngcc/src/utils", "@angular/compiler-cli/ngcc/src/host/commonjs_umd_utils", "@angular/compiler-cli/ngcc/src/host/esm2015_host", "@angular/compiler-cli/ngcc/src/host/esm5_host", "@angular/compiler-cli/ngcc/src/host/utils"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.getImportsOfUmdModule = exports.parseStatementForUmdModule = exports.UmdReflectionHost = void 0;
|
---|
20 | var tslib_1 = require("tslib");
|
---|
21 | var ts = require("typescript");
|
---|
22 | var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
|
---|
23 | var reflection_1 = require("@angular/compiler-cli/src/ngtsc/reflection");
|
---|
24 | var utils_1 = require("@angular/compiler-cli/ngcc/src/utils");
|
---|
25 | var commonjs_umd_utils_1 = require("@angular/compiler-cli/ngcc/src/host/commonjs_umd_utils");
|
---|
26 | var esm2015_host_1 = require("@angular/compiler-cli/ngcc/src/host/esm2015_host");
|
---|
27 | var esm5_host_1 = require("@angular/compiler-cli/ngcc/src/host/esm5_host");
|
---|
28 | var utils_2 = require("@angular/compiler-cli/ngcc/src/host/utils");
|
---|
29 | var UmdReflectionHost = /** @class */ (function (_super) {
|
---|
30 | tslib_1.__extends(UmdReflectionHost, _super);
|
---|
31 | function UmdReflectionHost(logger, isCore, src, dts) {
|
---|
32 | if (dts === void 0) { dts = null; }
|
---|
33 | var _this = _super.call(this, logger, isCore, src, dts) || this;
|
---|
34 | _this.umdModules = new utils_1.FactoryMap(function (sf) { return _this.computeUmdModule(sf); });
|
---|
35 | _this.umdExports = new utils_1.FactoryMap(function (sf) { return _this.computeExportsOfUmdModule(sf); });
|
---|
36 | _this.umdImportPaths = new utils_1.FactoryMap(function (param) { return _this.computeImportPath(param); });
|
---|
37 | _this.program = src.program;
|
---|
38 | _this.compilerHost = src.host;
|
---|
39 | return _this;
|
---|
40 | }
|
---|
41 | UmdReflectionHost.prototype.getImportOfIdentifier = function (id) {
|
---|
42 | // Is `id` a namespaced property access, e.g. `Directive` in `core.Directive`?
|
---|
43 | // If so capture the symbol of the namespace, e.g. `core`.
|
---|
44 | var nsIdentifier = commonjs_umd_utils_1.findNamespaceOfIdentifier(id);
|
---|
45 | var importParameter = nsIdentifier && this.findUmdImportParameter(nsIdentifier);
|
---|
46 | var from = importParameter && this.getUmdImportPath(importParameter);
|
---|
47 | return from !== null ? { from: from, name: id.text } : null;
|
---|
48 | };
|
---|
49 | UmdReflectionHost.prototype.getDeclarationOfIdentifier = function (id) {
|
---|
50 | // First we try one of the following:
|
---|
51 | // 1. The `exports` identifier - referring to the current file/module.
|
---|
52 | // 2. An identifier (e.g. `foo`) that refers to an imported UMD module.
|
---|
53 | // 3. A UMD style export identifier (e.g. the `foo` of `exports.foo`).
|
---|
54 | var declaration = this.getExportsDeclaration(id) || this.getUmdModuleDeclaration(id) ||
|
---|
55 | this.getUmdDeclaration(id);
|
---|
56 | if (declaration !== null) {
|
---|
57 | return declaration;
|
---|
58 | }
|
---|
59 | // Try to get the declaration using the super class.
|
---|
60 | var superDeclaration = _super.prototype.getDeclarationOfIdentifier.call(this, id);
|
---|
61 | if (superDeclaration === null) {
|
---|
62 | return null;
|
---|
63 | }
|
---|
64 | // Check to see if the declaration is the inner node of a declaration IIFE.
|
---|
65 | var outerNode = esm2015_host_1.getOuterNodeFromInnerDeclaration(superDeclaration.node);
|
---|
66 | if (outerNode === null) {
|
---|
67 | return superDeclaration;
|
---|
68 | }
|
---|
69 | // We are only interested if the outer declaration is of the form
|
---|
70 | // `exports.<name> = <initializer>`.
|
---|
71 | if (!commonjs_umd_utils_1.isExportsAssignment(outerNode)) {
|
---|
72 | return superDeclaration;
|
---|
73 | }
|
---|
74 | return {
|
---|
75 | kind: 1 /* Inline */,
|
---|
76 | node: outerNode.left,
|
---|
77 | implementation: outerNode.right,
|
---|
78 | known: null,
|
---|
79 | viaModule: null,
|
---|
80 | };
|
---|
81 | };
|
---|
82 | UmdReflectionHost.prototype.getExportsOfModule = function (module) {
|
---|
83 | return _super.prototype.getExportsOfModule.call(this, module) || this.umdExports.get(module.getSourceFile());
|
---|
84 | };
|
---|
85 | UmdReflectionHost.prototype.getUmdModule = function (sourceFile) {
|
---|
86 | if (sourceFile.isDeclarationFile) {
|
---|
87 | return null;
|
---|
88 | }
|
---|
89 | return this.umdModules.get(sourceFile);
|
---|
90 | };
|
---|
91 | UmdReflectionHost.prototype.getUmdImportPath = function (importParameter) {
|
---|
92 | return this.umdImportPaths.get(importParameter);
|
---|
93 | };
|
---|
94 | /**
|
---|
95 | * Get the top level statements for a module.
|
---|
96 | *
|
---|
97 | * In UMD modules these are the body of the UMD factory function.
|
---|
98 | *
|
---|
99 | * @param sourceFile The module whose statements we want.
|
---|
100 | * @returns An array of top level statements for the given module.
|
---|
101 | */
|
---|
102 | UmdReflectionHost.prototype.getModuleStatements = function (sourceFile) {
|
---|
103 | var umdModule = this.getUmdModule(sourceFile);
|
---|
104 | return umdModule !== null ? Array.from(umdModule.factoryFn.body.statements) : [];
|
---|
105 | };
|
---|
106 | UmdReflectionHost.prototype.getClassSymbolFromOuterDeclaration = function (declaration) {
|
---|
107 | var superSymbol = _super.prototype.getClassSymbolFromOuterDeclaration.call(this, declaration);
|
---|
108 | if (superSymbol) {
|
---|
109 | return superSymbol;
|
---|
110 | }
|
---|
111 | if (!commonjs_umd_utils_1.isExportsDeclaration(declaration)) {
|
---|
112 | return undefined;
|
---|
113 | }
|
---|
114 | var initializer = commonjs_umd_utils_1.skipAliases(declaration.parent.right);
|
---|
115 | if (ts.isIdentifier(initializer)) {
|
---|
116 | var implementation = this.getDeclarationOfIdentifier(initializer);
|
---|
117 | if (implementation !== null) {
|
---|
118 | var implementationSymbol = this.getClassSymbol(implementation.node);
|
---|
119 | if (implementationSymbol !== null) {
|
---|
120 | return implementationSymbol;
|
---|
121 | }
|
---|
122 | }
|
---|
123 | }
|
---|
124 | var innerDeclaration = esm2015_host_1.getInnerClassDeclaration(initializer);
|
---|
125 | if (innerDeclaration !== null) {
|
---|
126 | return this.createClassSymbol(declaration.name, innerDeclaration);
|
---|
127 | }
|
---|
128 | return undefined;
|
---|
129 | };
|
---|
130 | UmdReflectionHost.prototype.getClassSymbolFromInnerDeclaration = function (declaration) {
|
---|
131 | var superClassSymbol = _super.prototype.getClassSymbolFromInnerDeclaration.call(this, declaration);
|
---|
132 | if (superClassSymbol !== undefined) {
|
---|
133 | return superClassSymbol;
|
---|
134 | }
|
---|
135 | if (!reflection_1.isNamedFunctionDeclaration(declaration)) {
|
---|
136 | return undefined;
|
---|
137 | }
|
---|
138 | var outerNode = esm2015_host_1.getOuterNodeFromInnerDeclaration(declaration);
|
---|
139 | if (outerNode === null || !commonjs_umd_utils_1.isExportsAssignment(outerNode)) {
|
---|
140 | return undefined;
|
---|
141 | }
|
---|
142 | return this.createClassSymbol(outerNode.left.name, declaration);
|
---|
143 | };
|
---|
144 | /**
|
---|
145 | * Extract all "classes" from the `statement` and add them to the `classes` map.
|
---|
146 | */
|
---|
147 | UmdReflectionHost.prototype.addClassSymbolsFromStatement = function (classes, statement) {
|
---|
148 | _super.prototype.addClassSymbolsFromStatement.call(this, classes, statement);
|
---|
149 | // Also check for exports of the form: `exports.<name> = <class def>;`
|
---|
150 | if (commonjs_umd_utils_1.isExportsStatement(statement)) {
|
---|
151 | var classSymbol = this.getClassSymbol(statement.expression.left);
|
---|
152 | if (classSymbol) {
|
---|
153 | classes.set(classSymbol.implementation, classSymbol);
|
---|
154 | }
|
---|
155 | }
|
---|
156 | };
|
---|
157 | /**
|
---|
158 | * Analyze the given statement to see if it corresponds with an exports declaration like
|
---|
159 | * `exports.MyClass = MyClass_1 = <class def>;`. If so, the declaration of `MyClass_1`
|
---|
160 | * is associated with the `MyClass` identifier.
|
---|
161 | *
|
---|
162 | * @param statement The statement that needs to be preprocessed.
|
---|
163 | */
|
---|
164 | UmdReflectionHost.prototype.preprocessStatement = function (statement) {
|
---|
165 | _super.prototype.preprocessStatement.call(this, statement);
|
---|
166 | if (!commonjs_umd_utils_1.isExportsStatement(statement)) {
|
---|
167 | return;
|
---|
168 | }
|
---|
169 | var declaration = statement.expression.left;
|
---|
170 | var initializer = statement.expression.right;
|
---|
171 | if (!esm2015_host_1.isAssignment(initializer) || !ts.isIdentifier(initializer.left) ||
|
---|
172 | !this.isClass(declaration)) {
|
---|
173 | return;
|
---|
174 | }
|
---|
175 | var aliasedIdentifier = initializer.left;
|
---|
176 | var aliasedDeclaration = this.getDeclarationOfIdentifier(aliasedIdentifier);
|
---|
177 | if (aliasedDeclaration === null || aliasedDeclaration.node === null) {
|
---|
178 | throw new Error("Unable to locate declaration of " + aliasedIdentifier.text + " in \"" + statement.getText() + "\"");
|
---|
179 | }
|
---|
180 | this.aliasedClassDeclarations.set(aliasedDeclaration.node, declaration.name);
|
---|
181 | };
|
---|
182 | UmdReflectionHost.prototype.computeUmdModule = function (sourceFile) {
|
---|
183 | if (sourceFile.statements.length !== 1) {
|
---|
184 | throw new Error("Expected UMD module file (" + sourceFile.fileName + ") to contain exactly one statement, " +
|
---|
185 | ("but found " + sourceFile.statements.length + "."));
|
---|
186 | }
|
---|
187 | return parseStatementForUmdModule(sourceFile.statements[0]);
|
---|
188 | };
|
---|
189 | UmdReflectionHost.prototype.computeExportsOfUmdModule = function (sourceFile) {
|
---|
190 | var e_1, _a, e_2, _b;
|
---|
191 | var moduleMap = new Map();
|
---|
192 | try {
|
---|
193 | for (var _c = tslib_1.__values(this.getModuleStatements(sourceFile)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
---|
194 | var statement = _d.value;
|
---|
195 | if (commonjs_umd_utils_1.isExportsStatement(statement)) {
|
---|
196 | var exportDeclaration = this.extractBasicUmdExportDeclaration(statement);
|
---|
197 | if (!moduleMap.has(exportDeclaration.name)) {
|
---|
198 | // We assume that the first `exports.<name>` is the actual declaration, and that any
|
---|
199 | // subsequent statements that match are decorating the original declaration.
|
---|
200 | // For example:
|
---|
201 | // ```
|
---|
202 | // exports.foo = <declaration>;
|
---|
203 | // exports.foo = __decorate(<decorator>, exports.foo);
|
---|
204 | // ```
|
---|
205 | // The declaration is the first line not the second.
|
---|
206 | moduleMap.set(exportDeclaration.name, exportDeclaration.declaration);
|
---|
207 | }
|
---|
208 | }
|
---|
209 | else if (commonjs_umd_utils_1.isWildcardReexportStatement(statement)) {
|
---|
210 | var reexports = this.extractUmdWildcardReexports(statement, sourceFile);
|
---|
211 | try {
|
---|
212 | for (var reexports_1 = (e_2 = void 0, tslib_1.__values(reexports)), reexports_1_1 = reexports_1.next(); !reexports_1_1.done; reexports_1_1 = reexports_1.next()) {
|
---|
213 | var reexport = reexports_1_1.value;
|
---|
214 | moduleMap.set(reexport.name, reexport.declaration);
|
---|
215 | }
|
---|
216 | }
|
---|
217 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
---|
218 | finally {
|
---|
219 | try {
|
---|
220 | if (reexports_1_1 && !reexports_1_1.done && (_b = reexports_1.return)) _b.call(reexports_1);
|
---|
221 | }
|
---|
222 | finally { if (e_2) throw e_2.error; }
|
---|
223 | }
|
---|
224 | }
|
---|
225 | else if (commonjs_umd_utils_1.isDefinePropertyReexportStatement(statement)) {
|
---|
226 | var exportDeclaration = this.extractUmdDefinePropertyExportDeclaration(statement);
|
---|
227 | if (exportDeclaration !== null) {
|
---|
228 | moduleMap.set(exportDeclaration.name, exportDeclaration.declaration);
|
---|
229 | }
|
---|
230 | }
|
---|
231 | }
|
---|
232 | }
|
---|
233 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
234 | finally {
|
---|
235 | try {
|
---|
236 | if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
---|
237 | }
|
---|
238 | finally { if (e_1) throw e_1.error; }
|
---|
239 | }
|
---|
240 | return moduleMap;
|
---|
241 | };
|
---|
242 | UmdReflectionHost.prototype.computeImportPath = function (param) {
|
---|
243 | var e_3, _a;
|
---|
244 | var umdModule = this.getUmdModule(param.getSourceFile());
|
---|
245 | if (umdModule === null) {
|
---|
246 | return null;
|
---|
247 | }
|
---|
248 | var imports = getImportsOfUmdModule(umdModule);
|
---|
249 | if (imports === null) {
|
---|
250 | return null;
|
---|
251 | }
|
---|
252 | var importPath = null;
|
---|
253 | try {
|
---|
254 | for (var imports_1 = tslib_1.__values(imports), imports_1_1 = imports_1.next(); !imports_1_1.done; imports_1_1 = imports_1.next()) {
|
---|
255 | var i = imports_1_1.value;
|
---|
256 | // Add all imports to the map to speed up future look ups.
|
---|
257 | this.umdImportPaths.set(i.parameter, i.path);
|
---|
258 | if (i.parameter === param) {
|
---|
259 | importPath = i.path;
|
---|
260 | }
|
---|
261 | }
|
---|
262 | }
|
---|
263 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
---|
264 | finally {
|
---|
265 | try {
|
---|
266 | if (imports_1_1 && !imports_1_1.done && (_a = imports_1.return)) _a.call(imports_1);
|
---|
267 | }
|
---|
268 | finally { if (e_3) throw e_3.error; }
|
---|
269 | }
|
---|
270 | return importPath;
|
---|
271 | };
|
---|
272 | UmdReflectionHost.prototype.extractBasicUmdExportDeclaration = function (statement) {
|
---|
273 | var _a;
|
---|
274 | var name = statement.expression.left.name.text;
|
---|
275 | var exportExpression = commonjs_umd_utils_1.skipAliases(statement.expression.right);
|
---|
276 | var declaration = (_a = this.getDeclarationOfExpression(exportExpression)) !== null && _a !== void 0 ? _a : {
|
---|
277 | kind: 1 /* Inline */,
|
---|
278 | node: statement.expression.left,
|
---|
279 | implementation: statement.expression.right,
|
---|
280 | known: null,
|
---|
281 | viaModule: null,
|
---|
282 | };
|
---|
283 | return { name: name, declaration: declaration };
|
---|
284 | };
|
---|
285 | UmdReflectionHost.prototype.extractUmdWildcardReexports = function (statement, containingFile) {
|
---|
286 | var reexportArg = statement.expression.arguments[0];
|
---|
287 | var requireCall = commonjs_umd_utils_1.isRequireCall(reexportArg) ?
|
---|
288 | reexportArg :
|
---|
289 | ts.isIdentifier(reexportArg) ? commonjs_umd_utils_1.findRequireCallReference(reexportArg, this.checker) : null;
|
---|
290 | var importPath = null;
|
---|
291 | if (requireCall !== null) {
|
---|
292 | importPath = requireCall.arguments[0].text;
|
---|
293 | }
|
---|
294 | else if (ts.isIdentifier(reexportArg)) {
|
---|
295 | var importParameter = this.findUmdImportParameter(reexportArg);
|
---|
296 | importPath = importParameter && this.getUmdImportPath(importParameter);
|
---|
297 | }
|
---|
298 | if (importPath === null) {
|
---|
299 | return [];
|
---|
300 | }
|
---|
301 | var importedFile = this.resolveModuleName(importPath, containingFile);
|
---|
302 | if (importedFile === undefined) {
|
---|
303 | return [];
|
---|
304 | }
|
---|
305 | var importedExports = this.getExportsOfModule(importedFile);
|
---|
306 | if (importedExports === null) {
|
---|
307 | return [];
|
---|
308 | }
|
---|
309 | var viaModule = utils_1.stripExtension(importedFile.fileName);
|
---|
310 | var reexports = [];
|
---|
311 | importedExports.forEach(function (decl, name) { return reexports.push({ name: name, declaration: tslib_1.__assign(tslib_1.__assign({}, decl), { viaModule: viaModule }) }); });
|
---|
312 | return reexports;
|
---|
313 | };
|
---|
314 | UmdReflectionHost.prototype.extractUmdDefinePropertyExportDeclaration = function (statement) {
|
---|
315 | var args = statement.expression.arguments;
|
---|
316 | var name = args[1].text;
|
---|
317 | var getterFnExpression = commonjs_umd_utils_1.extractGetterFnExpression(statement);
|
---|
318 | if (getterFnExpression === null) {
|
---|
319 | return null;
|
---|
320 | }
|
---|
321 | var declaration = this.getDeclarationOfExpression(getterFnExpression);
|
---|
322 | if (declaration !== null) {
|
---|
323 | return { name: name, declaration: declaration };
|
---|
324 | }
|
---|
325 | return {
|
---|
326 | name: name,
|
---|
327 | declaration: {
|
---|
328 | kind: 1 /* Inline */,
|
---|
329 | node: args[1],
|
---|
330 | implementation: getterFnExpression,
|
---|
331 | known: null,
|
---|
332 | viaModule: null,
|
---|
333 | },
|
---|
334 | };
|
---|
335 | };
|
---|
336 | /**
|
---|
337 | * Is the identifier a parameter on a UMD factory function, e.g. `function factory(this, core)`?
|
---|
338 | * If so then return its declaration.
|
---|
339 | */
|
---|
340 | UmdReflectionHost.prototype.findUmdImportParameter = function (id) {
|
---|
341 | var symbol = id && this.checker.getSymbolAtLocation(id) || null;
|
---|
342 | var declaration = symbol && symbol.valueDeclaration;
|
---|
343 | return declaration && ts.isParameter(declaration) ? declaration : null;
|
---|
344 | };
|
---|
345 | UmdReflectionHost.prototype.getUmdDeclaration = function (id) {
|
---|
346 | var nsIdentifier = commonjs_umd_utils_1.findNamespaceOfIdentifier(id);
|
---|
347 | if (nsIdentifier === null) {
|
---|
348 | return null;
|
---|
349 | }
|
---|
350 | if (nsIdentifier.parent.parent && commonjs_umd_utils_1.isExportsAssignment(nsIdentifier.parent.parent)) {
|
---|
351 | var initializer = nsIdentifier.parent.parent.right;
|
---|
352 | if (ts.isIdentifier(initializer)) {
|
---|
353 | return this.getDeclarationOfIdentifier(initializer);
|
---|
354 | }
|
---|
355 | return this.detectKnownDeclaration({
|
---|
356 | kind: 1 /* Inline */,
|
---|
357 | node: nsIdentifier.parent.parent.left,
|
---|
358 | implementation: commonjs_umd_utils_1.skipAliases(nsIdentifier.parent.parent.right),
|
---|
359 | viaModule: null,
|
---|
360 | known: null,
|
---|
361 | });
|
---|
362 | }
|
---|
363 | var moduleDeclaration = this.getUmdModuleDeclaration(nsIdentifier);
|
---|
364 | if (moduleDeclaration === null || moduleDeclaration.node === null ||
|
---|
365 | !ts.isSourceFile(moduleDeclaration.node)) {
|
---|
366 | return null;
|
---|
367 | }
|
---|
368 | var moduleExports = this.getExportsOfModule(moduleDeclaration.node);
|
---|
369 | if (moduleExports === null) {
|
---|
370 | return null;
|
---|
371 | }
|
---|
372 | // We need to compute the `viaModule` because the `getExportsOfModule()` call
|
---|
373 | // did not know that we were importing the declaration.
|
---|
374 | var declaration = moduleExports.get(id.text);
|
---|
375 | if (!moduleExports.has(id.text)) {
|
---|
376 | return null;
|
---|
377 | }
|
---|
378 | // We need to compute the `viaModule` because the `getExportsOfModule()` call
|
---|
379 | // did not know that we were importing the declaration.
|
---|
380 | var viaModule = declaration.viaModule === null ? moduleDeclaration.viaModule : declaration.viaModule;
|
---|
381 | return tslib_1.__assign(tslib_1.__assign({}, declaration), { viaModule: viaModule, known: utils_1.getTsHelperFnFromIdentifier(id) });
|
---|
382 | };
|
---|
383 | UmdReflectionHost.prototype.getExportsDeclaration = function (id) {
|
---|
384 | if (!isExportsIdentifier(id)) {
|
---|
385 | return null;
|
---|
386 | }
|
---|
387 | // Sadly, in the case of `exports.foo = bar`, we can't use `this.findUmdImportParameter(id)`
|
---|
388 | // to check whether this `exports` is from the IIFE body arguments, because
|
---|
389 | // `this.checker.getSymbolAtLocation(id)` will return the symbol for the `foo` identifier
|
---|
390 | // rather than the `exports` identifier.
|
---|
391 | //
|
---|
392 | // Instead we search the symbols in the current local scope.
|
---|
393 | var exportsSymbol = this.checker.getSymbolsInScope(id, ts.SymbolFlags.Variable)
|
---|
394 | .find(function (symbol) { return symbol.name === 'exports'; });
|
---|
395 | var node = (exportsSymbol === null || exportsSymbol === void 0 ? void 0 : exportsSymbol.valueDeclaration) !== undefined &&
|
---|
396 | !ts.isFunctionExpression(exportsSymbol.valueDeclaration.parent) ?
|
---|
397 | // There is a locally defined `exports` variable that is not a function parameter.
|
---|
398 | // So this `exports` identifier must be a local variable and does not represent the module.
|
---|
399 | exportsSymbol.valueDeclaration :
|
---|
400 | // There is no local symbol or it is a parameter of an IIFE.
|
---|
401 | // So this `exports` represents the current "module".
|
---|
402 | id.getSourceFile();
|
---|
403 | return {
|
---|
404 | kind: 0 /* Concrete */,
|
---|
405 | node: node,
|
---|
406 | viaModule: null,
|
---|
407 | known: null,
|
---|
408 | identity: null,
|
---|
409 | };
|
---|
410 | };
|
---|
411 | UmdReflectionHost.prototype.getUmdModuleDeclaration = function (id) {
|
---|
412 | var importPath = this.getImportPathFromParameter(id) || this.getImportPathFromRequireCall(id);
|
---|
413 | if (importPath === null) {
|
---|
414 | return null;
|
---|
415 | }
|
---|
416 | var module = this.resolveModuleName(importPath, id.getSourceFile());
|
---|
417 | if (module === undefined) {
|
---|
418 | return null;
|
---|
419 | }
|
---|
420 | var viaModule = commonjs_umd_utils_1.isExternalImport(importPath) ? importPath : null;
|
---|
421 | return { kind: 0 /* Concrete */, node: module, viaModule: viaModule, known: null, identity: null };
|
---|
422 | };
|
---|
423 | UmdReflectionHost.prototype.getImportPathFromParameter = function (id) {
|
---|
424 | var importParameter = this.findUmdImportParameter(id);
|
---|
425 | if (importParameter === null) {
|
---|
426 | return null;
|
---|
427 | }
|
---|
428 | return this.getUmdImportPath(importParameter);
|
---|
429 | };
|
---|
430 | UmdReflectionHost.prototype.getImportPathFromRequireCall = function (id) {
|
---|
431 | var requireCall = commonjs_umd_utils_1.findRequireCallReference(id, this.checker);
|
---|
432 | if (requireCall === null) {
|
---|
433 | return null;
|
---|
434 | }
|
---|
435 | return requireCall.arguments[0].text;
|
---|
436 | };
|
---|
437 | /**
|
---|
438 | * If this is an IIFE then try to grab the outer and inner classes otherwise fallback on the super
|
---|
439 | * class.
|
---|
440 | */
|
---|
441 | UmdReflectionHost.prototype.getDeclarationOfExpression = function (expression) {
|
---|
442 | var inner = esm2015_host_1.getInnerClassDeclaration(expression);
|
---|
443 | if (inner !== null) {
|
---|
444 | var outer = esm2015_host_1.getOuterNodeFromInnerDeclaration(inner);
|
---|
445 | if (outer !== null && commonjs_umd_utils_1.isExportsAssignment(outer)) {
|
---|
446 | return {
|
---|
447 | kind: 1 /* Inline */,
|
---|
448 | node: outer.left,
|
---|
449 | implementation: inner,
|
---|
450 | known: null,
|
---|
451 | viaModule: null,
|
---|
452 | };
|
---|
453 | }
|
---|
454 | }
|
---|
455 | return _super.prototype.getDeclarationOfExpression.call(this, expression);
|
---|
456 | };
|
---|
457 | UmdReflectionHost.prototype.resolveModuleName = function (moduleName, containingFile) {
|
---|
458 | if (this.compilerHost.resolveModuleNames) {
|
---|
459 | var moduleInfo = this.compilerHost.resolveModuleNames([moduleName], containingFile.fileName, undefined, undefined, this.program.getCompilerOptions())[0];
|
---|
460 | return moduleInfo && this.program.getSourceFile(file_system_1.absoluteFrom(moduleInfo.resolvedFileName));
|
---|
461 | }
|
---|
462 | else {
|
---|
463 | var moduleInfo = ts.resolveModuleName(moduleName, containingFile.fileName, this.program.getCompilerOptions(), this.compilerHost);
|
---|
464 | return moduleInfo.resolvedModule &&
|
---|
465 | this.program.getSourceFile(file_system_1.absoluteFrom(moduleInfo.resolvedModule.resolvedFileName));
|
---|
466 | }
|
---|
467 | };
|
---|
468 | return UmdReflectionHost;
|
---|
469 | }(esm5_host_1.Esm5ReflectionHost));
|
---|
470 | exports.UmdReflectionHost = UmdReflectionHost;
|
---|
471 | function parseStatementForUmdModule(statement) {
|
---|
472 | var wrapper = getUmdWrapper(statement);
|
---|
473 | if (wrapper === null)
|
---|
474 | return null;
|
---|
475 | var factoryFnParamIndex = wrapper.fn.parameters.findIndex(function (parameter) { return ts.isIdentifier(parameter.name) && parameter.name.text === 'factory'; });
|
---|
476 | if (factoryFnParamIndex === -1)
|
---|
477 | return null;
|
---|
478 | var factoryFn = utils_2.stripParentheses(wrapper.call.arguments[factoryFnParamIndex]);
|
---|
479 | if (!factoryFn || !ts.isFunctionExpression(factoryFn))
|
---|
480 | return null;
|
---|
481 | return { wrapperFn: wrapper.fn, factoryFn: factoryFn };
|
---|
482 | }
|
---|
483 | exports.parseStatementForUmdModule = parseStatementForUmdModule;
|
---|
484 | function getUmdWrapper(statement) {
|
---|
485 | if (!ts.isExpressionStatement(statement))
|
---|
486 | return null;
|
---|
487 | if (ts.isParenthesizedExpression(statement.expression) &&
|
---|
488 | ts.isCallExpression(statement.expression.expression) &&
|
---|
489 | ts.isFunctionExpression(statement.expression.expression.expression)) {
|
---|
490 | // (function () { ... } (...) );
|
---|
491 | var call = statement.expression.expression;
|
---|
492 | var fn = statement.expression.expression.expression;
|
---|
493 | return { call: call, fn: fn };
|
---|
494 | }
|
---|
495 | if (ts.isCallExpression(statement.expression) &&
|
---|
496 | ts.isParenthesizedExpression(statement.expression.expression) &&
|
---|
497 | ts.isFunctionExpression(statement.expression.expression.expression)) {
|
---|
498 | // (function () { ... }) (...);
|
---|
499 | var call = statement.expression;
|
---|
500 | var fn = statement.expression.expression.expression;
|
---|
501 | return { call: call, fn: fn };
|
---|
502 | }
|
---|
503 | return null;
|
---|
504 | }
|
---|
505 | function getImportsOfUmdModule(umdModule) {
|
---|
506 | var imports = [];
|
---|
507 | for (var i = 1; i < umdModule.factoryFn.parameters.length; i++) {
|
---|
508 | imports.push({
|
---|
509 | parameter: umdModule.factoryFn.parameters[i],
|
---|
510 | path: getRequiredModulePath(umdModule.wrapperFn, i)
|
---|
511 | });
|
---|
512 | }
|
---|
513 | return imports;
|
---|
514 | }
|
---|
515 | exports.getImportsOfUmdModule = getImportsOfUmdModule;
|
---|
516 | function getRequiredModulePath(wrapperFn, paramIndex) {
|
---|
517 | var statement = wrapperFn.body.statements[0];
|
---|
518 | if (!ts.isExpressionStatement(statement)) {
|
---|
519 | throw new Error('UMD wrapper body is not an expression statement:\n' + wrapperFn.body.getText());
|
---|
520 | }
|
---|
521 | var modulePaths = [];
|
---|
522 | findModulePaths(statement.expression);
|
---|
523 | // Since we were only interested in the `require()` calls, we miss the `exports` argument, so we
|
---|
524 | // need to subtract 1.
|
---|
525 | // E.g. `function(exports, dep1, dep2)` maps to `function(exports, require('path/to/dep1'),
|
---|
526 | // require('path/to/dep2'))`
|
---|
527 | return modulePaths[paramIndex - 1];
|
---|
528 | // Search the statement for calls to `require('...')` and extract the string value of the first
|
---|
529 | // argument
|
---|
530 | function findModulePaths(node) {
|
---|
531 | if (commonjs_umd_utils_1.isRequireCall(node)) {
|
---|
532 | var argument = node.arguments[0];
|
---|
533 | if (ts.isStringLiteral(argument)) {
|
---|
534 | modulePaths.push(argument.text);
|
---|
535 | }
|
---|
536 | }
|
---|
537 | else {
|
---|
538 | node.forEachChild(findModulePaths);
|
---|
539 | }
|
---|
540 | }
|
---|
541 | }
|
---|
542 | /**
|
---|
543 | * Is the `node` an identifier with the name "exports"?
|
---|
544 | */
|
---|
545 | function isExportsIdentifier(node) {
|
---|
546 | return ts.isIdentifier(node) && node.text === 'exports';
|
---|
547 | }
|
---|
548 | });
|
---|
549 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW1kX2hvc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci1jbGkvbmdjYy9zcmMvaG9zdC91bWRfaG9zdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7Ozs7O0lBRUgsK0JBQWlDO0lBRWpDLDJFQUE0RDtJQUU1RCx5RUFBK0c7SUFFL0csOERBQWlGO0lBRWpGLDZGQUFrWTtJQUNsWSxpRkFBd0c7SUFDeEcsMkVBQStDO0lBRS9DLG1FQUF5QztJQUV6QztRQUF1Qyw2Q0FBa0I7UUFVdkQsMkJBQVksTUFBYyxFQUFFLE1BQWUsRUFBRSxHQUFrQixFQUFFLEdBQThCO1lBQTlCLG9CQUFBLEVBQUEsVUFBOEI7WUFBL0YsWUFDRSxrQkFBTSxNQUFNLEV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