UNPKG

3.16 kBTypeScriptView Raw
1import * as ts from "typescript";
2import { TransformOperation } from "@ngtools/webpack/src/transformers";
3import { AngularCompilerPlugin } from "@ngtools/webpack";
4export declare function nsReplaceLazyLoader(getNgCompiler: () => AngularCompilerPlugin): ts.TransformerFactory<ts.SourceFile>;
5export declare function addArrayPropertyValueToNgModule(sourceFile: ts.SourceFile, targetPropertyName: string, newPropertyValueMatch: string, newPropertyValue: string): TransformOperation[];
6export declare function getConfigObjectSetupCode(configObjectName: string, targetPropertyName: string, newPropertyValueMatch: string, newPropertyValue: string): string;
7export declare const NgLazyLoaderCode = "\nvar nsNgCoreImport_Generated = require(\"@angular/core\");\nvar NSLazyModulesLoader_Generated = /** @class */ (function () {\n function NSLazyModulesLoader_Generated(_compiler, config) {\n this._compiler = _compiler;\n this._config = config || {\n factoryPathPrefix: '',\n factoryPathSuffix: '.ngfactory',\n };\n }\n NSLazyModulesLoader_Generated.prototype.load = function (path) {\n var offlineMode = this._compiler instanceof nsNgCoreImport_Generated.Compiler;\n return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);\n };\n NSLazyModulesLoader_Generated.prototype.loadAndCompile = function (path) {\n var _this = this;\n var _a = path.split('#'), module = _a[0], exportName = _a[1];\n if (exportName === undefined) {\n exportName = 'default';\n }\n return import(module)\n .then(function (module) { return module[exportName]; })\n .then(function (type) { return _this.checkNotEmpty(type, module, exportName); })\n .then(function (type) { return _this._compiler.compileModuleAsync(type); });\n };\n NSLazyModulesLoader_Generated.prototype.loadFactory = function (path) {\n var _this = this;\n var _a = path.split('#'), module = _a[0], exportName = _a[1];\n var factoryClassSuffix = 'NgFactory';\n if (exportName === undefined) {\n exportName = 'default';\n factoryClassSuffix = '';\n }\n return import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)\n .then(function (module) { return module[exportName + factoryClassSuffix]; })\n .then(function (factory) { return _this.checkNotEmpty(factory, module, exportName); });\n };\n NSLazyModulesLoader_Generated.prototype.checkNotEmpty = function (value, modulePath, exportName) {\n if (!value) {\n throw new Error(\"Cannot find '\" + exportName + \"' in '\" + modulePath + \"'\");\n }\n return value;\n };\n NSLazyModulesLoader_Generated = __decorate([\n nsNgCoreImport_Generated.Injectable(),\n __param(1, nsNgCoreImport_Generated.Optional()),\n __metadata(\"design:paramtypes\", [nsNgCoreImport_Generated.Compiler, nsNgCoreImport_Generated.SystemJsNgModuleLoaderConfig])\n ], NSLazyModulesLoader_Generated);\n return NSLazyModulesLoader_Generated;\n}());\n";