@modern-js/runtime 2.60.3 → 2.60.4
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.
|
@@ -110,10 +110,15 @@ class LoadableCollector {
|
|
|
110
110
|
nonce,
|
|
111
111
|
...scriptLoadingAtr
|
|
112
112
|
}));
|
|
113
|
+
const jsScriptRegExp = /<script .*?src="([^"]+)".*?>/g;
|
|
114
|
+
const matchs = template.matchAll(jsScriptRegExp);
|
|
115
|
+
const existedScript = [];
|
|
116
|
+
for (const match of matchs) {
|
|
117
|
+
existedScript.push(match[1]);
|
|
118
|
+
}
|
|
113
119
|
const scripts = await Promise.all(chunks.filter((chunk) => {
|
|
114
120
|
var _this_existsAssets;
|
|
115
|
-
|
|
116
|
-
return !jsChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
121
|
+
return !existedScript.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
117
122
|
}).map(async (chunk) => {
|
|
118
123
|
const script = `<script${attributes} src="${chunk.url}"></script>`;
|
|
119
124
|
if ((0, import_utils.checkIsNode)() && checkIsInline(chunk, enableInlineScripts)) {
|
|
@@ -130,10 +135,15 @@ class LoadableCollector {
|
|
|
130
135
|
const { template, chunkSet, config } = this.options;
|
|
131
136
|
const { enableInlineStyles } = config;
|
|
132
137
|
const atrributes = (0, import_utils.attributesToString)(this.generateAttributes());
|
|
138
|
+
const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
|
|
139
|
+
const matchs = template.matchAll(linkRegExp);
|
|
140
|
+
const existedLinks = [];
|
|
141
|
+
for (const match of matchs) {
|
|
142
|
+
existedLinks.push(match[1]);
|
|
143
|
+
}
|
|
133
144
|
const css = await Promise.all(chunks.filter((chunk) => {
|
|
134
145
|
var _this_existsAssets;
|
|
135
|
-
|
|
136
|
-
return !cssChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
146
|
+
return !existedLinks.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
137
147
|
}).map(async (chunk) => {
|
|
138
148
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
139
149
|
if ((0, import_utils.checkIsNode)() && checkIsInline(chunk, enableInlineStyles)) {
|
|
@@ -133,7 +133,7 @@ var LoadableCollector = /* @__PURE__ */ function() {
|
|
|
133
133
|
_proto.emitScriptAssets = function emitScriptAssets(chunks) {
|
|
134
134
|
var _this = this;
|
|
135
135
|
return _async_to_generator(function() {
|
|
136
|
-
var _this_options, template, nonce, chunkSet, config, _config_scriptLoading, scriptLoading, enableInlineScripts, scriptLoadingAtr, attributes, scripts;
|
|
136
|
+
var _this_options, template, nonce, chunkSet, config, _config_scriptLoading, scriptLoading, enableInlineScripts, scriptLoadingAtr, attributes, jsScriptRegExp, matchs, existedScript, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, match, scripts;
|
|
137
137
|
return _ts_generator(this, function(_state) {
|
|
138
138
|
switch (_state.label) {
|
|
139
139
|
case 0:
|
|
@@ -147,12 +147,34 @@ var LoadableCollector = /* @__PURE__ */ function() {
|
|
|
147
147
|
attributes = attributesToString(_this.generateAttributes(_object_spread({
|
|
148
148
|
nonce
|
|
149
149
|
}, scriptLoadingAtr)));
|
|
150
|
+
jsScriptRegExp = /<script .*?src="([^"]+)".*?>/g;
|
|
151
|
+
matchs = template.matchAll(jsScriptRegExp);
|
|
152
|
+
existedScript = [];
|
|
153
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
154
|
+
try {
|
|
155
|
+
for (_iterator = matchs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
156
|
+
match = _step.value;
|
|
157
|
+
existedScript.push(match[1]);
|
|
158
|
+
}
|
|
159
|
+
} catch (err) {
|
|
160
|
+
_didIteratorError = true;
|
|
161
|
+
_iteratorError = err;
|
|
162
|
+
} finally {
|
|
163
|
+
try {
|
|
164
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
165
|
+
_iterator.return();
|
|
166
|
+
}
|
|
167
|
+
} finally {
|
|
168
|
+
if (_didIteratorError) {
|
|
169
|
+
throw _iteratorError;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
150
173
|
return [
|
|
151
174
|
4,
|
|
152
175
|
Promise.all(chunks.filter(function(chunk) {
|
|
153
176
|
var _this_existsAssets;
|
|
154
|
-
|
|
155
|
-
return !jsChunkReg.test(template) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
177
|
+
return !existedScript.includes(chunk.url) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
156
178
|
}).map(function() {
|
|
157
179
|
var _ref = _async_to_generator(function(chunk) {
|
|
158
180
|
var script;
|
|
@@ -198,19 +220,41 @@ var LoadableCollector = /* @__PURE__ */ function() {
|
|
|
198
220
|
_proto.emitStyleAssets = function emitStyleAssets(chunks) {
|
|
199
221
|
var _this = this;
|
|
200
222
|
return _async_to_generator(function() {
|
|
201
|
-
var _this_options, template, chunkSet, config, enableInlineStyles, atrributes, css;
|
|
223
|
+
var _this_options, template, chunkSet, config, enableInlineStyles, atrributes, linkRegExp, matchs, existedLinks, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, match, css;
|
|
202
224
|
return _ts_generator(this, function(_state) {
|
|
203
225
|
switch (_state.label) {
|
|
204
226
|
case 0:
|
|
205
227
|
_this_options = _this.options, template = _this_options.template, chunkSet = _this_options.chunkSet, config = _this_options.config;
|
|
206
228
|
enableInlineStyles = config.enableInlineStyles;
|
|
207
229
|
atrributes = attributesToString(_this.generateAttributes());
|
|
230
|
+
linkRegExp = /<link .*?href="([^"]+)".*?>/g;
|
|
231
|
+
matchs = template.matchAll(linkRegExp);
|
|
232
|
+
existedLinks = [];
|
|
233
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
234
|
+
try {
|
|
235
|
+
for (_iterator = matchs[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
236
|
+
match = _step.value;
|
|
237
|
+
existedLinks.push(match[1]);
|
|
238
|
+
}
|
|
239
|
+
} catch (err) {
|
|
240
|
+
_didIteratorError = true;
|
|
241
|
+
_iteratorError = err;
|
|
242
|
+
} finally {
|
|
243
|
+
try {
|
|
244
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
245
|
+
_iterator.return();
|
|
246
|
+
}
|
|
247
|
+
} finally {
|
|
248
|
+
if (_didIteratorError) {
|
|
249
|
+
throw _iteratorError;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
208
253
|
return [
|
|
209
254
|
4,
|
|
210
255
|
Promise.all(chunks.filter(function(chunk) {
|
|
211
256
|
var _this_existsAssets;
|
|
212
|
-
|
|
213
|
-
return !cssChunkReg.test(template) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
257
|
+
return !existedLinks.includes(chunk.url) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
214
258
|
}).map(function() {
|
|
215
259
|
var _ref = _async_to_generator(function(chunk) {
|
|
216
260
|
var link;
|
|
@@ -77,10 +77,15 @@ class LoadableCollector {
|
|
|
77
77
|
nonce,
|
|
78
78
|
...scriptLoadingAtr
|
|
79
79
|
}));
|
|
80
|
+
const jsScriptRegExp = /<script .*?src="([^"]+)".*?>/g;
|
|
81
|
+
const matchs = template.matchAll(jsScriptRegExp);
|
|
82
|
+
const existedScript = [];
|
|
83
|
+
for (const match of matchs) {
|
|
84
|
+
existedScript.push(match[1]);
|
|
85
|
+
}
|
|
80
86
|
const scripts = await Promise.all(chunks.filter((chunk) => {
|
|
81
87
|
var _this_existsAssets;
|
|
82
|
-
|
|
83
|
-
return !jsChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
88
|
+
return !existedScript.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
84
89
|
}).map(async (chunk) => {
|
|
85
90
|
const script = `<script${attributes} src="${chunk.url}"></script>`;
|
|
86
91
|
if (checkIsNode() && checkIsInline(chunk, enableInlineScripts)) {
|
|
@@ -97,10 +102,15 @@ class LoadableCollector {
|
|
|
97
102
|
const { template, chunkSet, config } = this.options;
|
|
98
103
|
const { enableInlineStyles } = config;
|
|
99
104
|
const atrributes = attributesToString(this.generateAttributes());
|
|
105
|
+
const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
|
|
106
|
+
const matchs = template.matchAll(linkRegExp);
|
|
107
|
+
const existedLinks = [];
|
|
108
|
+
for (const match of matchs) {
|
|
109
|
+
existedLinks.push(match[1]);
|
|
110
|
+
}
|
|
100
111
|
const css = await Promise.all(chunks.filter((chunk) => {
|
|
101
112
|
var _this_existsAssets;
|
|
102
|
-
|
|
103
|
-
return !cssChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
113
|
+
return !existedLinks.includes(chunk.url) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
|
|
104
114
|
}).map(async (chunk) => {
|
|
105
115
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
106
116
|
if (checkIsNode() && checkIsInline(chunk, enableInlineStyles)) {
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.60.
|
|
18
|
+
"version": "2.60.4",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"@types/loadable__component": "^5.13.4",
|
|
191
191
|
"@types/react-helmet": "^6.1.2",
|
|
192
192
|
"@types/styled-components": "^5.1.14",
|
|
193
|
-
"cookie": "0.
|
|
193
|
+
"cookie": "0.7.2",
|
|
194
194
|
"es-module-lexer": "^1.1.0",
|
|
195
195
|
"esbuild": "0.17.19",
|
|
196
196
|
"invariant": "^2.2.4",
|
|
@@ -199,11 +199,11 @@
|
|
|
199
199
|
"react-is": "^18",
|
|
200
200
|
"react-side-effect": "^2.1.1",
|
|
201
201
|
"styled-components": "^5.3.1",
|
|
202
|
-
"@modern-js/plugin": "2.60.
|
|
203
|
-
"@modern-js/plugin-data-loader": "2.60.
|
|
204
|
-
"@modern-js/runtime-utils": "2.60.
|
|
205
|
-
"@modern-js/
|
|
206
|
-
"@modern-js/
|
|
202
|
+
"@modern-js/plugin": "2.60.4",
|
|
203
|
+
"@modern-js/plugin-data-loader": "2.60.4",
|
|
204
|
+
"@modern-js/runtime-utils": "2.60.4",
|
|
205
|
+
"@modern-js/types": "2.60.4",
|
|
206
|
+
"@modern-js/utils": "2.60.4"
|
|
207
207
|
},
|
|
208
208
|
"peerDependencies": {
|
|
209
209
|
"react": ">=17",
|
|
@@ -226,10 +226,10 @@
|
|
|
226
226
|
"ts-jest": "^29.1.0",
|
|
227
227
|
"typescript": "^5",
|
|
228
228
|
"webpack": "^5.95.0",
|
|
229
|
-
"@modern-js/app-tools": "2.60.
|
|
230
|
-
"@scripts/build": "2.60.
|
|
231
|
-
"@modern-js/core": "2.60.
|
|
232
|
-
"@scripts/jest-config": "2.60.
|
|
229
|
+
"@modern-js/app-tools": "2.60.4",
|
|
230
|
+
"@scripts/build": "2.60.4",
|
|
231
|
+
"@modern-js/core": "2.60.4",
|
|
232
|
+
"@scripts/jest-config": "2.60.4"
|
|
233
233
|
},
|
|
234
234
|
"sideEffects": false,
|
|
235
235
|
"publishConfig": {
|