@tramvai/module-child-app 7.37.2 → 7.39.0
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { combineValidators, isUrl, endsWith } from '@tinkoff/env-validators';
|
|
2
|
-
import { Scope,
|
|
2
|
+
import { Scope, DI_TOKEN, optional } from '@tinkoff/dippy';
|
|
3
3
|
import { provide, TAPABLE_HOOK_FACTORY_TOKEN, commandLineListTokens } from '@tramvai/core';
|
|
4
4
|
import { ENV_USED_TOKEN, LOGGER_TOKEN, ENV_MANAGER_TOKEN, STORE_TOKEN, ASYNC_LOCAL_STORAGE_TOKEN } from '@tramvai/tokens-common';
|
|
5
|
-
import { RESOURCES_REGISTRY, RENDER_SLOTS, ResourceType, ResourceSlot, RENDER_FLOW_AFTER_TOKEN,
|
|
5
|
+
import { RESOURCES_REGISTRY, RENDER_SLOTS, ResourceType, ResourceSlot, RENDER_FLOW_AFTER_TOKEN, EXTEND_RENDER } from '@tramvai/tokens-render';
|
|
6
6
|
import { CHILD_APP_LOADER_TOKEN, CHILD_APP_LOADER_PLUGIN, CHILD_APP_LOADER_CACHE_TOKEN, CHILD_APP_STATE_MANAGER_TOKEN, CHILD_APP_DI_MANAGER_TOKEN, CHILD_APP_PRELOAD_MANAGER_TOKEN, CHILD_APP_PRELOAD_MANAGER_PLUGIN, CHILD_APP_COMMAND_LINE_RUNNER_TOKEN, CHILD_APP_RESOLUTION_CONFIG_MANAGER_TOKEN, CHILD_APP_RESOLVE_CONFIG_TOKEN, CHILD_APP_RENDER_MANAGER_TOKEN, CHILD_APP_CONTRACT_MANAGER, HOST_PROVIDED_CONTRACTS, HOST_REQUIRED_CONTRACTS } from '@tramvai/tokens-child-app';
|
|
7
7
|
import { safeStringify } from '@tramvai/safe-strings';
|
|
8
8
|
import { ServerLoader } from './loader.es.js';
|
|
@@ -97,7 +97,6 @@ const serverProviders = [
|
|
|
97
97
|
resolveFullConfig: CHILD_APP_RESOLVE_CONFIG_TOKEN,
|
|
98
98
|
loader: CHILD_APP_LOADER_TOKEN,
|
|
99
99
|
preloadManager: CHILD_APP_PRELOAD_MANAGER_TOKEN,
|
|
100
|
-
renderMode: optional(REACT_SERVER_RENDER_MODE),
|
|
101
100
|
},
|
|
102
101
|
}),
|
|
103
102
|
provide({
|
package/lib/server/providers.js
CHANGED
|
@@ -101,7 +101,6 @@ const serverProviders = [
|
|
|
101
101
|
resolveFullConfig: tokensChildApp.CHILD_APP_RESOLVE_CONFIG_TOKEN,
|
|
102
102
|
loader: tokensChildApp.CHILD_APP_LOADER_TOKEN,
|
|
103
103
|
preloadManager: tokensChildApp.CHILD_APP_PRELOAD_MANAGER_TOKEN,
|
|
104
|
-
renderMode: dippy.optional(tokensRender.REACT_SERVER_RENDER_MODE),
|
|
105
104
|
},
|
|
106
105
|
}),
|
|
107
106
|
core.provide({
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ExtractDependencyType } from '@tinkoff/dippy';
|
|
2
2
|
import { type ChildAppDiManager, type ChildAppLoader, type ChildAppPreloadManager, type CHILD_APP_RESOLVE_CONFIG_TOKEN } from '@tramvai/tokens-child-app';
|
|
3
3
|
import type { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
4
|
-
import type {
|
|
4
|
+
import type { RESOURCES_REGISTRY } from '@tramvai/tokens-render';
|
|
5
5
|
import type { ServerLoader } from './loader';
|
|
6
|
-
export declare const registerChildAppRenderSlots: ({ logger, diManager, resolveFullConfig, preloadManager, loader,
|
|
6
|
+
export declare const registerChildAppRenderSlots: ({ logger, diManager, resolveFullConfig, preloadManager, loader, resourcesRegistry, }: {
|
|
7
7
|
logger: ExtractDependencyType<typeof LOGGER_TOKEN>;
|
|
8
8
|
diManager: ChildAppDiManager;
|
|
9
9
|
resolveFullConfig: ExtractDependencyType<typeof CHILD_APP_RESOLVE_CONFIG_TOKEN>;
|
|
10
10
|
preloadManager: ChildAppPreloadManager;
|
|
11
11
|
loader: ChildAppLoader | ServerLoader;
|
|
12
|
-
renderMode: typeof REACT_SERVER_RENDER_MODE | null;
|
|
13
12
|
resourcesRegistry: ExtractDependencyType<typeof RESOURCES_REGISTRY>;
|
|
14
13
|
}) => () => Promise<void>;
|
|
15
14
|
//# sourceMappingURL=render-slots.d.ts.map
|
|
@@ -7,14 +7,6 @@ import { getSharedScope } from '../shared/webpack/moduleFederation.es.js';
|
|
|
7
7
|
import { getFlatSharedScopeItemsList, getFlatSharedModulesList } from './module-federation/utils.es.js';
|
|
8
8
|
import { resolveBestLoadedSharedModules } from './module-federation/best-loaded-shared-modules.es.js';
|
|
9
9
|
|
|
10
|
-
const asyncScriptAttrs = {
|
|
11
|
-
defer: null,
|
|
12
|
-
async: 'async',
|
|
13
|
-
};
|
|
14
|
-
const deferScriptAttrs = {
|
|
15
|
-
defer: 'defer',
|
|
16
|
-
async: null,
|
|
17
|
-
};
|
|
18
10
|
// for cases when Child App script was loaded or failed when script was added at server-side,
|
|
19
11
|
// and Child App initialization logic executed after that, we need to get script loading status
|
|
20
12
|
const entryAttrs = {
|
|
@@ -26,33 +18,45 @@ const entryAttrs = {
|
|
|
26
18
|
const chunkAttrs = {
|
|
27
19
|
onerror: `this.remove()`,
|
|
28
20
|
};
|
|
29
|
-
const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, preloadManager, loader,
|
|
21
|
+
const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, preloadManager, loader, resourcesRegistry, }) =>
|
|
30
22
|
// eslint-disable-next-line max-statements
|
|
31
23
|
async () => {
|
|
32
24
|
const log = logger('child-app:render:slots');
|
|
33
25
|
const result = [];
|
|
34
|
-
// defer scripts is not suitable for React streaming, we need to ability to run them as early as possible
|
|
35
|
-
// https://github.com/reactwg/react-18/discussions/114
|
|
36
|
-
const scriptTypeAttr = renderMode === 'streaming' ? asyncScriptAttrs : deferScriptAttrs;
|
|
37
26
|
const addChunk = (chunk, isEntry = false) => {
|
|
38
27
|
if (!chunk) {
|
|
39
28
|
return;
|
|
40
29
|
}
|
|
41
30
|
const extension = extname(chunk);
|
|
42
31
|
switch (extension) {
|
|
43
|
-
case '.js':
|
|
32
|
+
case '.js': {
|
|
33
|
+
const attrs = {
|
|
34
|
+
crossorigin: 'anonymous',
|
|
35
|
+
fetchpriority: 'low',
|
|
36
|
+
};
|
|
44
37
|
result.push({
|
|
45
38
|
type: ResourceType.script,
|
|
46
|
-
|
|
47
|
-
slot: ResourceSlot.HEAD_DYNAMIC_SCRIPTS,
|
|
39
|
+
slot: ResourceSlot.BODY_DYNAMIC_SCRIPTS,
|
|
48
40
|
payload: chunk,
|
|
49
41
|
attrs: {
|
|
42
|
+
...attrs,
|
|
50
43
|
'data-critical': 'true',
|
|
51
|
-
|
|
44
|
+
async: 'async',
|
|
45
|
+
defer: null,
|
|
52
46
|
...(isEntry ? entryAttrs : chunkAttrs),
|
|
53
47
|
},
|
|
54
48
|
});
|
|
49
|
+
result.push({
|
|
50
|
+
type: ResourceType.preloadLink,
|
|
51
|
+
slot: ResourceSlot.HEAD_PERFORMANCE,
|
|
52
|
+
payload: chunk,
|
|
53
|
+
attrs: {
|
|
54
|
+
...attrs,
|
|
55
|
+
as: 'script',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
55
58
|
break;
|
|
59
|
+
}
|
|
56
60
|
case '.css':
|
|
57
61
|
result.push({
|
|
58
62
|
type: ResourceType.style,
|
|
@@ -60,6 +64,8 @@ async () => {
|
|
|
60
64
|
payload: chunk,
|
|
61
65
|
attrs: {
|
|
62
66
|
'data-critical': 'true',
|
|
67
|
+
crossorigin: 'anonymous',
|
|
68
|
+
fetchpriority: 'high',
|
|
63
69
|
},
|
|
64
70
|
});
|
|
65
71
|
break;
|
|
@@ -15,14 +15,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
15
15
|
|
|
16
16
|
var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
17
17
|
|
|
18
|
-
const asyncScriptAttrs = {
|
|
19
|
-
defer: null,
|
|
20
|
-
async: 'async',
|
|
21
|
-
};
|
|
22
|
-
const deferScriptAttrs = {
|
|
23
|
-
defer: 'defer',
|
|
24
|
-
async: null,
|
|
25
|
-
};
|
|
26
18
|
// for cases when Child App script was loaded or failed when script was added at server-side,
|
|
27
19
|
// and Child App initialization logic executed after that, we need to get script loading status
|
|
28
20
|
const entryAttrs = {
|
|
@@ -34,33 +26,45 @@ const entryAttrs = {
|
|
|
34
26
|
const chunkAttrs = {
|
|
35
27
|
onerror: `this.remove()`,
|
|
36
28
|
};
|
|
37
|
-
const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, preloadManager, loader,
|
|
29
|
+
const registerChildAppRenderSlots = ({ logger, diManager, resolveFullConfig, preloadManager, loader, resourcesRegistry, }) =>
|
|
38
30
|
// eslint-disable-next-line max-statements
|
|
39
31
|
async () => {
|
|
40
32
|
const log = logger('child-app:render:slots');
|
|
41
33
|
const result = [];
|
|
42
|
-
// defer scripts is not suitable for React streaming, we need to ability to run them as early as possible
|
|
43
|
-
// https://github.com/reactwg/react-18/discussions/114
|
|
44
|
-
const scriptTypeAttr = renderMode === 'streaming' ? asyncScriptAttrs : deferScriptAttrs;
|
|
45
34
|
const addChunk = (chunk, isEntry = false) => {
|
|
46
35
|
if (!chunk) {
|
|
47
36
|
return;
|
|
48
37
|
}
|
|
49
38
|
const extension = path.extname(chunk);
|
|
50
39
|
switch (extension) {
|
|
51
|
-
case '.js':
|
|
40
|
+
case '.js': {
|
|
41
|
+
const attrs = {
|
|
42
|
+
crossorigin: 'anonymous',
|
|
43
|
+
fetchpriority: 'low',
|
|
44
|
+
};
|
|
52
45
|
result.push({
|
|
53
46
|
type: tokensRender.ResourceType.script,
|
|
54
|
-
|
|
55
|
-
slot: tokensRender.ResourceSlot.HEAD_DYNAMIC_SCRIPTS,
|
|
47
|
+
slot: tokensRender.ResourceSlot.BODY_DYNAMIC_SCRIPTS,
|
|
56
48
|
payload: chunk,
|
|
57
49
|
attrs: {
|
|
50
|
+
...attrs,
|
|
58
51
|
'data-critical': 'true',
|
|
59
|
-
|
|
52
|
+
async: 'async',
|
|
53
|
+
defer: null,
|
|
60
54
|
...(isEntry ? entryAttrs : chunkAttrs),
|
|
61
55
|
},
|
|
62
56
|
});
|
|
57
|
+
result.push({
|
|
58
|
+
type: tokensRender.ResourceType.preloadLink,
|
|
59
|
+
slot: tokensRender.ResourceSlot.HEAD_PERFORMANCE,
|
|
60
|
+
payload: chunk,
|
|
61
|
+
attrs: {
|
|
62
|
+
...attrs,
|
|
63
|
+
as: 'script',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
63
66
|
break;
|
|
67
|
+
}
|
|
64
68
|
case '.css':
|
|
65
69
|
result.push({
|
|
66
70
|
type: tokensRender.ResourceType.style,
|
|
@@ -68,6 +72,8 @@ async () => {
|
|
|
68
72
|
payload: chunk,
|
|
69
73
|
attrs: {
|
|
70
74
|
'data-critical': 'true',
|
|
75
|
+
crossorigin: 'anonymous',
|
|
76
|
+
fetchpriority: 'high',
|
|
71
77
|
},
|
|
72
78
|
});
|
|
73
79
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-child-app",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.39.0",
|
|
4
4
|
"description": "Module for child apps",
|
|
5
5
|
"browser": {
|
|
6
6
|
"./lib/server.es.js": "./lib/browser.js",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"@tinkoff/module-loader-client": "0.9.1",
|
|
37
37
|
"@tinkoff/module-loader-server": "0.10.3",
|
|
38
38
|
"@tinkoff/url": "0.13.1",
|
|
39
|
-
"@tramvai/child-app-core": "7.
|
|
40
|
-
"@tramvai/module-common": "7.
|
|
41
|
-
"@tramvai/module-router": "7.
|
|
39
|
+
"@tramvai/child-app-core": "7.39.0",
|
|
40
|
+
"@tramvai/module-common": "7.39.0",
|
|
41
|
+
"@tramvai/module-router": "7.39.0",
|
|
42
42
|
"@tramvai/safe-strings": "0.10.2",
|
|
43
|
-
"@tramvai/tokens-child-app": "7.
|
|
43
|
+
"@tramvai/tokens-child-app": "7.39.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@tinkoff/dippy": "^1.0.0",
|
|
47
|
-
"@tinkoff/router": "0.7.
|
|
47
|
+
"@tinkoff/router": "0.7.149",
|
|
48
48
|
"@tinkoff/utils": "^2.1.2",
|
|
49
|
-
"@tramvai/core": "7.
|
|
50
|
-
"@tramvai/react": "7.
|
|
51
|
-
"@tramvai/state": "7.
|
|
52
|
-
"@tramvai/tokens-common": "7.
|
|
53
|
-
"@tramvai/tokens-render": "7.
|
|
54
|
-
"@tramvai/tokens-router": "7.
|
|
49
|
+
"@tramvai/core": "7.39.0",
|
|
50
|
+
"@tramvai/react": "7.39.0",
|
|
51
|
+
"@tramvai/state": "7.39.0",
|
|
52
|
+
"@tramvai/tokens-common": "7.39.0",
|
|
53
|
+
"@tramvai/tokens-render": "7.39.0",
|
|
54
|
+
"@tramvai/tokens-router": "7.39.0",
|
|
55
55
|
"object-assign": "^4.1.1",
|
|
56
56
|
"react": ">=16.14.0",
|
|
57
57
|
"react-dom": ">=16.14.0",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"tslib": "^2.4.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@tramvai/module-http-client": "7.
|
|
63
|
-
"@tramvai/module-react-query": "7.
|
|
64
|
-
"@tramvai/module-render": "7.
|
|
65
|
-
"@tramvai/module-router": "7.
|
|
66
|
-
"@tramvai/module-server": "7.
|
|
67
|
-
"@tramvai/react": "7.
|
|
68
|
-
"@tramvai/react-query": "7.
|
|
69
|
-
"@tramvai/state": "7.
|
|
62
|
+
"@tramvai/module-http-client": "7.39.0",
|
|
63
|
+
"@tramvai/module-react-query": "7.39.0",
|
|
64
|
+
"@tramvai/module-render": "7.39.0",
|
|
65
|
+
"@tramvai/module-router": "7.39.0",
|
|
66
|
+
"@tramvai/module-server": "7.39.0",
|
|
67
|
+
"@tramvai/react": "7.39.0",
|
|
68
|
+
"@tramvai/react-query": "7.39.0",
|
|
69
|
+
"@tramvai/state": "7.39.0"
|
|
70
70
|
},
|
|
71
71
|
"module": "lib/server.es.js"
|
|
72
72
|
}
|