@tramvai/module-render 2.87.0 → 2.90.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.
- package/lib/server/PageBuilder.d.ts +3 -1
- package/lib/server/PageBuilder.es.js +11 -4
- package/lib/server/PageBuilder.js +11 -4
- package/lib/server/blocks/bundleResource/bundleResource.d.ts +3 -2
- package/lib/server/blocks/bundleResource/bundleResource.es.js +1 -2
- package/lib/server/blocks/bundleResource/bundleResource.js +2 -3
- package/lib/server/blocks/polyfill.d.ts +3 -2
- package/lib/server/blocks/polyfill.es.js +1 -2
- package/lib/server/blocks/polyfill.js +2 -3
- package/lib/server/blocks/utils/fetchWebpackStats.d.ts +2 -12
- package/lib/server/blocks/utils/fetchWebpackStats.es.js +6 -2
- package/lib/server/blocks/utils/fetchWebpackStats.js +6 -2
- package/lib/server/blocks/utils/flushFiles.d.ts +1 -1
- package/lib/server.es.js +7 -1
- package/lib/server.js +6 -0
- package/package.json +15 -15
- package/tests.js +0 -78
|
@@ -11,7 +11,8 @@ export declare class PageBuilder {
|
|
|
11
11
|
private modern;
|
|
12
12
|
private renderFlowAfter;
|
|
13
13
|
private log;
|
|
14
|
-
|
|
14
|
+
private fetchWebpackStats;
|
|
15
|
+
constructor({ renderSlots, pageService, resourcesRegistry, context, reactRender, htmlPageSchema, polyfillCondition, htmlAttrs, modern, renderFlowAfter, logger, fetchWebpackStats, }: {
|
|
15
16
|
renderSlots: any;
|
|
16
17
|
pageService: any;
|
|
17
18
|
resourcesRegistry: any;
|
|
@@ -23,6 +24,7 @@ export declare class PageBuilder {
|
|
|
23
24
|
modern: any;
|
|
24
25
|
renderFlowAfter: any;
|
|
25
26
|
logger: any;
|
|
27
|
+
fetchWebpackStats: any;
|
|
26
28
|
});
|
|
27
29
|
flow(): Promise<string>;
|
|
28
30
|
dehydrateState(): void;
|
|
@@ -7,7 +7,6 @@ import { bundleResource } from './blocks/bundleResource/bundleResource.es.js';
|
|
|
7
7
|
import { polyfillResources } from './blocks/polyfill.es.js';
|
|
8
8
|
import { addPreloadForCriticalJS } from './blocks/preload/preloadBlock.es.js';
|
|
9
9
|
import { formatAttributes } from './utils.es.js';
|
|
10
|
-
import { fetchWebpackStats } from './blocks/utils/fetchWebpackStats.es.js';
|
|
11
10
|
|
|
12
11
|
/* eslint-disable sort-class-members/sort-class-members */
|
|
13
12
|
const mapResourcesToSlots = (resources) => resources.reduce((acc, resource) => {
|
|
@@ -21,7 +20,7 @@ const mapResourcesToSlots = (resources) => resources.reduce((acc, resource) => {
|
|
|
21
20
|
return acc;
|
|
22
21
|
}, {});
|
|
23
22
|
class PageBuilder {
|
|
24
|
-
constructor({ renderSlots, pageService, resourcesRegistry, context, reactRender, htmlPageSchema, polyfillCondition, htmlAttrs, modern, renderFlowAfter, logger, }) {
|
|
23
|
+
constructor({ renderSlots, pageService, resourcesRegistry, context, reactRender, htmlPageSchema, polyfillCondition, htmlAttrs, modern, renderFlowAfter, logger, fetchWebpackStats, }) {
|
|
25
24
|
this.htmlAttrs = htmlAttrs;
|
|
26
25
|
this.renderSlots = flatten(renderSlots || []);
|
|
27
26
|
this.pageService = pageService;
|
|
@@ -33,9 +32,10 @@ class PageBuilder {
|
|
|
33
32
|
this.modern = modern;
|
|
34
33
|
this.renderFlowAfter = renderFlowAfter || [];
|
|
35
34
|
this.log = logger('page-builder');
|
|
35
|
+
this.fetchWebpackStats = fetchWebpackStats;
|
|
36
36
|
}
|
|
37
37
|
async flow() {
|
|
38
|
-
const stats = await fetchWebpackStats({ modern: this.modern });
|
|
38
|
+
const stats = await this.fetchWebpackStats({ modern: this.modern });
|
|
39
39
|
const extractor = new ChunkExtractor({ stats, entrypoints: [] });
|
|
40
40
|
// first we render the application, because we need to extract information about the data used by the components
|
|
41
41
|
await this.renderApp(extractor);
|
|
@@ -59,10 +59,17 @@ class PageBuilder {
|
|
|
59
59
|
async fetchChunksInfo(extractor) {
|
|
60
60
|
const { modern } = this;
|
|
61
61
|
const { bundle, pageComponent } = this.pageService.getConfig();
|
|
62
|
-
this.resourcesRegistry.register(await bundleResource({
|
|
62
|
+
this.resourcesRegistry.register(await bundleResource({
|
|
63
|
+
bundle,
|
|
64
|
+
modern,
|
|
65
|
+
extractor,
|
|
66
|
+
pageComponent,
|
|
67
|
+
fetchWebpackStats: this.fetchWebpackStats,
|
|
68
|
+
}));
|
|
63
69
|
this.resourcesRegistry.register(await polyfillResources({
|
|
64
70
|
condition: this.polyfillCondition,
|
|
65
71
|
modern,
|
|
72
|
+
fetchWebpackStats: this.fetchWebpackStats,
|
|
66
73
|
}));
|
|
67
74
|
}
|
|
68
75
|
preloadBlock() {
|
|
@@ -11,7 +11,6 @@ var bundleResource = require('./blocks/bundleResource/bundleResource.js');
|
|
|
11
11
|
var polyfill = require('./blocks/polyfill.js');
|
|
12
12
|
var preloadBlock = require('./blocks/preload/preloadBlock.js');
|
|
13
13
|
var utils = require('./utils.js');
|
|
14
|
-
var fetchWebpackStats = require('./blocks/utils/fetchWebpackStats.js');
|
|
15
14
|
|
|
16
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
16
|
|
|
@@ -29,7 +28,7 @@ const mapResourcesToSlots = (resources) => resources.reduce((acc, resource) => {
|
|
|
29
28
|
return acc;
|
|
30
29
|
}, {});
|
|
31
30
|
class PageBuilder {
|
|
32
|
-
constructor({ renderSlots, pageService, resourcesRegistry, context, reactRender, htmlPageSchema, polyfillCondition, htmlAttrs, modern, renderFlowAfter, logger, }) {
|
|
31
|
+
constructor({ renderSlots, pageService, resourcesRegistry, context, reactRender, htmlPageSchema, polyfillCondition, htmlAttrs, modern, renderFlowAfter, logger, fetchWebpackStats, }) {
|
|
33
32
|
this.htmlAttrs = htmlAttrs;
|
|
34
33
|
this.renderSlots = flatten__default["default"](renderSlots || []);
|
|
35
34
|
this.pageService = pageService;
|
|
@@ -41,9 +40,10 @@ class PageBuilder {
|
|
|
41
40
|
this.modern = modern;
|
|
42
41
|
this.renderFlowAfter = renderFlowAfter || [];
|
|
43
42
|
this.log = logger('page-builder');
|
|
43
|
+
this.fetchWebpackStats = fetchWebpackStats;
|
|
44
44
|
}
|
|
45
45
|
async flow() {
|
|
46
|
-
const stats = await
|
|
46
|
+
const stats = await this.fetchWebpackStats({ modern: this.modern });
|
|
47
47
|
const extractor = new server.ChunkExtractor({ stats, entrypoints: [] });
|
|
48
48
|
// first we render the application, because we need to extract information about the data used by the components
|
|
49
49
|
await this.renderApp(extractor);
|
|
@@ -67,10 +67,17 @@ class PageBuilder {
|
|
|
67
67
|
async fetchChunksInfo(extractor) {
|
|
68
68
|
const { modern } = this;
|
|
69
69
|
const { bundle, pageComponent } = this.pageService.getConfig();
|
|
70
|
-
this.resourcesRegistry.register(await bundleResource.bundleResource({
|
|
70
|
+
this.resourcesRegistry.register(await bundleResource.bundleResource({
|
|
71
|
+
bundle,
|
|
72
|
+
modern,
|
|
73
|
+
extractor,
|
|
74
|
+
pageComponent,
|
|
75
|
+
fetchWebpackStats: this.fetchWebpackStats,
|
|
76
|
+
}));
|
|
71
77
|
this.resourcesRegistry.register(await polyfill.polyfillResources({
|
|
72
78
|
condition: this.polyfillCondition,
|
|
73
79
|
modern,
|
|
80
|
+
fetchWebpackStats: this.fetchWebpackStats,
|
|
74
81
|
}));
|
|
75
82
|
}
|
|
76
83
|
preloadBlock() {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ChunkExtractor } from '@loadable/server';
|
|
2
|
-
import type { PageResource } from '@tramvai/tokens-render';
|
|
3
|
-
export declare const bundleResource: ({ bundle, modern, extractor, pageComponent, }: {
|
|
2
|
+
import type { PageResource, FETCH_WEBPACK_STATS_TOKEN } from '@tramvai/tokens-render';
|
|
3
|
+
export declare const bundleResource: ({ bundle, modern, extractor, pageComponent, fetchWebpackStats, }: {
|
|
4
4
|
bundle: string;
|
|
5
5
|
modern: boolean;
|
|
6
6
|
extractor: ChunkExtractor;
|
|
7
7
|
pageComponent?: string;
|
|
8
|
+
fetchWebpackStats: typeof FETCH_WEBPACK_STATS_TOKEN;
|
|
8
9
|
}) => Promise<PageResource[]>;
|
|
@@ -4,9 +4,8 @@ import { ResourceType, ResourceSlot } from '@tramvai/tokens-render';
|
|
|
4
4
|
import { isFileSystemPageComponent, fileSystemPageToWebpackChunkName } from '@tramvai/experiments';
|
|
5
5
|
import { PRELOAD_JS } from '../../constants/performance.es.js';
|
|
6
6
|
import { flushFiles } from '../utils/flushFiles.es.js';
|
|
7
|
-
import { fetchWebpackStats } from '../utils/fetchWebpackStats.es.js';
|
|
8
7
|
|
|
9
|
-
const bundleResource = async ({ bundle, modern, extractor, pageComponent, }) => {
|
|
8
|
+
const bundleResource = async ({ bundle, modern, extractor, pageComponent, fetchWebpackStats, }) => {
|
|
10
9
|
// for file-system pages preload page chunk against bundle chunk
|
|
11
10
|
const chunkNameFromBundle = isFileSystemPageComponent(pageComponent)
|
|
12
11
|
? fileSystemPageToWebpackChunkName(pageComponent)
|
|
@@ -8,19 +8,18 @@ var tokensRender = require('@tramvai/tokens-render');
|
|
|
8
8
|
var experiments = require('@tramvai/experiments');
|
|
9
9
|
var performance = require('../../constants/performance.js');
|
|
10
10
|
var flushFiles = require('../utils/flushFiles.js');
|
|
11
|
-
var fetchWebpackStats = require('../utils/fetchWebpackStats.js');
|
|
12
11
|
|
|
13
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
13
|
|
|
15
14
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
16
15
|
var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
|
|
17
16
|
|
|
18
|
-
const bundleResource = async ({ bundle, modern, extractor, pageComponent, }) => {
|
|
17
|
+
const bundleResource = async ({ bundle, modern, extractor, pageComponent, fetchWebpackStats, }) => {
|
|
19
18
|
// for file-system pages preload page chunk against bundle chunk
|
|
20
19
|
const chunkNameFromBundle = experiments.isFileSystemPageComponent(pageComponent)
|
|
21
20
|
? experiments.fileSystemPageToWebpackChunkName(pageComponent)
|
|
22
21
|
: last__default["default"](bundle.split('/'));
|
|
23
|
-
const webpackStats = await fetchWebpackStats
|
|
22
|
+
const webpackStats = await fetchWebpackStats({ modern });
|
|
24
23
|
const { publicPath, assetsByChunkName } = webpackStats;
|
|
25
24
|
const bundles = has__default["default"]('common-chunk', assetsByChunkName)
|
|
26
25
|
? ['common-chunk', chunkNameFromBundle]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { PageResource } from '@tramvai/tokens-render';
|
|
2
|
-
export declare const polyfillResources: ({ condition, modern, }: {
|
|
1
|
+
import type { PageResource, FETCH_WEBPACK_STATS_TOKEN } from '@tramvai/tokens-render';
|
|
2
|
+
export declare const polyfillResources: ({ condition, modern, fetchWebpackStats, }: {
|
|
3
3
|
condition: string;
|
|
4
4
|
modern: boolean;
|
|
5
|
+
fetchWebpackStats: typeof FETCH_WEBPACK_STATS_TOKEN;
|
|
5
6
|
}) => Promise<PageResource[]>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ResourceType, ResourceSlot } from '@tramvai/tokens-render';
|
|
2
|
-
import { fetchWebpackStats } from './utils/fetchWebpackStats.es.js';
|
|
3
2
|
import { flushFiles } from './utils/flushFiles.es.js';
|
|
4
3
|
|
|
5
|
-
const polyfillResources = async ({ condition, modern, }) => {
|
|
4
|
+
const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
|
|
6
5
|
const webpackStats = await fetchWebpackStats({ modern });
|
|
7
6
|
const { publicPath } = webpackStats;
|
|
8
7
|
// получает файл полифилла из stats.json\stats.modern.json.
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tokensRender = require('@tramvai/tokens-render');
|
|
6
|
-
var fetchWebpackStats = require('./utils/fetchWebpackStats.js');
|
|
7
6
|
var flushFiles = require('./utils/flushFiles.js');
|
|
8
7
|
|
|
9
|
-
const polyfillResources = async ({ condition, modern, }) => {
|
|
10
|
-
const webpackStats = await fetchWebpackStats
|
|
8
|
+
const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
|
|
9
|
+
const webpackStats = await fetchWebpackStats({ modern });
|
|
11
10
|
const { publicPath } = webpackStats;
|
|
12
11
|
// получает файл полифилла из stats.json\stats.modern.json.
|
|
13
12
|
// В зависимости от версии браузера будет использован полифилл из legacy или modern сборки,
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
namedChunkGroups?: Record<string, {
|
|
4
|
-
name: string;
|
|
5
|
-
chunks: string[];
|
|
6
|
-
}>;
|
|
7
|
-
publicPath: string;
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
};
|
|
10
|
-
export declare const fetchWebpackStats: ({ modern, }?: {
|
|
11
|
-
modern?: boolean;
|
|
12
|
-
}) => Promise<WebpackStats>;
|
|
1
|
+
import type { FETCH_WEBPACK_STATS_TOKEN } from '@tramvai/tokens-render';
|
|
2
|
+
export declare const fetchWebpackStats: typeof FETCH_WEBPACK_STATS_TOKEN;
|
|
@@ -28,7 +28,11 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
28
28
|
if (process.env.NODE_ENV === 'test') {
|
|
29
29
|
fetchStats = () => {
|
|
30
30
|
// mock for unit-testing as there is no real static return something just to make server render work
|
|
31
|
-
return Promise.resolve({
|
|
31
|
+
return Promise.resolve({
|
|
32
|
+
publicPath: 'http://localhost:4000/',
|
|
33
|
+
assetsByChunkName: {},
|
|
34
|
+
entrypoints: {},
|
|
35
|
+
});
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
38
|
if (process.env.NODE_ENV === 'production') {
|
|
@@ -81,7 +85,7 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
81
85
|
return Promise.resolve(stats);
|
|
82
86
|
};
|
|
83
87
|
}
|
|
84
|
-
const fetchWebpackStats = async ({ modern
|
|
88
|
+
const fetchWebpackStats = async ({ modern } = {}) => {
|
|
85
89
|
return fetchStats(modern);
|
|
86
90
|
};
|
|
87
91
|
|
|
@@ -55,7 +55,11 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
55
55
|
if (process.env.NODE_ENV === 'test') {
|
|
56
56
|
fetchStats = () => {
|
|
57
57
|
// mock for unit-testing as there is no real static return something just to make server render work
|
|
58
|
-
return Promise.resolve({
|
|
58
|
+
return Promise.resolve({
|
|
59
|
+
publicPath: 'http://localhost:4000/',
|
|
60
|
+
assetsByChunkName: {},
|
|
61
|
+
entrypoints: {},
|
|
62
|
+
});
|
|
59
63
|
};
|
|
60
64
|
}
|
|
61
65
|
if (process.env.NODE_ENV === 'production') {
|
|
@@ -108,7 +112,7 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
108
112
|
return Promise.resolve(stats);
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
|
-
const fetchWebpackStats = async ({ modern
|
|
115
|
+
const fetchWebpackStats = async ({ modern } = {}) => {
|
|
112
116
|
return fetchStats(modern);
|
|
113
117
|
};
|
|
114
118
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebpackStats } from '
|
|
1
|
+
import type { WebpackStats } from '@tramvai/tokens-render';
|
|
2
2
|
export declare const isJs: (file: string) => boolean;
|
|
3
3
|
export declare const isCss: (file: string) => boolean;
|
|
4
4
|
export declare const flushFiles: (chunks: string[], webpackStats: WebpackStats, { ignoreDependencies, }?: {
|
package/lib/server.es.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Module, provide, commandLineListTokens, DI_TOKEN } from '@tramvai/core'
|
|
|
3
3
|
import { CREATE_CACHE_TOKEN, LOGGER_TOKEN, REQUEST_MANAGER_TOKEN, RESPONSE_MANAGER_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
4
4
|
import { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
|
|
5
5
|
import { ClientHintsModule, USER_AGENT_TOKEN } from '@tramvai/module-client-hints';
|
|
6
|
-
import { RESOURCES_REGISTRY, RESOURCE_INLINE_OPTIONS, RENDER_SLOTS, POLYFILL_CONDITION, HTML_ATTRS, MODERN_SATISFIES_TOKEN, RENDER_FLOW_AFTER_TOKEN, CUSTOM_RENDER, EXTEND_RENDER, REACT_SERVER_RENDER_MODE, ResourceType } from '@tramvai/tokens-render';
|
|
6
|
+
import { RESOURCES_REGISTRY, RESOURCE_INLINE_OPTIONS, RENDER_SLOTS, POLYFILL_CONDITION, HTML_ATTRS, MODERN_SATISFIES_TOKEN, RENDER_FLOW_AFTER_TOKEN, FETCH_WEBPACK_STATS_TOKEN, CUSTOM_RENDER, EXTEND_RENDER, REACT_SERVER_RENDER_MODE, ResourceType } from '@tramvai/tokens-render';
|
|
7
7
|
export * from '@tramvai/tokens-render';
|
|
8
8
|
import { Scope } from '@tinkoff/dippy';
|
|
9
9
|
import { satisfies } from '@tinkoff/user-agent';
|
|
@@ -19,6 +19,7 @@ import { ReactRenderServer } from './server/ReactRenderServer.es.js';
|
|
|
19
19
|
export { ReactRenderServer } from './server/ReactRenderServer.es.js';
|
|
20
20
|
import { LayoutModule } from './shared/LayoutModule.es.js';
|
|
21
21
|
import { providers } from './shared/providers.es.js';
|
|
22
|
+
import { fetchWebpackStats } from './server/blocks/utils/fetchWebpackStats.es.js';
|
|
22
23
|
|
|
23
24
|
var RenderModule_1;
|
|
24
25
|
const REQUEST_TTL = 5 * 60 * 1000;
|
|
@@ -193,6 +194,7 @@ Page Error Boundary will be rendered for the client`,
|
|
|
193
194
|
modern: MODERN_SATISFIES_TOKEN,
|
|
194
195
|
renderFlowAfter: { token: RENDER_FLOW_AFTER_TOKEN, optional: true },
|
|
195
196
|
logger: LOGGER_TOKEN,
|
|
197
|
+
fetchWebpackStats: FETCH_WEBPACK_STATS_TOKEN,
|
|
196
198
|
},
|
|
197
199
|
}),
|
|
198
200
|
provide({
|
|
@@ -274,6 +276,10 @@ Page Error Boundary will be rendered for the client`,
|
|
|
274
276
|
createCache: CREATE_CACHE_TOKEN,
|
|
275
277
|
},
|
|
276
278
|
}),
|
|
279
|
+
provide({
|
|
280
|
+
provide: FETCH_WEBPACK_STATS_TOKEN,
|
|
281
|
+
useValue: fetchWebpackStats,
|
|
282
|
+
}),
|
|
277
283
|
],
|
|
278
284
|
})
|
|
279
285
|
], RenderModule);
|
package/lib/server.js
CHANGED
|
@@ -20,6 +20,7 @@ var htmlPageSchema = require('./server/htmlPageSchema.js');
|
|
|
20
20
|
var ReactRenderServer = require('./server/ReactRenderServer.js');
|
|
21
21
|
var LayoutModule = require('./shared/LayoutModule.js');
|
|
22
22
|
var providers = require('./shared/providers.js');
|
|
23
|
+
var fetchWebpackStats = require('./server/blocks/utils/fetchWebpackStats.js');
|
|
23
24
|
|
|
24
25
|
var RenderModule_1;
|
|
25
26
|
const REQUEST_TTL = 5 * 60 * 1000;
|
|
@@ -194,6 +195,7 @@ Page Error Boundary will be rendered for the client`,
|
|
|
194
195
|
modern: tokensRender.MODERN_SATISFIES_TOKEN,
|
|
195
196
|
renderFlowAfter: { token: tokensRender.RENDER_FLOW_AFTER_TOKEN, optional: true },
|
|
196
197
|
logger: tokensCommon.LOGGER_TOKEN,
|
|
198
|
+
fetchWebpackStats: tokensRender.FETCH_WEBPACK_STATS_TOKEN,
|
|
197
199
|
},
|
|
198
200
|
}),
|
|
199
201
|
core.provide({
|
|
@@ -275,6 +277,10 @@ Page Error Boundary will be rendered for the client`,
|
|
|
275
277
|
createCache: tokensCommon.CREATE_CACHE_TOKEN,
|
|
276
278
|
},
|
|
277
279
|
}),
|
|
280
|
+
core.provide({
|
|
281
|
+
provide: tokensRender.FETCH_WEBPACK_STATS_TOKEN,
|
|
282
|
+
useValue: fetchWebpackStats.fetchWebpackStats,
|
|
283
|
+
}),
|
|
278
284
|
],
|
|
279
285
|
})
|
|
280
286
|
], exports.RenderModule);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-render",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.90.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"@tinkoff/layout-factory": "0.3.8",
|
|
27
27
|
"@tinkoff/errors": "0.3.8",
|
|
28
28
|
"@tinkoff/url": "0.8.6",
|
|
29
|
-
"@tinkoff/user-agent": "0.4.
|
|
30
|
-
"@tramvai/module-client-hints": "2.
|
|
31
|
-
"@tramvai/module-router": "2.
|
|
32
|
-
"@tramvai/react": "2.
|
|
29
|
+
"@tinkoff/user-agent": "0.4.229",
|
|
30
|
+
"@tramvai/module-client-hints": "2.90.0",
|
|
31
|
+
"@tramvai/module-router": "2.90.0",
|
|
32
|
+
"@tramvai/react": "2.90.0",
|
|
33
33
|
"@tramvai/safe-strings": "0.5.8",
|
|
34
|
-
"@tramvai/tokens-render": "2.
|
|
35
|
-
"@tramvai/experiments": "2.
|
|
34
|
+
"@tramvai/tokens-render": "2.90.0",
|
|
35
|
+
"@tramvai/experiments": "2.90.0",
|
|
36
36
|
"@types/loadable__server": "^5.12.6",
|
|
37
37
|
"node-fetch": "^2.6.1"
|
|
38
38
|
},
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@tinkoff/dippy": "0.8.15",
|
|
41
41
|
"@tinkoff/utils": "^2.1.2",
|
|
42
42
|
"@tinkoff/react-hooks": "0.1.6",
|
|
43
|
-
"@tramvai/cli": "2.
|
|
44
|
-
"@tramvai/core": "2.
|
|
45
|
-
"@tramvai/module-common": "2.
|
|
46
|
-
"@tramvai/state": "2.
|
|
47
|
-
"@tramvai/test-helpers": "2.
|
|
48
|
-
"@tramvai/tokens-common": "2.
|
|
49
|
-
"@tramvai/tokens-router": "2.
|
|
50
|
-
"@tramvai/tokens-server-private": "2.
|
|
43
|
+
"@tramvai/cli": "2.90.0",
|
|
44
|
+
"@tramvai/core": "2.90.0",
|
|
45
|
+
"@tramvai/module-common": "2.90.0",
|
|
46
|
+
"@tramvai/state": "2.90.0",
|
|
47
|
+
"@tramvai/test-helpers": "2.90.0",
|
|
48
|
+
"@tramvai/tokens-common": "2.90.0",
|
|
49
|
+
"@tramvai/tokens-router": "2.90.0",
|
|
50
|
+
"@tramvai/tokens-server-private": "2.90.0",
|
|
51
51
|
"express": "^4.17.1",
|
|
52
52
|
"prop-types": "^15.6.2",
|
|
53
53
|
"react": ">=16.14.0",
|
package/tests.js
CHANGED
|
@@ -20,33 +20,13 @@ require('@tinkoff/utils/object/has');
|
|
|
20
20
|
require('@tinkoff/utils/array/last');
|
|
21
21
|
require('@tramvai/experiments');
|
|
22
22
|
require('@tinkoff/utils/array/uniq');
|
|
23
|
-
var path = require('path');
|
|
24
23
|
require('@tinkoff/utils/array/each');
|
|
25
24
|
require('@tinkoff/utils/object/path');
|
|
26
25
|
|
|
27
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
27
|
|
|
29
|
-
function _interopNamespace(e) {
|
|
30
|
-
if (e && e.__esModule) return e;
|
|
31
|
-
var n = Object.create(null);
|
|
32
|
-
if (e) {
|
|
33
|
-
Object.keys(e).forEach(function (k) {
|
|
34
|
-
if (k !== 'default') {
|
|
35
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
36
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () { return e[k]; }
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
n["default"] = e;
|
|
44
|
-
return n;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
28
|
var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
48
29
|
var toArray__default = /*#__PURE__*/_interopDefaultLegacy(toArray);
|
|
49
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
50
30
|
|
|
51
31
|
class ResourcesRegistry {
|
|
52
32
|
constructor({ resourceInliner }) {
|
|
@@ -90,64 +70,6 @@ const RESOURCE_INLINER = dippy.createToken('resourceInliner');
|
|
|
90
70
|
*/
|
|
91
71
|
dippy.createToken('resourcesRegistryCache');
|
|
92
72
|
|
|
93
|
-
const requireFunc =
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
96
|
-
|
|
97
|
-
let appConfig;
|
|
98
|
-
try {
|
|
99
|
-
appConfig = require('@tramvai/cli/lib/external/config').appConfig;
|
|
100
|
-
}
|
|
101
|
-
catch (e) { }
|
|
102
|
-
if (process.env.NODE_ENV === 'development') ;
|
|
103
|
-
if (process.env.NODE_ENV === 'test') ;
|
|
104
|
-
if (process.env.NODE_ENV === 'production') {
|
|
105
|
-
const SEARCH_PATHS = [process.cwd(), __dirname];
|
|
106
|
-
const webpackStats = (fileName) => {
|
|
107
|
-
let stats;
|
|
108
|
-
for (const dir of SEARCH_PATHS) {
|
|
109
|
-
try {
|
|
110
|
-
const statsPath = path__namespace.resolve(dir, fileName);
|
|
111
|
-
stats = requireFunc(statsPath);
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
// ignore errors as this function is used to load stats for several optional destinations
|
|
116
|
-
// and these destinations may not have stats file
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!stats) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (!process.env.ASSETS_PREFIX) {
|
|
123
|
-
if (process.env.STATIC_PREFIX) {
|
|
124
|
-
throw new Error('Required env variable "ASSETS_PREFIX" is not set. Instead of using "STATIC_PREFIX" env please define "ASSETS_PREFIX: STATIC_PREFIX + /compiled"');
|
|
125
|
-
}
|
|
126
|
-
throw new Error('Required env variable "ASSETS_PREFIX" is not set');
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
...stats,
|
|
130
|
-
publicPath: process.env.ASSETS_PREFIX,
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
const statsLegacy = webpackStats('stats.json');
|
|
134
|
-
webpackStats('stats.modern.json') || statsLegacy;
|
|
135
|
-
if (!statsLegacy) {
|
|
136
|
-
throw new Error(`Cannot find stats.json.
|
|
137
|
-
It should be placed in one of the next places:
|
|
138
|
-
${SEARCH_PATHS.join('\n\t')}
|
|
139
|
-
In case it happens on deployment:
|
|
140
|
-
- In case you are using two independent jobs for building app
|
|
141
|
-
- Either do not split build command by two independent jobs and use one common job with "tramvai build" command without --buildType
|
|
142
|
-
- Or copy stats.json (and stats.modern.json if present) file from client build output to server output by yourself in your CI
|
|
143
|
-
- Otherwise report issue to tramvai team
|
|
144
|
-
In case it happens locally:
|
|
145
|
-
- prefer to use command "tramvai start-prod" to test prod-build locally
|
|
146
|
-
- copy stats.json next to built server.js file
|
|
147
|
-
`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
73
|
const formatAttributes = (htmlAttrs, target) => {
|
|
152
74
|
if (!htmlAttrs) {
|
|
153
75
|
return '';
|