@modern-js/runtime 2.49.0 → 2.49.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/dist/cjs/ssr/cli/index.js +10 -9
- package/dist/cjs/ssr/react/prerender/index.js +3 -1
- package/dist/esm/ssr/cli/index.js +10 -9
- package/dist/esm/ssr/react/prerender/index.js +3 -1
- package/dist/esm-node/ssr/cli/index.js +10 -9
- package/dist/esm-node/ssr/react/prerender/index.js +3 -1
- package/package.json +10 -10
|
@@ -43,7 +43,7 @@ const hasStringSSREntry = (userConfig) => {
|
|
|
43
43
|
}
|
|
44
44
|
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
45
45
|
for (const name of Object.keys(server.ssrByEntries)) {
|
|
46
|
-
if (!isStreaming(server.ssrByEntries[name])) {
|
|
46
|
+
if (server.ssrByEntries[name] && !isStreaming(server.ssrByEntries[name])) {
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -65,26 +65,27 @@ const ssrPlugin = () => ({
|
|
|
65
65
|
return {
|
|
66
66
|
config() {
|
|
67
67
|
const appContext = api.useAppContext();
|
|
68
|
+
const userConfig = api.useConfigContext();
|
|
68
69
|
pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(appContext.internalDirectory, "plugins");
|
|
69
70
|
const { bundlerType = "webpack" } = api.useAppContext();
|
|
70
71
|
const babelHandler = (() => {
|
|
71
72
|
if (bundlerType === "webpack") {
|
|
72
73
|
return (config) => {
|
|
73
74
|
var _config_plugins;
|
|
74
|
-
const
|
|
75
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
75
76
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(import_path.default.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
76
|
-
if ((0, import_utils.isUseSSRBundle)(
|
|
77
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig2) && checkUseStringSSR(userConfig2)) {
|
|
77
78
|
var _config_plugins1;
|
|
78
79
|
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
82
|
} else if (bundlerType === "rspack") {
|
|
82
83
|
return (config) => {
|
|
83
|
-
const
|
|
84
|
-
if ((0, import_utils.isUseSSRBundle)(
|
|
84
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
85
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig2)) {
|
|
85
86
|
var _config_plugins;
|
|
86
87
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(import_path.default.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
87
|
-
if (checkUseStringSSR(
|
|
88
|
+
if (checkUseStringSSR(userConfig2)) {
|
|
88
89
|
var _config_plugins1;
|
|
89
90
|
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
90
91
|
}
|
|
@@ -105,8 +106,8 @@ const ssrPlugin = () => ({
|
|
|
105
106
|
},
|
|
106
107
|
tools: {
|
|
107
108
|
bundlerChain(chain, { isServer, isServiceWorker }) {
|
|
108
|
-
const
|
|
109
|
-
if ((0, import_utils.isUseSSRBundle)(
|
|
109
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
110
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig2) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig2)) {
|
|
110
111
|
const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
111
112
|
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
112
113
|
{
|
|
@@ -115,7 +116,7 @@ const ssrPlugin = () => ({
|
|
|
115
116
|
]);
|
|
116
117
|
}
|
|
117
118
|
},
|
|
118
|
-
babel: babelHandler
|
|
119
|
+
babel: (0, import_utils.isUseSSRBundle)(userConfig) && checkUseStringSSR(userConfig) ? babelHandler : void 0
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
122
|
},
|
|
@@ -99,7 +99,9 @@ function factory(Component) {
|
|
|
99
99
|
if (!validate) {
|
|
100
100
|
throw new Error("invalid props, check usage");
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
if (process.env.NODE_ENV === "development") {
|
|
103
|
+
console.error("[Warn] PreRender has been deprecated, please use SSR Cache instead. reference to docs: https://modernjs.dev/guides/advanced-features/ssr.html");
|
|
104
|
+
}
|
|
103
105
|
return (0, import_react.createElement)(Component, {
|
|
104
106
|
...newProps
|
|
105
107
|
});
|
|
@@ -16,7 +16,7 @@ var hasStringSSREntry = function(userConfig) {
|
|
|
16
16
|
try {
|
|
17
17
|
for (var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
18
18
|
var name = _step.value;
|
|
19
|
-
if (!isStreaming(server.ssrByEntries[name])) {
|
|
19
|
+
if (server.ssrByEntries[name] && !isStreaming(server.ssrByEntries[name])) {
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -53,26 +53,27 @@ var ssrPlugin = function() {
|
|
|
53
53
|
return {
|
|
54
54
|
config: function config() {
|
|
55
55
|
var appContext = api.useAppContext();
|
|
56
|
+
var userConfig = api.useConfigContext();
|
|
56
57
|
pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
|
|
57
58
|
var _api_useAppContext = api.useAppContext(), _api_useAppContext_bundlerType = _api_useAppContext.bundlerType, bundlerType = _api_useAppContext_bundlerType === void 0 ? "webpack" : _api_useAppContext_bundlerType;
|
|
58
59
|
var babelHandler = function() {
|
|
59
60
|
if (bundlerType === "webpack") {
|
|
60
61
|
return function(config2) {
|
|
61
62
|
var _config_plugins;
|
|
62
|
-
var
|
|
63
|
+
var userConfig2 = api.useResolvedConfigContext();
|
|
63
64
|
(_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
64
|
-
if (isUseSSRBundle(
|
|
65
|
+
if (isUseSSRBundle(userConfig2) && checkUseStringSSR(userConfig2)) {
|
|
65
66
|
var _config_plugins1;
|
|
66
67
|
(_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
} else if (bundlerType === "rspack") {
|
|
70
71
|
return function(config2) {
|
|
71
|
-
var
|
|
72
|
-
if (isUseSSRBundle(
|
|
72
|
+
var userConfig2 = api.useResolvedConfigContext();
|
|
73
|
+
if (isUseSSRBundle(userConfig2)) {
|
|
73
74
|
var _config_plugins;
|
|
74
75
|
(_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
75
|
-
if (checkUseStringSSR(
|
|
76
|
+
if (checkUseStringSSR(userConfig2)) {
|
|
76
77
|
var _config_plugins1;
|
|
77
78
|
(_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
78
79
|
}
|
|
@@ -95,8 +96,8 @@ var ssrPlugin = function() {
|
|
|
95
96
|
tools: {
|
|
96
97
|
bundlerChain: function bundlerChain(chain, param) {
|
|
97
98
|
var isServer = param.isServer, isServiceWorker = param.isServiceWorker;
|
|
98
|
-
var
|
|
99
|
-
if (isUseSSRBundle(
|
|
99
|
+
var userConfig2 = api.useResolvedConfigContext();
|
|
100
|
+
if (isUseSSRBundle(userConfig2) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig2)) {
|
|
100
101
|
var LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
101
102
|
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
102
103
|
{
|
|
@@ -105,7 +106,7 @@ var ssrPlugin = function() {
|
|
|
105
106
|
]);
|
|
106
107
|
}
|
|
107
108
|
},
|
|
108
|
-
babel: babelHandler
|
|
109
|
+
babel: isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig) ? babelHandler : void 0
|
|
109
110
|
}
|
|
110
111
|
};
|
|
111
112
|
},
|
|
@@ -70,7 +70,9 @@ function factory(Component) {
|
|
|
70
70
|
if (!validate) {
|
|
71
71
|
throw new Error("invalid props, check usage");
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
if (process.env.NODE_ENV === "development") {
|
|
74
|
+
console.error("[Warn] PreRender has been deprecated, please use SSR Cache instead. reference to docs: https://modernjs.dev/guides/advanced-features/ssr.html");
|
|
75
|
+
}
|
|
74
76
|
return createElement(Component, _object_spread({}, newProps));
|
|
75
77
|
};
|
|
76
78
|
_create_class(Spr2, null, [
|
|
@@ -9,7 +9,7 @@ const hasStringSSREntry = (userConfig) => {
|
|
|
9
9
|
}
|
|
10
10
|
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
11
11
|
for (const name of Object.keys(server.ssrByEntries)) {
|
|
12
|
-
if (!isStreaming(server.ssrByEntries[name])) {
|
|
12
|
+
if (server.ssrByEntries[name] && !isStreaming(server.ssrByEntries[name])) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -31,26 +31,27 @@ const ssrPlugin = () => ({
|
|
|
31
31
|
return {
|
|
32
32
|
config() {
|
|
33
33
|
const appContext = api.useAppContext();
|
|
34
|
+
const userConfig = api.useConfigContext();
|
|
34
35
|
pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
|
|
35
36
|
const { bundlerType = "webpack" } = api.useAppContext();
|
|
36
37
|
const babelHandler = (() => {
|
|
37
38
|
if (bundlerType === "webpack") {
|
|
38
39
|
return (config) => {
|
|
39
40
|
var _config_plugins;
|
|
40
|
-
const
|
|
41
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
41
42
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
42
|
-
if (isUseSSRBundle(
|
|
43
|
+
if (isUseSSRBundle(userConfig2) && checkUseStringSSR(userConfig2)) {
|
|
43
44
|
var _config_plugins1;
|
|
44
45
|
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
48
|
} else if (bundlerType === "rspack") {
|
|
48
49
|
return (config) => {
|
|
49
|
-
const
|
|
50
|
-
if (isUseSSRBundle(
|
|
50
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
51
|
+
if (isUseSSRBundle(userConfig2)) {
|
|
51
52
|
var _config_plugins;
|
|
52
53
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
53
|
-
if (checkUseStringSSR(
|
|
54
|
+
if (checkUseStringSSR(userConfig2)) {
|
|
54
55
|
var _config_plugins1;
|
|
55
56
|
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
56
57
|
}
|
|
@@ -71,8 +72,8 @@ const ssrPlugin = () => ({
|
|
|
71
72
|
},
|
|
72
73
|
tools: {
|
|
73
74
|
bundlerChain(chain, { isServer, isServiceWorker }) {
|
|
74
|
-
const
|
|
75
|
-
if (isUseSSRBundle(
|
|
75
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
76
|
+
if (isUseSSRBundle(userConfig2) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig2)) {
|
|
76
77
|
const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
77
78
|
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
78
79
|
{
|
|
@@ -81,7 +82,7 @@ const ssrPlugin = () => ({
|
|
|
81
82
|
]);
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
|
-
babel: babelHandler
|
|
85
|
+
babel: isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig) ? babelHandler : void 0
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
},
|
|
@@ -66,7 +66,9 @@ function factory(Component) {
|
|
|
66
66
|
if (!validate) {
|
|
67
67
|
throw new Error("invalid props, check usage");
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
if (process.env.NODE_ENV === "development") {
|
|
70
|
+
console.error("[Warn] PreRender has been deprecated, please use SSR Cache instead. reference to docs: https://modernjs.dev/guides/advanced-features/ssr.html");
|
|
71
|
+
}
|
|
70
72
|
return createElement(Component, {
|
|
71
73
|
...newProps
|
|
72
74
|
});
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.49.
|
|
18
|
+
"version": "2.49.1",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -170,10 +170,10 @@
|
|
|
170
170
|
"react-side-effect": "^2.1.1",
|
|
171
171
|
"styled-components": "^5.3.1",
|
|
172
172
|
"@swc/helpers": "0.5.3",
|
|
173
|
-
"@modern-js/plugin": "2.49.
|
|
174
|
-
"@modern-js/
|
|
175
|
-
"@modern-js/
|
|
176
|
-
"@modern-js/runtime-utils": "2.49.
|
|
173
|
+
"@modern-js/plugin": "2.49.1",
|
|
174
|
+
"@modern-js/utils": "2.49.1",
|
|
175
|
+
"@modern-js/types": "2.49.1",
|
|
176
|
+
"@modern-js/runtime-utils": "2.49.1"
|
|
177
177
|
},
|
|
178
178
|
"peerDependencies": {
|
|
179
179
|
"react": ">=17",
|
|
@@ -194,11 +194,11 @@
|
|
|
194
194
|
"ts-jest": "^29.1.0",
|
|
195
195
|
"typescript": "^5",
|
|
196
196
|
"webpack": "^5.91.0",
|
|
197
|
-
"@modern-js/app-tools": "2.49.
|
|
198
|
-
"@modern-js/core": "2.49.
|
|
199
|
-
"@modern-js/server-core": "2.49.
|
|
200
|
-
"@scripts/build": "2.49.
|
|
201
|
-
"@scripts/jest-config": "2.49.
|
|
197
|
+
"@modern-js/app-tools": "2.49.1",
|
|
198
|
+
"@modern-js/core": "2.49.1",
|
|
199
|
+
"@modern-js/server-core": "2.49.1",
|
|
200
|
+
"@scripts/build": "2.49.1",
|
|
201
|
+
"@scripts/jest-config": "2.49.1"
|
|
202
202
|
},
|
|
203
203
|
"sideEffects": false,
|
|
204
204
|
"publishConfig": {
|