1 | import { Compiler, Injectable } from '@angular/core';
|
2 |
|
3 |
|
4 |
|
5 | var NgModuleLoader = (function () {
|
6 | |
7 |
|
8 |
|
9 | function NgModuleLoader(_compiler) {
|
10 | this._compiler = _compiler;
|
11 | }
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 | NgModuleLoader.prototype.load = function (modulePath, ngModuleExport) {
|
18 | var offlineMode = this._compiler instanceof Compiler;
|
19 | return offlineMode ? loadPrecompiledFactory(modulePath, ngModuleExport) : loadAndCompile(this._compiler, modulePath, ngModuleExport);
|
20 | };
|
21 | return NgModuleLoader;
|
22 | }());
|
23 | export { NgModuleLoader };
|
24 | NgModuleLoader.decorators = [
|
25 | { type: Injectable },
|
26 | ];
|
27 |
|
28 |
|
29 |
|
30 | NgModuleLoader.ctorParameters = function () { return [
|
31 | { type: Compiler, },
|
32 | ]; };
|
33 | function NgModuleLoader_tsickle_Closure_declarations() {
|
34 |
|
35 | NgModuleLoader.decorators;
|
36 | |
37 |
|
38 |
|
39 |
|
40 | NgModuleLoader.ctorParameters;
|
41 |
|
42 | NgModuleLoader.prototype._compiler;
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | function loadAndCompile(compiler, modulePath, ngModuleExport) {
|
51 | if (!ngModuleExport) {
|
52 | ngModuleExport = 'default';
|
53 | }
|
54 | return System.import(modulePath)
|
55 | .then(function (rawModule) {
|
56 | var module = rawModule[ngModuleExport];
|
57 | if (!module) {
|
58 | throw new Error("Module " + modulePath + " does not export " + ngModuleExport);
|
59 | }
|
60 | return compiler.compileModuleAsync(module);
|
61 | });
|
62 | }
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | function loadPrecompiledFactory(modulePath, ngModuleExport) {
|
69 | return System.import(modulePath)
|
70 | .then(function (rawModule) {
|
71 | var ngModuleFactory = rawModule[ngModuleExport];
|
72 | if (!ngModuleFactory) {
|
73 | throw new Error("Module " + modulePath + " does not export " + ngModuleExport);
|
74 | }
|
75 | return ngModuleFactory;
|
76 | });
|
77 | }
|
78 |
|
\ | No newline at end of file |