Skip to content

Commit 24413e6

Browse files
authored
fix(application-loader): remove debug logs, fix preload app load component (#153)
1 parent d6df32e commit 24413e6

File tree

8 files changed

+25
-30
lines changed

8 files changed

+25
-30
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changelog
22
All notable changes to ngx-planet will be documented in this file.
33

4+
### [9.0.1-beta.6](https://github.com/worktile/ngx-planet/compare/9.0.1-beta.3...9.0.1-beta.6) (2020-12-10)
5+
6+
7+
### Bug Fixes
8+
9+
* **application-loader:** fix preload app load component not display ([0a3abd2](https://github.com/worktile/ngx-planet/commit/0a3abd2f139bf66ed08587f87477d201414ddffa))
10+
11+
### [9.0.1-beta.5](https://github.com/worktile/ngx-planet/compare/9.0.1-beta.3...9.0.1-beta.5) (2020-12-10)
12+
13+
14+
### Bug Fixes
15+
16+
* **application-loader:** fix preload app load component not display ([0a3abd2](https://github.com/worktile/ngx-planet/commit/0a3abd2f139bf66ed08587f87477d201414ddffa))
17+
418
### [9.0.1-beta.4](https://github.com/worktile/ngx-planet/compare/9.0.1-beta.3...9.0.1-beta.4) (2020-12-10)
519

620

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@worktile/planet",
3-
"version": "9.0.1-beta.4",
3+
"version": "9.0.1-beta.6",
44
"description": "A powerful, reliable, fully-featured and production ready Micro Frontend library for Angular.",
55
"keywords": [
66
"micro front-end",

packages/planet/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@worktile/planet",
3-
"version": "9.0.1-beta.4",
3+
"version": "9.0.1-beta.6",
44
"private": false,
55
"peerDependencies": {
66
"@angular/common": "^9.0.0",

packages/planet/src/application/planet-application-loader.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { of, Observable, Subject, forkJoin, from } from 'rxjs';
33
import { AssetsLoader } from '../assets-loader';
44
import { PlanetApplication, PlanetRouterEvent, SwitchModes, PlanetOptions } from '../planet.class';
55
import { switchMap, share, map, tap, distinctUntilChanged, take, filter, catchError } from 'rxjs/operators';
6-
import { getHTMLElement, coerceArray, createElementByTemplate, debug } from '../helpers';
6+
import { getHTMLElement, coerceArray, createElementByTemplate } from '../helpers';
77
import { PlanetApplicationRef } from './planet-application-ref';
88
import { PlanetPortalApplication } from './portal-application';
99
import { PlanetApplicationService } from './planet-application.service';
@@ -224,12 +224,12 @@ export class PlanetApplicationLoader {
224224
setTimeout(() => {
225225
// 此处判断是因为如果静态资源加载完毕还未启动被取消,还是会启动之前的应用,虽然可能性比较小,但是无法排除这种可能性,所以只有当 Event 是最后一个才会启动
226226
if (this.startRouteChangeEvent === event) {
227-
this.ngZone.runOutsideAngular(() => {
228-
forkJoin(apps$).subscribe(() => {
229-
this.setLoadingDone();
230-
this.ensurePreloadApps(apps);
231-
});
227+
// this.ngZone.runOutsideAngular(() => {
228+
forkJoin(apps$).subscribe(() => {
229+
this.setLoadingDone();
230+
this.ensurePreloadApps(apps);
232231
});
232+
// });
233233
}
234234
});
235235
} else {
@@ -305,7 +305,6 @@ export class PlanetApplicationLoader {
305305
app: PlanetApplication,
306306
defaultStatus: 'hidden' | 'display' = 'display'
307307
): Observable<PlanetApplicationRef> {
308-
debug(`${app.name} start bootstrap`);
309308
this.setAppStatus(app, ApplicationStatus.bootstrapping);
310309
const appRef = getPlanetApplicationRef(app.name);
311310
if (appRef && appRef.bootstrap) {
@@ -333,7 +332,6 @@ export class PlanetApplicationLoader {
333332
}
334333
return result.pipe(
335334
tap(() => {
336-
debug(`${app.name} bootstrapped`);
337335
this.setAppStatus(app, ApplicationStatus.bootstrapped);
338336
if (defaultStatus === 'display' && appRootElement) {
339337
appRootElement.removeAttribute('style');
@@ -437,7 +435,6 @@ export class PlanetApplicationLoader {
437435
preload(app: PlanetApplication, directBootstrap?: boolean): Observable<PlanetApplicationRef> {
438436
const status = this.appsStatus.get(app);
439437
if (!status || status === ApplicationStatus.loadError) {
440-
debug(`${app.name} start preloading`);
441438
return this.startLoadAppAssets(app).pipe(
442439
switchMap(() => {
443440
if (directBootstrap) {
@@ -446,7 +443,6 @@ export class PlanetApplicationLoader {
446443
return this.ngZone.runOutsideAngular(() => {
447444
return this.takeOneStable().pipe(
448445
switchMap(() => {
449-
debug(`${app.name} start bootstrap on stable`);
450446
return this.bootstrapApp(app, 'hidden');
451447
})
452448
);
@@ -468,12 +464,10 @@ export class PlanetApplicationLoader {
468464
}),
469465
take(1),
470466
map(() => {
471-
debug(`${app.name} assets is loading or app is bootstrapped, return appRef`);
472467
return getPlanetApplicationRef(app.name);
473468
})
474469
);
475470
} else {
476-
debug(`${app.name} status is '${status}' , return appRef`);
477471
return of(getPlanetApplicationRef(app.name));
478472
}
479473
}

packages/planet/src/assets-loader.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable } from '@angular/core';
2-
import { hashCode, isEmpty, getScriptsAndStylesFullPaths, debug } from './helpers';
2+
import { hashCode, isEmpty, getScriptsAndStylesFullPaths } from './helpers';
33
import { of, Observable, Observer, forkJoin, concat, merge } from 'rxjs';
44
import { tap, shareReplay, map, switchMap, switchAll, concatMap, concatAll, scan, reduce } from 'rxjs/operators';
55
import { HttpClient } from '@angular/common/http';
@@ -21,10 +21,8 @@ export class AssetsLoader {
2121
constructor(private http: HttpClient) {}
2222

2323
loadScript(src: string): Observable<AssetsLoadResult> {
24-
debug(`load '${src}' start`);
2524
const id = hashCode(src);
2625
if (this.loadedSources.includes(id)) {
27-
debug(`load '${src}' successfully from cache`);
2826
return of({
2927
src: src,
3028
hashCode: id,
@@ -76,15 +74,12 @@ export class AssetsLoader {
7674
observer.complete();
7775
};
7876
document.body.appendChild(script);
79-
debug(`load '${src}' successfully`);
8077
});
8178
}
8279

8380
loadStyle(src: string): Observable<AssetsLoadResult> {
84-
debug(`load '${src}' start`);
8581
const id = hashCode(src);
8682
if (this.loadedSources.includes(id)) {
87-
debug(`load '${src}' successfully from cache`);
8883
return of({
8984
src: src,
9085
hashCode: id,
@@ -120,7 +115,6 @@ export class AssetsLoader {
120115
observer.complete();
121116
};
122117
head.appendChild(link);
123-
debug(`load '${src}' successfully`);
124118
});
125119
}
126120

@@ -174,10 +168,8 @@ export class AssetsLoader {
174168
}
175169

176170
loadManifest(url: string): Observable<{ [key: string]: string }> {
177-
debug(`load '${url}' start`);
178171
return this.http.get(url).pipe(
179172
map((response: any) => {
180-
debug(`load '${url}' successfully`);
181173
return response;
182174
})
183175
);

packages/planet/src/component/planet-component-loader.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ComponentType, DomPortalOutlet, ComponentPortal, PortalInjector } from
33
import { PlanetApplicationRef } from '../application/planet-application-ref';
44
import { PlanetComponentRef } from './planet-component-ref';
55
import { PlantComponentConfig } from './plant-component.config';
6-
import { coerceArray, debug } from '../helpers';
6+
import { coerceArray } from '../helpers';
77
import { delay, map, shareReplay, finalize } from 'rxjs/operators';
88
import { of, Observable } from 'rxjs';
99
import { DOCUMENT } from '@angular/common';
@@ -125,7 +125,6 @@ export class PlanetComponentLoader {
125125
if (component) {
126126
return this.ngZone.run(() => {
127127
const componentRef = this.attachComponent<any>(component, appRef.appModuleRef, config);
128-
debug(`${app} component '${componentName}' loaded successfully`);
129128
return componentRef;
130129
});
131130
} else {
@@ -142,7 +141,6 @@ export class PlanetComponentLoader {
142141
}
143142

144143
load<TData = any>(app: string, componentName: string, config: PlantComponentConfig<TData>) {
145-
debug(`start loading the component '${componentName}' of ${app}`);
146144
const result = this.getPlantAppRef(app).pipe(
147145
map(appRef => {
148146
const componentFactory = appRef.getComponentFactory();

packages/planet/src/helpers.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { PlanetApplication } from './planet.class';
2-
import _debug from 'debug';
32

43
const ELEMENT_NODE_TYPE = 1;
54

6-
export const debug = _debug('planet');
7-
85
export function hashCode(str: string): number {
96
let hash = 0;
107
let chr: number;

0 commit comments

Comments
 (0)