source: trip-planner-front/node_modules/@schematics/angular/migrations/update-12/update-lazy-module-paths.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 3.2 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29const ts = __importStar(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
30function* visit(directory) {
31 for (const path of directory.subfiles) {
32 if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
33 const entry = directory.file(path);
34 if (entry) {
35 const content = entry.content;
36 if (content.includes('loadChildren')) {
37 const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
38 yield source;
39 }
40 }
41 }
42 }
43 for (const path of directory.subdirs) {
44 if (path === 'node_modules' || path.startsWith('.')) {
45 continue;
46 }
47 yield* visit(directory.dir(path));
48 }
49}
50function default_1() {
51 return (tree) => {
52 for (const sourceFile of visit(tree.root)) {
53 let recorder;
54 ts.forEachChild(sourceFile, function analyze(node) {
55 if (ts.isPropertyAssignment(node) &&
56 (ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
57 node.name.text === 'loadChildren' &&
58 ts.isStringLiteral(node.initializer)) {
59 const valueNode = node.initializer;
60 const parts = valueNode.text.split('#');
61 const path = parts[0];
62 const moduleName = parts[1] || 'default';
63 const fix = `() => import('${path}').then(m => m.${moduleName})`;
64 if (!recorder) {
65 recorder = tree.beginUpdate(sourceFile.fileName);
66 }
67 const index = valueNode.getStart();
68 const length = valueNode.getWidth();
69 recorder.remove(index, length).insertLeft(index, fix);
70 }
71 ts.forEachChild(node, analyze);
72 });
73 if (recorder) {
74 tree.commitUpdate(recorder);
75 }
76 }
77 };
78}
79exports.default = default_1;
Note: See TracBrowser for help on using the repository browser.