@tramvai/module-render 4.41.100 → 4.41.107

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.
@@ -26,7 +26,7 @@ const bundleResource = async ({ bundle, modern, extractor, pageComponent, fetchW
26
26
  ? fileSystemPageToWebpackChunkName(pageComponent)
27
27
  : last(bundle.split('/'));
28
28
  const webpackStats = await fetchWebpackStats({ modern });
29
- const { publicPath, assetsByChunkName } = webpackStats;
29
+ const { publicPath, assetsByChunkName, integrities = {} } = webpackStats;
30
30
  const bundles = has('common-chunk', assetsByChunkName)
31
31
  ? ['common-chunk', chunkNameFromBundle]
32
32
  : [chunkNameFromBundle];
@@ -48,31 +48,34 @@ const bundleResource = async ({ bundle, modern, extractor, pageComponent, fetchW
48
48
  // defer scripts is not suitable for React streaming, we need to ability to run them as early as possible
49
49
  // https://github.com/reactwg/react-18/discussions/114
50
50
  const scriptTypeAttr = renderMode === 'streaming' ? asyncScriptAttrs : deferScriptAttrs;
51
- styles.map((style) => result.push({
51
+ styles.forEach((style) => result.push({
52
52
  type: ResourceType.style,
53
53
  slot: ResourceSlot.HEAD_CORE_STYLES,
54
54
  payload: genHref(style),
55
55
  attrs: {
56
+ ...(integrities[style] ? { integrity: integrities[style] } : {}),
56
57
  'data-critical': 'true',
57
58
  // looks like we don't need this scripts preload at all, but also it is official recommendation for streaming
58
59
  // https://github.com/reactwg/react-18/discussions/114
59
60
  onload: renderMode === 'streaming' ? null : `${PRELOAD_JS}()`,
60
61
  },
61
62
  }));
62
- baseScripts.map((script) => result.push({
63
+ baseScripts.forEach((script) => result.push({
63
64
  type: ResourceType.script,
64
65
  slot: ResourceSlot.HEAD_CORE_SCRIPTS,
65
66
  payload: genHref(script),
66
67
  attrs: {
68
+ ...(integrities[script] ? { integrity: integrities[script] } : {}),
67
69
  'data-critical': 'true',
68
70
  ...scriptTypeAttr,
69
71
  },
70
72
  }));
71
- scripts.map((script) => result.push({
73
+ scripts.forEach((script) => result.push({
72
74
  type: ResourceType.script,
73
75
  slot: ResourceSlot.HEAD_CORE_SCRIPTS,
74
76
  payload: genHref(script),
75
77
  attrs: {
78
+ ...(integrities[script] ? { integrity: integrities[script] } : {}),
76
79
  'data-critical': 'true',
77
80
  ...scriptTypeAttr,
78
81
  },
@@ -35,7 +35,7 @@ const bundleResource = async ({ bundle, modern, extractor, pageComponent, fetchW
35
35
  ? experiments.fileSystemPageToWebpackChunkName(pageComponent)
36
36
  : last__default["default"](bundle.split('/'));
37
37
  const webpackStats = await fetchWebpackStats({ modern });
38
- const { publicPath, assetsByChunkName } = webpackStats;
38
+ const { publicPath, assetsByChunkName, integrities = {} } = webpackStats;
39
39
  const bundles = has__default["default"]('common-chunk', assetsByChunkName)
40
40
  ? ['common-chunk', chunkNameFromBundle]
41
41
  : [chunkNameFromBundle];
@@ -57,31 +57,34 @@ const bundleResource = async ({ bundle, modern, extractor, pageComponent, fetchW
57
57
  // defer scripts is not suitable for React streaming, we need to ability to run them as early as possible
58
58
  // https://github.com/reactwg/react-18/discussions/114
59
59
  const scriptTypeAttr = renderMode === 'streaming' ? asyncScriptAttrs : deferScriptAttrs;
60
- styles.map((style) => result.push({
60
+ styles.forEach((style) => result.push({
61
61
  type: tokensRender.ResourceType.style,
62
62
  slot: tokensRender.ResourceSlot.HEAD_CORE_STYLES,
63
63
  payload: genHref(style),
64
64
  attrs: {
65
+ ...(integrities[style] ? { integrity: integrities[style] } : {}),
65
66
  'data-critical': 'true',
66
67
  // looks like we don't need this scripts preload at all, but also it is official recommendation for streaming
67
68
  // https://github.com/reactwg/react-18/discussions/114
68
69
  onload: renderMode === 'streaming' ? null : `${performance.PRELOAD_JS}()`,
69
70
  },
70
71
  }));
71
- baseScripts.map((script) => result.push({
72
+ baseScripts.forEach((script) => result.push({
72
73
  type: tokensRender.ResourceType.script,
73
74
  slot: tokensRender.ResourceSlot.HEAD_CORE_SCRIPTS,
74
75
  payload: genHref(script),
75
76
  attrs: {
77
+ ...(integrities[script] ? { integrity: integrities[script] } : {}),
76
78
  'data-critical': 'true',
77
79
  ...scriptTypeAttr,
78
80
  },
79
81
  }));
80
- scripts.map((script) => result.push({
82
+ scripts.forEach((script) => result.push({
81
83
  type: tokensRender.ResourceType.script,
82
84
  slot: tokensRender.ResourceSlot.HEAD_CORE_SCRIPTS,
83
85
  payload: genHref(script),
84
86
  attrs: {
87
+ ...(integrities[script] ? { integrity: integrities[script] } : {}),
85
88
  'data-critical': 'true',
86
89
  ...scriptTypeAttr,
87
90
  },
@@ -37,6 +37,7 @@ if (process.env.NODE_ENV === 'test') {
37
37
  publicPath: 'http://localhost:4000/',
38
38
  assetsByChunkName: {},
39
39
  entrypoints: {},
40
+ integrities: {},
40
41
  });
41
42
  };
42
43
  }
@@ -64,6 +64,7 @@ if (process.env.NODE_ENV === 'test') {
64
64
  publicPath: 'http://localhost:4000/',
65
65
  assetsByChunkName: {},
66
66
  entrypoints: {},
67
+ integrities: {},
67
68
  });
68
69
  };
69
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-render",
3
- "version": "4.41.100",
3
+ "version": "4.41.107",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -26,15 +26,15 @@
26
26
  "@tinkoff/layout-factory": "0.5.3",
27
27
  "@tinkoff/errors": "0.5.3",
28
28
  "@tinkoff/url": "0.10.3",
29
- "@tinkoff/user-agent": "0.6.235",
29
+ "@tinkoff/user-agent": "0.6.242",
30
30
  "@tinkoff/request-core": "^0.10.0",
31
31
  "@tinkoff/request-plugin-protocol-http": "^0.12.1",
32
- "@tramvai/module-client-hints": "4.41.100",
33
- "@tramvai/module-router": "4.41.100",
34
- "@tramvai/react": "4.41.100",
32
+ "@tramvai/module-client-hints": "4.41.107",
33
+ "@tramvai/module-router": "4.41.107",
34
+ "@tramvai/react": "4.41.107",
35
35
  "@tramvai/safe-strings": "0.7.9",
36
- "@tramvai/tokens-render": "4.41.100",
37
- "@tramvai/experiments": "4.41.100",
36
+ "@tramvai/tokens-render": "4.41.107",
37
+ "@tramvai/experiments": "4.41.107",
38
38
  "@types/loadable__server": "^5.12.6",
39
39
  "node-fetch": "^2.6.1"
40
40
  },
@@ -42,14 +42,14 @@
42
42
  "@tinkoff/dippy": "0.10.11",
43
43
  "@tinkoff/utils": "^2.1.2",
44
44
  "@tinkoff/react-hooks": "0.3.3",
45
- "@tramvai/cli": "4.41.100",
46
- "@tramvai/core": "4.41.100",
47
- "@tramvai/module-common": "4.41.100",
48
- "@tramvai/state": "4.41.100",
49
- "@tramvai/test-helpers": "4.41.100",
50
- "@tramvai/tokens-common": "4.41.100",
51
- "@tramvai/tokens-router": "4.41.100",
52
- "@tramvai/tokens-server-private": "4.41.100",
45
+ "@tramvai/cli": "4.41.107",
46
+ "@tramvai/core": "4.41.107",
47
+ "@tramvai/module-common": "4.41.107",
48
+ "@tramvai/state": "4.41.107",
49
+ "@tramvai/test-helpers": "4.41.107",
50
+ "@tramvai/tokens-common": "4.41.107",
51
+ "@tramvai/tokens-router": "4.41.107",
52
+ "@tramvai/tokens-server-private": "4.41.107",
53
53
  "express": "^4.17.1",
54
54
  "prop-types": "^15.6.2",
55
55
  "react": ">=16.14.0",