@tramvai/module-render 4.3.0 → 4.4.1

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.
@@ -65,7 +65,7 @@ class PageBuilder {
65
65
  });
66
66
  }
67
67
  async fetchChunksInfo(extractor) {
68
- const { modern } = this;
68
+ const { modern, renderMode } = this;
69
69
  const { bundle, pageComponent } = this.pageService.getConfig();
70
70
  this.resourcesRegistry.register(await bundleResource({
71
71
  bundle,
@@ -79,6 +79,7 @@ class PageBuilder {
79
79
  condition: this.polyfillCondition,
80
80
  modern,
81
81
  fetchWebpackStats: this.fetchWebpackStats,
82
+ renderMode,
82
83
  }));
83
84
  }
84
85
  preloadBlock() {
@@ -73,7 +73,7 @@ class PageBuilder {
73
73
  });
74
74
  }
75
75
  async fetchChunksInfo(extractor) {
76
- const { modern } = this;
76
+ const { modern, renderMode } = this;
77
77
  const { bundle, pageComponent } = this.pageService.getConfig();
78
78
  this.resourcesRegistry.register(await bundleResource.bundleResource({
79
79
  bundle,
@@ -87,6 +87,7 @@ class PageBuilder {
87
87
  condition: this.polyfillCondition,
88
88
  modern,
89
89
  fetchWebpackStats: this.fetchWebpackStats,
90
+ renderMode,
90
91
  }));
91
92
  }
92
93
  preloadBlock() {
@@ -1,7 +1,8 @@
1
- import type { PageResource, FETCH_WEBPACK_STATS_TOKEN } from '@tramvai/tokens-render';
2
- export declare const polyfillResources: ({ condition, modern, fetchWebpackStats, }: {
1
+ import type { PageResource, FETCH_WEBPACK_STATS_TOKEN, REACT_SERVER_RENDER_MODE } from '@tramvai/tokens-render';
2
+ export declare const polyfillResources: ({ condition, modern, fetchWebpackStats, renderMode, }: {
3
3
  condition: string;
4
4
  modern: boolean;
5
5
  fetchWebpackStats: typeof FETCH_WEBPACK_STATS_TOKEN;
6
+ renderMode: typeof REACT_SERVER_RENDER_MODE;
6
7
  }) => Promise<PageResource[]>;
7
8
  //# sourceMappingURL=polyfill.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { ResourceType, ResourceSlot } from '@tramvai/tokens-render';
2
2
  import { flushFiles } from './utils/flushFiles.es.js';
3
3
 
4
- const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
4
+ const polyfillResources = async ({ condition, modern, fetchWebpackStats, renderMode, }) => {
5
5
  const webpackStats = await fetchWebpackStats({ modern });
6
6
  const { publicPath } = webpackStats;
7
7
  // получает файл полифилла из stats.json\stats.modern.json.
@@ -17,6 +17,9 @@ const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
17
17
  result.push({
18
18
  type: ResourceType.inlineScript,
19
19
  slot: ResourceSlot.HEAD_POLYFILLS,
20
+ // all scripts are "async" for streaming, so we need to guarantee that polyfills will be loaded before.
21
+ // will hurt performance, because polufills will block page rendering
22
+ // todo: research solution to use "async" for polyfills and wait this script in the application entry point
20
23
  payload: `(function (){
21
24
  var con;
22
25
  try {
@@ -24,7 +27,7 @@ const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
24
27
  } catch (e) {
25
28
  con = true;
26
29
  }
27
- if (con) { document.write('<script defer="defer" charset="utf-8" data-critical="true" crossorigin="anonymous" src="${href}"><\\/script>')}
30
+ if (con) { document.write('<script${renderMode === 'streaming' ? '' : ' defer="defer"'} charset="utf-8" data-critical="true" crossorigin="anonymous" src="${href}"><\\/script>')}
28
31
  })()`,
29
32
  });
30
33
  });
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tokensRender = require('@tramvai/tokens-render');
6
6
  var flushFiles = require('./utils/flushFiles.js');
7
7
 
8
- const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
8
+ const polyfillResources = async ({ condition, modern, fetchWebpackStats, renderMode, }) => {
9
9
  const webpackStats = await fetchWebpackStats({ modern });
10
10
  const { publicPath } = webpackStats;
11
11
  // получает файл полифилла из stats.json\stats.modern.json.
@@ -21,6 +21,9 @@ const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
21
21
  result.push({
22
22
  type: tokensRender.ResourceType.inlineScript,
23
23
  slot: tokensRender.ResourceSlot.HEAD_POLYFILLS,
24
+ // all scripts are "async" for streaming, so we need to guarantee that polyfills will be loaded before.
25
+ // will hurt performance, because polufills will block page rendering
26
+ // todo: research solution to use "async" for polyfills and wait this script in the application entry point
24
27
  payload: `(function (){
25
28
  var con;
26
29
  try {
@@ -28,7 +31,7 @@ const polyfillResources = async ({ condition, modern, fetchWebpackStats, }) => {
28
31
  } catch (e) {
29
32
  con = true;
30
33
  }
31
- if (con) { document.write('<script defer="defer" charset="utf-8" data-critical="true" crossorigin="anonymous" src="${href}"><\\/script>')}
34
+ if (con) { document.write('<script${renderMode === 'streaming' ? '' : ' defer="defer"'} charset="utf-8" data-critical="true" crossorigin="anonymous" src="${href}"><\\/script>')}
32
35
  })()`,
33
36
  });
34
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-render",
3
- "version": "4.3.0",
3
+ "version": "4.4.1",
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.5.1",
27
27
  "@tinkoff/errors": "0.5.1",
28
28
  "@tinkoff/url": "0.10.1",
29
- "@tinkoff/user-agent": "0.6.10",
30
- "@tramvai/module-client-hints": "4.3.0",
31
- "@tramvai/module-router": "4.3.0",
32
- "@tramvai/react": "4.3.0",
29
+ "@tinkoff/user-agent": "0.6.13",
30
+ "@tramvai/module-client-hints": "4.4.1",
31
+ "@tramvai/module-router": "4.4.1",
32
+ "@tramvai/react": "4.4.1",
33
33
  "@tramvai/safe-strings": "0.7.1",
34
- "@tramvai/tokens-render": "4.3.0",
35
- "@tramvai/experiments": "4.3.0",
34
+ "@tramvai/tokens-render": "4.4.1",
35
+ "@tramvai/experiments": "4.4.1",
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.10.2",
41
41
  "@tinkoff/utils": "^2.1.2",
42
42
  "@tinkoff/react-hooks": "0.3.1",
43
- "@tramvai/cli": "4.3.0",
44
- "@tramvai/core": "4.3.0",
45
- "@tramvai/module-common": "4.3.0",
46
- "@tramvai/state": "4.3.0",
47
- "@tramvai/test-helpers": "4.3.0",
48
- "@tramvai/tokens-common": "4.3.0",
49
- "@tramvai/tokens-router": "4.3.0",
50
- "@tramvai/tokens-server-private": "4.3.0",
43
+ "@tramvai/cli": "4.4.1",
44
+ "@tramvai/core": "4.4.1",
45
+ "@tramvai/module-common": "4.4.1",
46
+ "@tramvai/state": "4.4.1",
47
+ "@tramvai/test-helpers": "4.4.1",
48
+ "@tramvai/tokens-common": "4.4.1",
49
+ "@tramvai/tokens-router": "4.4.1",
50
+ "@tramvai/tokens-server-private": "4.4.1",
51
51
  "express": "^4.17.1",
52
52
  "prop-types": "^15.6.2",
53
53
  "react": ">=16.14.0",