@modern-js/runtime 2.63.2 → 2.63.3
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.
|
@@ -80,8 +80,18 @@ class LoadableCollector {
|
|
|
80
80
|
if (!this.extractor) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
const { extractor } = this;
|
|
84
|
-
const
|
|
83
|
+
const { extractor, options } = this;
|
|
84
|
+
const { entryName, config } = options;
|
|
85
|
+
const asyncChunks = [];
|
|
86
|
+
if (config.enableAsyncEntry) {
|
|
87
|
+
try {
|
|
88
|
+
asyncChunks.push(...extractor.getChunkAssets([
|
|
89
|
+
`async-${entryName}`
|
|
90
|
+
]));
|
|
91
|
+
} catch (e) {
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks));
|
|
85
95
|
const scriptChunks = generateChunks(chunks, "js");
|
|
86
96
|
const styleChunks = generateChunks(chunks, "css");
|
|
87
97
|
this.emitLoadableScripts(extractor);
|
|
@@ -132,7 +142,7 @@ class LoadableCollector {
|
|
|
132
142
|
chunkSet.jsChunk += scripts.filter((script) => Boolean(script)).join("");
|
|
133
143
|
}
|
|
134
144
|
async emitStyleAssets(chunks) {
|
|
135
|
-
const { template, chunkSet, config } = this.options;
|
|
145
|
+
const { template, chunkSet, config, entryName } = this.options;
|
|
136
146
|
const { enableInlineStyles } = config;
|
|
137
147
|
const atrributes = (0, import_utils.attributesToString)(this.generateAttributes());
|
|
138
148
|
const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
|
|
@@ -3,6 +3,7 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
|
3
3
|
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
4
4
|
import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
|
5
5
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
6
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
6
7
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
8
|
import { ChunkExtractor } from "@loadable/server";
|
|
8
9
|
import { attributesToString, checkIsNode } from "../utils";
|
|
@@ -83,7 +84,7 @@ var LoadableCollector = /* @__PURE__ */ function() {
|
|
|
83
84
|
_proto.effect = function effect() {
|
|
84
85
|
var _this = this;
|
|
85
86
|
return _async_to_generator(function() {
|
|
86
|
-
var extractor, chunks, scriptChunks, styleChunks;
|
|
87
|
+
var extractor, options, entryName, config, asyncChunks, _asyncChunks, chunks, scriptChunks, styleChunks;
|
|
87
88
|
return _ts_generator(this, function(_state) {
|
|
88
89
|
switch (_state.label) {
|
|
89
90
|
case 0:
|
|
@@ -92,8 +93,19 @@ var LoadableCollector = /* @__PURE__ */ function() {
|
|
|
92
93
|
2
|
|
93
94
|
];
|
|
94
95
|
}
|
|
95
|
-
extractor = _this.extractor;
|
|
96
|
-
|
|
96
|
+
extractor = _this.extractor, options = _this.options;
|
|
97
|
+
entryName = options.entryName, config = options.config;
|
|
98
|
+
asyncChunks = [];
|
|
99
|
+
if (config.enableAsyncEntry) {
|
|
100
|
+
try {
|
|
101
|
+
;
|
|
102
|
+
(_asyncChunks = asyncChunks).push.apply(_asyncChunks, _to_consumable_array(extractor.getChunkAssets([
|
|
103
|
+
"async-".concat(entryName)
|
|
104
|
+
])));
|
|
105
|
+
} catch (e) {
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks));
|
|
97
109
|
scriptChunks = generateChunks(chunks, "js");
|
|
98
110
|
styleChunks = generateChunks(chunks, "css");
|
|
99
111
|
_this.emitLoadableScripts(extractor);
|
|
@@ -220,11 +232,11 @@ var LoadableCollector = /* @__PURE__ */ function() {
|
|
|
220
232
|
_proto.emitStyleAssets = function emitStyleAssets(chunks) {
|
|
221
233
|
var _this = this;
|
|
222
234
|
return _async_to_generator(function() {
|
|
223
|
-
var _this_options, template, chunkSet, config, enableInlineStyles, atrributes, linkRegExp, matchs, existedLinks, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, match, css;
|
|
235
|
+
var _this_options, template, chunkSet, config, entryName, enableInlineStyles, atrributes, linkRegExp, matchs, existedLinks, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, match, css;
|
|
224
236
|
return _ts_generator(this, function(_state) {
|
|
225
237
|
switch (_state.label) {
|
|
226
238
|
case 0:
|
|
227
|
-
_this_options = _this.options, template = _this_options.template, chunkSet = _this_options.chunkSet, config = _this_options.config;
|
|
239
|
+
_this_options = _this.options, template = _this_options.template, chunkSet = _this_options.chunkSet, config = _this_options.config, entryName = _this_options.entryName;
|
|
228
240
|
enableInlineStyles = config.enableInlineStyles;
|
|
229
241
|
atrributes = attributesToString(_this.generateAttributes());
|
|
230
242
|
linkRegExp = /<link .*?href="([^"]+)".*?>/g;
|
|
@@ -47,8 +47,18 @@ class LoadableCollector {
|
|
|
47
47
|
if (!this.extractor) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const { extractor } = this;
|
|
51
|
-
const
|
|
50
|
+
const { extractor, options } = this;
|
|
51
|
+
const { entryName, config } = options;
|
|
52
|
+
const asyncChunks = [];
|
|
53
|
+
if (config.enableAsyncEntry) {
|
|
54
|
+
try {
|
|
55
|
+
asyncChunks.push(...extractor.getChunkAssets([
|
|
56
|
+
`async-${entryName}`
|
|
57
|
+
]));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks));
|
|
52
62
|
const scriptChunks = generateChunks(chunks, "js");
|
|
53
63
|
const styleChunks = generateChunks(chunks, "css");
|
|
54
64
|
this.emitLoadableScripts(extractor);
|
|
@@ -99,7 +109,7 @@ class LoadableCollector {
|
|
|
99
109
|
chunkSet.jsChunk += scripts.filter((script) => Boolean(script)).join("");
|
|
100
110
|
}
|
|
101
111
|
async emitStyleAssets(chunks) {
|
|
102
|
-
const { template, chunkSet, config } = this.options;
|
|
112
|
+
const { template, chunkSet, config, entryName } = this.options;
|
|
103
113
|
const { enableInlineStyles } = config;
|
|
104
114
|
const atrributes = attributesToString(this.generateAttributes());
|
|
105
115
|
const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
|
|
@@ -2,8 +2,8 @@ import type { ReactElement } from 'react';
|
|
|
2
2
|
import type { ChunkSet, Collector } from './types';
|
|
3
3
|
declare module '@loadable/server' {
|
|
4
4
|
interface ChunkExtractor {
|
|
5
|
-
chunks:
|
|
6
|
-
getChunkAssets: (chunks:
|
|
5
|
+
chunks: string[];
|
|
6
|
+
getChunkAssets: (chunks: string[]) => Chunk[];
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export interface LoadableCollectorOptions {
|
|
@@ -20,6 +20,7 @@ export interface LoadableCollectorConfig {
|
|
|
20
20
|
enableInlineStyles?: boolean | RegExp;
|
|
21
21
|
enableInlineScripts?: boolean | RegExp;
|
|
22
22
|
crossorigin?: boolean | 'anonymous' | 'use-credentials';
|
|
23
|
+
enableAsyncEntry?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare class LoadableCollector implements Collector {
|
|
25
26
|
private options;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.63.
|
|
18
|
+
"version": "2.63.3",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -200,11 +200,11 @@
|
|
|
200
200
|
"react-is": "^18",
|
|
201
201
|
"react-side-effect": "^2.1.1",
|
|
202
202
|
"styled-components": "^5.3.1",
|
|
203
|
-
"@modern-js/plugin": "2.63.
|
|
204
|
-
"@modern-js/
|
|
205
|
-
"@modern-js/
|
|
206
|
-
"@modern-js/runtime-utils": "2.63.
|
|
207
|
-
"@modern-js/
|
|
203
|
+
"@modern-js/plugin": "2.63.3",
|
|
204
|
+
"@modern-js/plugin-data-loader": "2.63.3",
|
|
205
|
+
"@modern-js/types": "2.63.3",
|
|
206
|
+
"@modern-js/runtime-utils": "2.63.3",
|
|
207
|
+
"@modern-js/utils": "2.63.3"
|
|
208
208
|
},
|
|
209
209
|
"peerDependencies": {
|
|
210
210
|
"react": ">=17",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
},
|
|
213
213
|
"devDependencies": {
|
|
214
214
|
"@remix-run/web-fetch": "^4.1.3",
|
|
215
|
-
"@rsbuild/core": "1.1.
|
|
215
|
+
"@rsbuild/core": "1.1.10",
|
|
216
216
|
"@testing-library/react": "^13.4.0",
|
|
217
217
|
"@types/cookie": "0.6.0",
|
|
218
218
|
"@types/invariant": "^2.2.30",
|
|
@@ -228,10 +228,10 @@
|
|
|
228
228
|
"ts-node": "^10.9.1",
|
|
229
229
|
"typescript": "^5",
|
|
230
230
|
"webpack": "^5.97.1",
|
|
231
|
-
"@modern-js/app-tools": "2.63.
|
|
232
|
-
"@modern-js/core": "2.63.
|
|
233
|
-
"@scripts/build": "2.63.
|
|
234
|
-
"@scripts/jest-config": "2.63.
|
|
231
|
+
"@modern-js/app-tools": "2.63.3",
|
|
232
|
+
"@modern-js/core": "2.63.3",
|
|
233
|
+
"@scripts/build": "2.63.3",
|
|
234
|
+
"@scripts/jest-config": "2.63.3"
|
|
235
235
|
},
|
|
236
236
|
"sideEffects": false,
|
|
237
237
|
"publishConfig": {
|