@modern-js/runtime 2.24.0 → 2.24.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @modern-js/runtime
2
2
 
3
+ ## 2.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 13354d3356: fix(runtime): ssr link tag add attrs error
8
+ fix(runtime): ssr link 标签添加错误的属性
9
+ - @modern-js/plugin@2.24.1
10
+ - @modern-js/types@2.24.1
11
+ - @modern-js/utils@2.24.1
12
+
3
13
  ## 2.24.0
4
14
 
5
15
  ### Patch Changes
@@ -9,8 +9,7 @@ Object.defineProperty(exports, "toHtml", {
9
9
  }
10
10
  });
11
11
  const _server = require("@loadable/server");
12
- const _utils = require("../../utils");
13
- const _utils1 = require("../utils");
12
+ const _utils = require("../utils");
14
13
  const extname = (uri) => {
15
14
  if (typeof uri !== "string" || !uri.includes(".")) {
16
15
  return "";
@@ -18,7 +17,7 @@ const extname = (uri) => {
18
17
  return `.${uri === null || uri === void 0 ? void 0 : uri.split(".").pop()}` || "";
19
18
  };
20
19
  const toHtml = (jsx, renderer, next) => {
21
- const { stats, result: { chunksMap }, host, config = {}, nonce } = renderer;
20
+ const { stats, result: { chunksMap }, config = {}, nonce } = renderer;
22
21
  if (!stats || chunksMap.js) {
23
22
  return next(jsx);
24
23
  }
@@ -30,12 +29,12 @@ const toHtml = (jsx, renderer, next) => {
30
29
  });
31
30
  const html = next(extractor.collectChunks(jsx));
32
31
  const chunks = extractor.getChunkAssets(extractor.chunks);
33
- chunksMap.js = (chunksMap.js || "") + (0, _utils1.getLoadableScripts)(extractor);
32
+ chunksMap.js = (chunksMap.js || "") + (0, _utils.getLoadableScripts)(extractor);
34
33
  for (const v of chunks) {
35
34
  const fileType = extname(v.url).slice(1);
36
35
  const attributes = {};
37
36
  const { crossorigin, scriptLoading = "defer" } = config;
38
- if (crossorigin && (0, _utils.isCrossOrigin)(v.url, host)) {
37
+ if (crossorigin) {
39
38
  attributes.crossorigin = crossorigin === true ? "anonymous" : crossorigin;
40
39
  }
41
40
  switch (scriptLoading) {
@@ -49,10 +48,11 @@ const toHtml = (jsx, renderer, next) => {
49
48
  }
50
49
  if (fileType === "js") {
51
50
  attributes.nonce = nonce;
52
- const attrsStr = (0, _utils1.attributesToString)(attributes);
51
+ const attrsStr = (0, _utils.attributesToString)(attributes);
53
52
  chunksMap[fileType] += `<script${attrsStr} src="${v.url}"></script>`;
54
53
  } else if (fileType === "css") {
55
- chunksMap[fileType] += `<link${attributes} href="${v.url}" rel="stylesheet" />`;
54
+ const attrsStr = (0, _utils.attributesToString)(attributes);
55
+ chunksMap[fileType] += `<link${attrsStr} href="${v.url}" rel="stylesheet" />`;
56
56
  }
57
57
  }
58
58
  return html;
@@ -21,9 +21,6 @@ _export(exports, {
21
21
  },
22
22
  mockResponse: function() {
23
23
  return mockResponse;
24
- },
25
- isCrossOrigin: function() {
26
- return isCrossOrigin;
27
24
  }
28
25
  });
29
26
  const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
@@ -75,12 +72,3 @@ const mockResponse = () => {
75
72
  }
76
73
  };
77
74
  };
78
- const isCrossOrigin = (url = "", base) => {
79
- if (url.startsWith("/") || url.startsWith("./")) {
80
- return false;
81
- } else if (!url.includes(base)) {
82
- return true;
83
- } else {
84
- return false;
85
- }
86
- };
@@ -1,5 +1,4 @@
1
1
  import { ChunkExtractor } from "@loadable/server";
2
- import { isCrossOrigin } from "../../utils";
3
2
  import { attributesToString, getLoadableScripts } from "../utils";
4
3
  var extname = function(uri) {
5
4
  if (typeof uri !== "string" || !uri.includes(".")) {
@@ -8,7 +7,7 @@ var extname = function(uri) {
8
7
  return ".".concat(uri === null || uri === void 0 ? void 0 : uri.split(".").pop()) || "";
9
8
  };
10
9
  export var toHtml = function(jsx, renderer, next) {
11
- var stats = renderer.stats, chunksMap = renderer.result.chunksMap, host = renderer.host, _renderer_config = renderer.config, config = _renderer_config === void 0 ? {} : _renderer_config, nonce = renderer.nonce;
10
+ var stats = renderer.stats, chunksMap = renderer.result.chunksMap, _renderer_config = renderer.config, config = _renderer_config === void 0 ? {} : _renderer_config, nonce = renderer.nonce;
12
11
  if (!stats || chunksMap.js) {
13
12
  return next(jsx);
14
13
  }
@@ -28,7 +27,7 @@ export var toHtml = function(jsx, renderer, next) {
28
27
  var fileType = extname(v.url).slice(1);
29
28
  var attributes = {};
30
29
  var crossorigin = config.crossorigin, _config_scriptLoading = config.scriptLoading, scriptLoading = _config_scriptLoading === void 0 ? "defer" : _config_scriptLoading;
31
- if (crossorigin && isCrossOrigin(v.url, host)) {
30
+ if (crossorigin) {
32
31
  attributes.crossorigin = crossorigin === true ? "anonymous" : crossorigin;
33
32
  }
34
33
  switch (scriptLoading) {
@@ -45,7 +44,8 @@ export var toHtml = function(jsx, renderer, next) {
45
44
  var attrsStr = attributesToString(attributes);
46
45
  chunksMap[fileType] += "<script".concat(attrsStr, ' src="').concat(v.url, '"></script>');
47
46
  } else if (fileType === "css") {
48
- chunksMap[fileType] += "<link".concat(attributes, ' href="').concat(v.url, '" rel="stylesheet" />');
47
+ var attrsStr1 = attributesToString(attributes);
48
+ chunksMap[fileType] += "<link".concat(attrsStr1, ' href="').concat(v.url, '" rel="stylesheet" />');
49
49
  }
50
50
  }
51
51
  } catch (err) {
@@ -51,13 +51,3 @@ export var mockResponse = function() {
51
51
  }
52
52
  };
53
53
  };
54
- export var isCrossOrigin = function() {
55
- var url = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", base = arguments.length > 1 ? arguments[1] : void 0;
56
- if (url.startsWith("/") || url.startsWith("./")) {
57
- return false;
58
- } else if (!url.includes(base)) {
59
- return true;
60
- } else {
61
- return false;
62
- }
63
- };
@@ -1,5 +1,4 @@
1
1
  import { ChunkExtractor } from "@loadable/server";
2
- import { isCrossOrigin } from "../../utils";
3
2
  import { attributesToString, getLoadableScripts } from "../utils";
4
3
  const extname = (uri) => {
5
4
  if (typeof uri !== "string" || !uri.includes(".")) {
@@ -8,7 +7,7 @@ const extname = (uri) => {
8
7
  return `.${uri === null || uri === void 0 ? void 0 : uri.split(".").pop()}` || "";
9
8
  };
10
9
  export const toHtml = (jsx, renderer, next) => {
11
- const { stats, result: { chunksMap }, host, config = {}, nonce } = renderer;
10
+ const { stats, result: { chunksMap }, config = {}, nonce } = renderer;
12
11
  if (!stats || chunksMap.js) {
13
12
  return next(jsx);
14
13
  }
@@ -25,7 +24,7 @@ export const toHtml = (jsx, renderer, next) => {
25
24
  const fileType = extname(v.url).slice(1);
26
25
  const attributes = {};
27
26
  const { crossorigin, scriptLoading = "defer" } = config;
28
- if (crossorigin && isCrossOrigin(v.url, host)) {
27
+ if (crossorigin) {
29
28
  attributes.crossorigin = crossorigin === true ? "anonymous" : crossorigin;
30
29
  }
31
30
  switch (scriptLoading) {
@@ -42,7 +41,8 @@ export const toHtml = (jsx, renderer, next) => {
42
41
  const attrsStr = attributesToString(attributes);
43
42
  chunksMap[fileType] += `<script${attrsStr} src="${v.url}"></script>`;
44
43
  } else if (fileType === "css") {
45
- chunksMap[fileType] += `<link${attributes} href="${v.url}" rel="stylesheet" />`;
44
+ const attrsStr = attributesToString(attributes);
45
+ chunksMap[fileType] += `<link${attrsStr} href="${v.url}" rel="stylesheet" />`;
46
46
  }
47
47
  }
48
48
  return html;
@@ -46,12 +46,3 @@ export const mockResponse = () => {
46
46
  }
47
47
  };
48
48
  };
49
- export const isCrossOrigin = (url = "", base) => {
50
- if (url.startsWith("/") || url.startsWith("./")) {
51
- return false;
52
- } else if (!url.includes(base)) {
53
- return true;
54
- } else {
55
- return false;
56
- }
57
- };
@@ -7,5 +7,4 @@ export declare const mockResponse: () => {
7
7
  setHeader(): void;
8
8
  status(): void;
9
9
  readonly locals: {};
10
- };
11
- export declare const isCrossOrigin: (url: string | undefined, base: string) => boolean;
10
+ };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.24.0",
18
+ "version": "2.24.1",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -169,9 +169,9 @@
169
169
  "redux-logger": "^3.0.6",
170
170
  "styled-components": "^5.3.1",
171
171
  "@swc/helpers": "0.5.1",
172
- "@modern-js/plugin": "2.24.0",
173
- "@modern-js/utils": "2.24.0",
174
- "@modern-js/types": "2.24.0"
172
+ "@modern-js/types": "2.24.1",
173
+ "@modern-js/utils": "2.24.1",
174
+ "@modern-js/plugin": "2.24.1"
175
175
  },
176
176
  "peerDependencies": {
177
177
  "react": ">=17",
@@ -192,11 +192,11 @@
192
192
  "ts-jest": "^29.1.0",
193
193
  "typescript": "^5",
194
194
  "webpack": "^5.82.1",
195
- "@modern-js/app-tools": "2.24.0",
196
- "@modern-js/core": "2.24.0",
197
- "@modern-js/server-core": "2.24.0",
198
- "@scripts/build": "2.24.0",
199
- "@scripts/jest-config": "2.24.0"
195
+ "@modern-js/core": "2.24.1",
196
+ "@modern-js/server-core": "2.24.1",
197
+ "@modern-js/app-tools": "2.24.1",
198
+ "@scripts/build": "2.24.1",
199
+ "@scripts/jest-config": "2.24.1"
200
200
  },
201
201
  "sideEffects": false,
202
202
  "modernConfig": {},