@modern-js/runtime 1.21.4 → 1.21.6
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 +30 -0
- package/dist/js/modern/core/compatible.js +19 -1
- package/dist/js/modern/ssr/serverRender/loadable.js +5 -1
- package/dist/js/modern/state/runtime/plugin.js +1 -1
- package/dist/js/node/core/compatible.js +19 -1
- package/dist/js/node/ssr/serverRender/loadable.js +5 -1
- package/dist/js/node/state/runtime/plugin.js +1 -1
- package/dist/js/treeshaking/core/compatible.js +19 -1
- package/dist/js/treeshaking/ssr/serverRender/loadable.js +5 -1
- package/dist/js/treeshaking/state/runtime/plugin.js +1 -1
- package/dist/types/core/compatible.d.ts +13 -5
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
+
## 1.21.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bb7788d: fix: bootstrap func ReactDOM params type when use react18
|
|
8
|
+
|
|
9
|
+
fix: 修复当使用 React18 时, bootstrap 函数 ReactDOM 参数类型
|
|
10
|
+
|
|
11
|
+
- e951ac1: fix: state runtime plugin init hook not return next function
|
|
12
|
+
|
|
13
|
+
fix: 修复 state runtime 插件 init 钩子未返回 next 函数
|
|
14
|
+
|
|
15
|
+
- @modern-js/webpack@1.21.6
|
|
16
|
+
- @modern-js/plugin@1.21.6
|
|
17
|
+
- @modern-js/utils@1.21.6
|
|
18
|
+
|
|
19
|
+
## 1.21.5
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- a150632: fix: bootstrap function params type define
|
|
24
|
+
|
|
25
|
+
fix: 修复 bootstrap 函数参数类型定义
|
|
26
|
+
|
|
27
|
+
- 29576fc: fix: extname function logic bug fix
|
|
28
|
+
fix: 修复 extname 函数的逻辑问题
|
|
29
|
+
- @modern-js/webpack@1.21.5
|
|
30
|
+
- @modern-js/plugin@1.21.5
|
|
31
|
+
- @modern-js/utils@1.21.5
|
|
32
|
+
|
|
3
33
|
## 1.21.4
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -178,16 +178,34 @@ root, ReactDOM = defaultReactDOM) => {
|
|
|
178
178
|
|
|
179
179
|
const ModernRender = App => {
|
|
180
180
|
if (IS_REACT18) {
|
|
181
|
-
(root
|
|
181
|
+
if (root) {
|
|
182
|
+
root.render(App);
|
|
183
|
+
} else if (ReactDOM.createRoot) {
|
|
184
|
+
ReactDOM.createRoot(rootElement).render(App);
|
|
185
|
+
} else {
|
|
186
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `createRoot` method');
|
|
187
|
+
}
|
|
182
188
|
} else {
|
|
189
|
+
if (!ReactDOM.render) {
|
|
190
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `render` method');
|
|
191
|
+
}
|
|
192
|
+
|
|
183
193
|
ReactDOM.render(App, rootElement);
|
|
184
194
|
}
|
|
185
195
|
};
|
|
186
196
|
|
|
187
197
|
const ModernHydrate = (App, callback) => {
|
|
188
198
|
if (IS_REACT18) {
|
|
199
|
+
if (!ReactDOM.hydrateRoot) {
|
|
200
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `hydrateRoot` method');
|
|
201
|
+
}
|
|
202
|
+
|
|
189
203
|
ReactDOM.hydrateRoot(rootElement, App);
|
|
190
204
|
} else {
|
|
205
|
+
if (!ReactDOM.hydrate) {
|
|
206
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `hydrate` method');
|
|
207
|
+
}
|
|
208
|
+
|
|
191
209
|
ReactDOM.hydrate(App, rootElement, callback);
|
|
192
210
|
}
|
|
193
211
|
};
|
|
@@ -2,7 +2,11 @@ import { ChunkExtractor } from '@loadable/server';
|
|
|
2
2
|
import { isCrossOrigin } from "../utils";
|
|
3
3
|
|
|
4
4
|
const extname = uri => {
|
|
5
|
-
|
|
5
|
+
if (typeof uri !== 'string' || !uri.includes('.')) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return `.${uri === null || uri === void 0 ? void 0 : uri.split('.').pop()}` || '';
|
|
6
10
|
};
|
|
7
11
|
|
|
8
12
|
function getLoadableScripts(extractor) {
|
|
@@ -203,16 +203,34 @@ root, ReactDOM = _reactDom.default) => {
|
|
|
203
203
|
|
|
204
204
|
const ModernRender = App => {
|
|
205
205
|
if (IS_REACT18) {
|
|
206
|
-
(root
|
|
206
|
+
if (root) {
|
|
207
|
+
root.render(App);
|
|
208
|
+
} else if (ReactDOM.createRoot) {
|
|
209
|
+
ReactDOM.createRoot(rootElement).render(App);
|
|
210
|
+
} else {
|
|
211
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `createRoot` method');
|
|
212
|
+
}
|
|
207
213
|
} else {
|
|
214
|
+
if (!ReactDOM.render) {
|
|
215
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `render` method');
|
|
216
|
+
}
|
|
217
|
+
|
|
208
218
|
ReactDOM.render(App, rootElement);
|
|
209
219
|
}
|
|
210
220
|
};
|
|
211
221
|
|
|
212
222
|
const ModernHydrate = (App, callback) => {
|
|
213
223
|
if (IS_REACT18) {
|
|
224
|
+
if (!ReactDOM.hydrateRoot) {
|
|
225
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `hydrateRoot` method');
|
|
226
|
+
}
|
|
227
|
+
|
|
214
228
|
ReactDOM.hydrateRoot(rootElement, App);
|
|
215
229
|
} else {
|
|
230
|
+
if (!ReactDOM.hydrate) {
|
|
231
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `hydrate` method');
|
|
232
|
+
}
|
|
233
|
+
|
|
216
234
|
ReactDOM.hydrate(App, rootElement, callback);
|
|
217
235
|
}
|
|
218
236
|
};
|
|
@@ -10,7 +10,11 @@ var _server = require("@loadable/server");
|
|
|
10
10
|
var _utils = require("../utils");
|
|
11
11
|
|
|
12
12
|
const extname = uri => {
|
|
13
|
-
|
|
13
|
+
if (typeof uri !== 'string' || !uri.includes('.')) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return `.${uri === null || uri === void 0 ? void 0 : uri.split('.').pop()}` || '';
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
function getLoadableScripts(extractor) {
|
|
@@ -210,16 +210,34 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
210
210
|
|
|
211
211
|
ModernRender = function ModernRender(App) {
|
|
212
212
|
if (IS_REACT18) {
|
|
213
|
-
(root
|
|
213
|
+
if (root) {
|
|
214
|
+
root.render(App);
|
|
215
|
+
} else if (ReactDOM.createRoot) {
|
|
216
|
+
ReactDOM.createRoot(_rootElement).render(App);
|
|
217
|
+
} else {
|
|
218
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `createRoot` method');
|
|
219
|
+
}
|
|
214
220
|
} else {
|
|
221
|
+
if (!ReactDOM.render) {
|
|
222
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `render` method');
|
|
223
|
+
}
|
|
224
|
+
|
|
215
225
|
ReactDOM.render(App, _rootElement);
|
|
216
226
|
}
|
|
217
227
|
};
|
|
218
228
|
|
|
219
229
|
ModernHydrate = function ModernHydrate(App, callback) {
|
|
220
230
|
if (IS_REACT18) {
|
|
231
|
+
if (!ReactDOM.hydrateRoot) {
|
|
232
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `hydrateRoot` method');
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
ReactDOM.hydrateRoot(_rootElement, App);
|
|
222
236
|
} else {
|
|
237
|
+
if (!ReactDOM.hydrate) {
|
|
238
|
+
throw Error('The `bootstrap` `ReactDOM` parameter needs to provide the `hydrate` method');
|
|
239
|
+
}
|
|
240
|
+
|
|
223
241
|
ReactDOM.hydrate(App, _rootElement, callback);
|
|
224
242
|
}
|
|
225
243
|
};
|
|
@@ -3,7 +3,11 @@ import { ChunkExtractor } from '@loadable/server';
|
|
|
3
3
|
import { isCrossOrigin } from "../utils";
|
|
4
4
|
|
|
5
5
|
var extname = function extname(uri) {
|
|
6
|
-
|
|
6
|
+
if (typeof uri !== 'string' || !uri.includes('.')) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return ".".concat(uri === null || uri === void 0 ? void 0 : uri.split('.').pop()) || '';
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
function getLoadableScripts(extractor) {
|
|
@@ -7,15 +7,23 @@ export declare type CreateAppOptions = {
|
|
|
7
7
|
export declare const createApp: ({
|
|
8
8
|
plugins
|
|
9
9
|
}: CreateAppOptions) => (App?: React.ComponentType<any>) => React.ComponentType<any>;
|
|
10
|
+
export interface Root {
|
|
11
|
+
render: (children: React.ReactNode) => void;
|
|
12
|
+
unmount: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface HydrationOptions {
|
|
15
|
+
identifierPrefix?: string;
|
|
16
|
+
onRecoverableError?: (error: unknown) => void;
|
|
17
|
+
}
|
|
10
18
|
interface HydrateFunc {
|
|
11
|
-
(container: Element | Document, initialChildren: React.ReactNode):
|
|
19
|
+
(container: Element | Document, initialChildren: React.ReactNode, options?: HydrationOptions): Root;
|
|
12
20
|
(initialChildren: React.ReactNode, container: Element | Document, callback?: () => void): void;
|
|
13
21
|
}
|
|
14
|
-
declare type BootStrap<T = unknown> = (App: React.ComponentType, id: string | Record<string, any> | HTMLElement, root
|
|
15
|
-
render
|
|
16
|
-
hydrate
|
|
22
|
+
declare type BootStrap<T = unknown> = (App: React.ComponentType, id: string | Record<string, any> | HTMLElement, root?: any, ReactDOM?: {
|
|
23
|
+
render?: (children: React.ReactNode, rootElement?: HTMLElement) => void;
|
|
24
|
+
hydrate?: HydrateFunc;
|
|
17
25
|
createRoot?: (rootElement: HTMLElement) => any;
|
|
18
|
-
hydrateRoot
|
|
26
|
+
hydrateRoot?: HydrateFunc;
|
|
19
27
|
}) => Promise<T>;
|
|
20
28
|
export declare const bootstrap: BootStrap;
|
|
21
29
|
export declare const useRuntimeContext: () => TRuntimeContext;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.21.
|
|
14
|
+
"version": "1.21.6",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./type.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -116,9 +116,6 @@
|
|
|
116
116
|
"@loadable/babel-plugin": "^5.13.2",
|
|
117
117
|
"@loadable/server": "^5.15.1",
|
|
118
118
|
"@loadable/component": "^5.15.0",
|
|
119
|
-
"@modern-js/plugin": "1.21.4",
|
|
120
|
-
"@modern-js/webpack": "1.21.4",
|
|
121
|
-
"@modern-js/utils": "1.21.4",
|
|
122
119
|
"@modern-js-reduck/plugin-auto-actions": "^1.0.2",
|
|
123
120
|
"@modern-js-reduck/plugin-devtools": "^1.0.3",
|
|
124
121
|
"@modern-js-reduck/plugin-effects": "^1.0.2",
|
|
@@ -130,7 +127,10 @@
|
|
|
130
127
|
"@types/react-helmet": "^6.1.2",
|
|
131
128
|
"@types/redux-logger": "^3.0.9",
|
|
132
129
|
"@types/loadable__component": "^5.13.4",
|
|
133
|
-
"@types/styled-components": "^5.1.14"
|
|
130
|
+
"@types/styled-components": "^5.1.14",
|
|
131
|
+
"@modern-js/plugin": "1.21.6",
|
|
132
|
+
"@modern-js/webpack": "1.21.6",
|
|
133
|
+
"@modern-js/utils": "1.21.6"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
136
|
"react": ">=17",
|
|
@@ -142,20 +142,20 @@
|
|
|
142
142
|
"ts-jest": "^27.0.4",
|
|
143
143
|
"typescript": "^4",
|
|
144
144
|
"jest": "^27",
|
|
145
|
-
"@modern-js/core": "1.21.4",
|
|
146
|
-
"@modern-js/types": "1.21.4",
|
|
147
|
-
"@modern-js/utils": "1.21.4",
|
|
148
145
|
"@types/jest": "^27",
|
|
149
146
|
"@types/node": "^14",
|
|
150
147
|
"@types/react-side-effect": "^1.1.1",
|
|
151
148
|
"@types/loadable__webpack-plugin": "^5.7.3",
|
|
152
149
|
"@types/serialize-javascript": "^5.0.1",
|
|
153
|
-
"@scripts/build": "1.21.4",
|
|
154
|
-
"@scripts/jest-config": "1.21.4",
|
|
155
150
|
"@testing-library/react": "^12.0.0",
|
|
156
151
|
"@testing-library/react-hooks": "^7.0.1",
|
|
157
152
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
158
|
-
"@types/invariant": "^2.2.30"
|
|
153
|
+
"@types/invariant": "^2.2.30",
|
|
154
|
+
"@modern-js/core": "1.21.6",
|
|
155
|
+
"@modern-js/types": "1.21.6",
|
|
156
|
+
"@modern-js/utils": "1.21.6",
|
|
157
|
+
"@scripts/build": "1.21.6",
|
|
158
|
+
"@scripts/jest-config": "1.21.6"
|
|
159
159
|
},
|
|
160
160
|
"sideEffects": false,
|
|
161
161
|
"modernConfig": {},
|