fix(docs-infra): workaround for broken 'import as' (#27536)
It's unclear why `import as` results in the aliases to be undefined. Plain tsc seems to do the right thing and emits the correct code, so it might be some kind of interaction in @angular/cli or webpack that are causing the failure. This should be investigated separately from the tsc update in angular/angular. See angular/angular-cli#13212 PR Close #27536
This commit is contained in:
parent
2c9b6c0c1f
commit
cdfe8f4d69
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { from as fromPromise, Observable } from 'rxjs';
|
import { from, Observable } from 'rxjs';
|
||||||
import { first, map, share } from 'rxjs/operators';
|
import { first, map, share } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Logger } from 'app/shared/logger.service';
|
import { Logger } from 'app/shared/logger.service';
|
||||||
|
@ -20,7 +20,7 @@ export class PrettyPrinter {
|
||||||
private prettyPrintOne: Observable<PrettyPrintOne>;
|
private prettyPrintOne: Observable<PrettyPrintOne>;
|
||||||
|
|
||||||
constructor(private logger: Logger) {
|
constructor(private logger: Logger) {
|
||||||
this.prettyPrintOne = fromPromise(this.getPrettyPrintOne()).pipe(share());
|
this.prettyPrintOne = from(this.getPrettyPrintOne()).pipe(share());
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPrettyPrintOne(): Promise<PrettyPrintOne> {
|
private getPrettyPrintOne(): Promise<PrettyPrintOne> {
|
||||||
|
|
|
@ -5,9 +5,10 @@ import {
|
||||||
NgModuleRef,
|
NgModuleRef,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ELEMENT_MODULE_PATHS_TOKEN } from './element-registry';
|
import { ELEMENT_MODULE_PATHS_TOKEN } from './element-registry';
|
||||||
import { from as fromPromise, Observable, of } from 'rxjs';
|
import { from, Observable, of } from 'rxjs';
|
||||||
import { createCustomElement } from '@angular/elements';
|
import { createCustomElement } from '@angular/elements';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ElementsLoader {
|
export class ElementsLoader {
|
||||||
/** Map of unregistered custom elements and their respective module paths to load. */
|
/** Map of unregistered custom elements and their respective module paths to load. */
|
||||||
|
@ -34,7 +35,7 @@ export class ElementsLoader {
|
||||||
|
|
||||||
// Returns observable that completes when all discovered elements have been registered.
|
// Returns observable that completes when all discovered elements have been registered.
|
||||||
const allRegistered = Promise.all(unregisteredSelectors.map(s => this.loadCustomElement(s)));
|
const allRegistered = Promise.all(unregisteredSelectors.map(s => this.loadCustomElement(s)));
|
||||||
return fromPromise(allRegistered.then(() => undefined));
|
return from(allRegistered.then(() => undefined));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Loads and registers the custom element defined on the `WithCustomElement` module factory. */
|
/** Loads and registers the custom element defined on the `WithCustomElement` module factory. */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core';
|
||||||
import { asapScheduler as asap, combineLatest, Subject } from 'rxjs';
|
import { asapScheduler, combineLatest, Subject } from 'rxjs';
|
||||||
import { startWith, subscribeOn, takeUntil } from 'rxjs/operators';
|
import { startWith, subscribeOn, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ScrollService } from 'app/shared/scroll.service';
|
import { ScrollService } from 'app/shared/scroll.service';
|
||||||
|
@ -52,7 +52,7 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
// We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes,
|
// We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes,
|
||||||
// which, in turn, are caused by the rendering that happened due to a ChangeDetection.
|
// which, in turn, are caused by the rendering that happened due to a ChangeDetection.
|
||||||
// Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular.
|
// Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular.
|
||||||
combineLatest(this.tocService.activeItemIndex.pipe(subscribeOn(asap)), this.items.changes.pipe(startWith(this.items)))
|
combineLatest(this.tocService.activeItemIndex.pipe(subscribeOn(asapScheduler)), this.items.changes.pipe(startWith(this.items)))
|
||||||
.pipe(takeUntil(this.onDestroy))
|
.pipe(takeUntil(this.onDestroy))
|
||||||
.subscribe(([index, items]) => {
|
.subscribe(([index, items]) => {
|
||||||
this.activeIndex = index;
|
this.activeIndex = index;
|
||||||
|
|
Loading…
Reference in New Issue