@tramvai/module-child-app 5.4.2 → 5.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,7 +43,15 @@ class PreloadManager {
43
43
  await this.loader.load(config);
44
44
  await this.resolveComponent(config, route);
45
45
  await this.run('customer', config);
46
- await this.run('clear', config);
46
+ // do not block Child App preloading by "clear" stage (where actions executed),
47
+ // because in will delay Child App rendering
48
+ // TODO: do we need to wait this Child App stage in "afterSpaTransition"?
49
+ // TODO: Can be a race condition between Child App render and actions?
50
+ this.run('clear', config).catch((error) => {
51
+ if (process.env.NODE_ENV === 'development') {
52
+ console.error('Child App command line error', error);
53
+ }
54
+ });
47
55
  }
48
56
  catch (error) {
49
57
  if (process.env.NODE_ENV === 'development') {
@@ -13,10 +13,13 @@ class RenderManager {
13
13
  if (this.preloadManager.isPreloaded(request)) {
14
14
  return [this.diManager.getChildDi(config), undefined];
15
15
  }
16
- this.log.warn({
17
- message: 'Child-app has been used but not preloaded before React render',
18
- request,
19
- });
16
+ // for SPA-navigation, if Child App is preloaded first time, it is valid case
17
+ if (!this.preloadManager.isNotPreloadedForSpaNavigation(request)) {
18
+ this.log.warn({
19
+ message: 'Child-app has been used but not preloaded before React render',
20
+ request,
21
+ });
22
+ }
20
23
  const promiseDi = this.preloadManager.preload(request).then(() => {
21
24
  return this.diManager.getChildDi(config);
22
25
  });
@@ -1,5 +1,6 @@
1
1
  const runCommand = async ({ status, forcePreload, runner, preloader, diManager, pageService, logger, }) => {
2
2
  const childApps = preloader.getPreloadedList();
3
+ const log = logger('child-app:run-preloaded');
3
4
  await Promise.all(childApps.map(async (config) => {
4
5
  if (forcePreload) {
5
6
  // need to wait while actual child-app is loaded in case it wasn't preloaded before
@@ -8,11 +9,16 @@ const runCommand = async ({ status, forcePreload, runner, preloader, diManager,
8
9
  // if Child Apps was not preloaded, prevent running `spa` and `afterSpa` lines for it,
9
10
  // because it trigger actions or resolveUserDeps/resolvePageDeps commands second execution on the same navigation
10
11
  if (preloader.isNotPreloadedForSpaNavigation(config)) {
12
+ if (status === 'spa') {
13
+ log.info({
14
+ message: 'Child App has been preloaded first time, current SPA-transition will not be blocked, Child App `spa` and `afterSpa` lines will be skipped',
15
+ config,
16
+ });
17
+ }
11
18
  return;
12
19
  }
13
20
  return runner.run('client', status, config);
14
21
  })).catch((error) => {
15
- const log = logger('child-app:run-preloaded');
16
22
  log.error({
17
23
  event: 'spa-failed',
18
24
  error,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-child-app",
3
- "version": "5.4.2",
3
+ "version": "5.4.3",
4
4
  "description": "Module for child apps",
5
5
  "browser": {
6
6
  "./lib/server.js": "./lib/browser.js",
@@ -33,23 +33,23 @@
33
33
  "@tinkoff/env-validators": "0.4.2",
34
34
  "@tinkoff/module-loader-client": "0.7.2",
35
35
  "@tinkoff/module-loader-server": "0.8.2",
36
- "@tramvai/module-common": "5.4.2",
36
+ "@tramvai/module-common": "5.4.3",
37
37
  "@tinkoff/url": "0.11.2",
38
- "@tramvai/child-app-core": "5.4.2",
38
+ "@tramvai/child-app-core": "5.4.3",
39
39
  "@tramvai/safe-strings": "0.8.2",
40
- "@tramvai/tokens-child-app": "5.4.2"
40
+ "@tramvai/tokens-child-app": "5.4.3"
41
41
  },
42
42
  "devDependencies": {},
43
43
  "peerDependencies": {
44
44
  "@tinkoff/dippy": "0.11.3",
45
- "@tinkoff/router": "0.5.10",
45
+ "@tinkoff/router": "0.5.11",
46
46
  "@tinkoff/utils": "^2.1.2",
47
- "@tramvai/core": "5.4.2",
48
- "@tramvai/state": "5.4.2",
49
- "@tramvai/react": "5.4.2",
50
- "@tramvai/tokens-common": "5.4.2",
51
- "@tramvai/tokens-render": "5.4.2",
52
- "@tramvai/tokens-router": "5.4.2",
47
+ "@tramvai/core": "5.4.3",
48
+ "@tramvai/state": "5.4.3",
49
+ "@tramvai/react": "5.4.3",
50
+ "@tramvai/tokens-common": "5.4.3",
51
+ "@tramvai/tokens-render": "5.4.3",
52
+ "@tramvai/tokens-router": "5.4.3",
53
53
  "react": ">=16.14.0",
54
54
  "react-dom": ">=16.14.0",
55
55
  "object-assign": "^4.1.1",