@shuvi/platform-web 1.0.18 → 1.0.19
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/esm/shuvi-app/app/client.js +1 -4
- package/esm/shuvi-app/app/server.js +1 -1
- package/esm/shuvi-app/react/view/ReactView.client.jsx +1 -1
- package/esm/shuvi-app/react/view/ReactView.server.bare.d.ts +4 -0
- package/esm/shuvi-app/react/view/ReactView.server.bare.jsx +28 -0
- package/lib/node/features/html-render/index.js +14 -1
- package/lib/node/targets/react/bundler/index.js +0 -6
- package/package.json +11 -11
- package/shuvi-type-extensions-runtime.d.ts +0 -7
|
@@ -11,7 +11,6 @@ import { getRoutes } from '@shuvi/app/core/platform';
|
|
|
11
11
|
import { runPreload, runLoaders, getRouteMatchesWithInvalidLoader, isRedirect, isResponse } from '@shuvi/platform-shared/shared';
|
|
12
12
|
import application from '@shuvi/platform-shared/shuvi-app/application';
|
|
13
13
|
import { createRouter, createBrowserHistory, createHashHistory } from '@shuvi/router';
|
|
14
|
-
import pageLoaders from '@shuvi/app/files/page-loaders';
|
|
15
14
|
import { historyMode } from '@shuvi/app/files/routerConfig';
|
|
16
15
|
import { SHUVI_ERROR } from '@shuvi/shared/constants';
|
|
17
16
|
import { serializeServerError } from '../helper/serializeServerError';
|
|
@@ -59,6 +58,7 @@ export const createApp = ({ routes, appData, appComponent }) => {
|
|
|
59
58
|
next();
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
61
|
+
const pageLoaders = yield app.getLoaders();
|
|
62
62
|
const matches = getRouteMatchesWithInvalidLoader(to, from, pageLoaders);
|
|
63
63
|
try {
|
|
64
64
|
const loaderDatas = yield new Promise((resolve, reject) => {
|
|
@@ -131,6 +131,3 @@ export const createApp = ({ routes, appData, appComponent }) => {
|
|
|
131
131
|
}));
|
|
132
132
|
return app;
|
|
133
133
|
};
|
|
134
|
-
if (module.hot) {
|
|
135
|
-
module.hot.accept('@shuvi/app/files/page-loaders');
|
|
136
|
-
}
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import routes from '@shuvi/app/files/routes';
|
|
11
11
|
import { getRoutes, app as AppComponent } from '@shuvi/app/core/platform';
|
|
12
12
|
import { runLoaders, getRouteMatchesWithInvalidLoader, isResponse, isRedirect } from '@shuvi/platform-shared/shared';
|
|
13
|
-
import pageLoaders from '@shuvi/app/files/page-loaders';
|
|
14
13
|
import application from '@shuvi/platform-shared/shuvi-app/application';
|
|
15
14
|
import { createRouter, createMemoryHistory, pathToString } from '@shuvi/router';
|
|
16
15
|
import logger from '@shuvi/utils/logger';
|
|
@@ -28,6 +27,7 @@ export const createApp = options => {
|
|
|
28
27
|
let app;
|
|
29
28
|
if (ssr) {
|
|
30
29
|
router.beforeResolve((to, from, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const pageLoaders = yield app.getLoaders();
|
|
31
31
|
const matches = getRouteMatchesWithInvalidLoader(to, from, pageLoaders);
|
|
32
32
|
try {
|
|
33
33
|
const loaderResult = yield runLoaders(matches, pageLoaders, {
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { SHUVI_ERROR } from '@shuvi/shared/constants';
|
|
12
12
|
import { Router } from '@shuvi/router-react';
|
|
13
|
-
import { getServerError } from '@shuvi/error-overlay';
|
|
14
13
|
import AppContainer from '../AppContainer';
|
|
15
14
|
import { HeadManager, HeadManagerContext } from '../head';
|
|
16
15
|
import Loadable from '../loadable';
|
|
@@ -27,6 +26,7 @@ export class ReactClientView {
|
|
|
27
26
|
const TypedAppComponent = AppComponent;
|
|
28
27
|
if (ssr && isInitialRender) {
|
|
29
28
|
if (process.env.NODE_ENV === 'development') {
|
|
29
|
+
const { getServerError } = require('@shuvi/error-overlay');
|
|
30
30
|
if (appError && appError.source === 'server') {
|
|
31
31
|
setTimeout(() => {
|
|
32
32
|
var _a;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export class ReactServerView {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.renderApp = () => __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const htmlContent = '';
|
|
14
|
+
const appData = {
|
|
15
|
+
dynamicIds: []
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
appData,
|
|
19
|
+
content: htmlContent,
|
|
20
|
+
htmlAttrs: {},
|
|
21
|
+
headBeginTags: [],
|
|
22
|
+
headEndTags: [],
|
|
23
|
+
bodyBeginTags: [],
|
|
24
|
+
bodyEndTags: []
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -46,7 +46,7 @@ Object.defineProperty(exports, "getPageMiddleware", { enumerable: true, get: fun
|
|
|
46
46
|
/** This plugin uses `platformContext` so that it is set to a plugin getter */
|
|
47
47
|
const getPlugin = (platformContext) => {
|
|
48
48
|
const core = (0, service_1.createPlugin)({
|
|
49
|
-
configWebpack: (chain, { name, mode }, ctx) => {
|
|
49
|
+
configWebpack: (chain, { webpack, name, mode }, ctx) => {
|
|
50
50
|
const isDev = mode === 'development';
|
|
51
51
|
const pkgVersion = (0, version_1.getVersion)();
|
|
52
52
|
const isServer = name === shared_1.BUNDLER_TARGET_SERVER;
|
|
@@ -79,6 +79,19 @@ const getPlugin = (platformContext) => {
|
|
|
79
79
|
else if (isServer) {
|
|
80
80
|
if (!ctx.config.ssr) {
|
|
81
81
|
chain.resolve.alias.set('@shuvi/platform-shared/shuvi-app/application$', '@shuvi/platform-shared/shuvi-app/application.bare');
|
|
82
|
+
chain
|
|
83
|
+
.plugin('replace/ReactView.server')
|
|
84
|
+
.use(webpack.NormalModuleReplacementPlugin, [
|
|
85
|
+
/\.\/ReactView\.server/,
|
|
86
|
+
function (resource) {
|
|
87
|
+
const { context } = resource;
|
|
88
|
+
// form shuvi internal request
|
|
89
|
+
if (context.endsWith('esm/shuvi-app/react/view')) {
|
|
90
|
+
resource.request = './ReactView.server.bare';
|
|
91
|
+
}
|
|
92
|
+
return resource;
|
|
93
|
+
}
|
|
94
|
+
]);
|
|
82
95
|
}
|
|
83
96
|
chain.plugin('private/build-manifest').use(build_manifest_plugin_1.default, [
|
|
84
97
|
{
|
|
@@ -102,12 +102,6 @@ const configWebpack = (config, { name, webpack }, context) => {
|
|
|
102
102
|
}
|
|
103
103
|
]);
|
|
104
104
|
if (context.mode === 'development') {
|
|
105
|
-
config.module
|
|
106
|
-
.rule('main')
|
|
107
|
-
.oneOf('js')
|
|
108
|
-
.use('react-refresh-loader')
|
|
109
|
-
.loader(require.resolve('@next/react-refresh-utils/loader'))
|
|
110
|
-
.before('shuvi-swc-loader');
|
|
111
105
|
config
|
|
112
106
|
.plugin('react-refresh-plugin')
|
|
113
107
|
.use(ReactRefreshWebpackPlugin_1.default, [webpack]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -72,17 +72,17 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@next/react-refresh-utils": "12.1.6",
|
|
75
|
-
"@shuvi/error-overlay": "1.0.
|
|
76
|
-
"@shuvi/hook": "1.0.
|
|
77
|
-
"@shuvi/platform-shared": "1.0.
|
|
75
|
+
"@shuvi/error-overlay": "1.0.19",
|
|
76
|
+
"@shuvi/hook": "1.0.19",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.19",
|
|
78
78
|
"doura": "0.0.8",
|
|
79
79
|
"react-doura": "0.0.8",
|
|
80
|
-
"@shuvi/router": "1.0.
|
|
81
|
-
"@shuvi/router-react": "1.0.
|
|
82
|
-
"@shuvi/runtime": "1.0.
|
|
83
|
-
"@shuvi/shared": "1.0.
|
|
84
|
-
"@shuvi/toolpack": "1.0.
|
|
85
|
-
"@shuvi/utils": "1.0.
|
|
80
|
+
"@shuvi/router": "1.0.19",
|
|
81
|
+
"@shuvi/router-react": "1.0.19",
|
|
82
|
+
"@shuvi/runtime": "1.0.19",
|
|
83
|
+
"@shuvi/shared": "1.0.19",
|
|
84
|
+
"@shuvi/toolpack": "1.0.19",
|
|
85
|
+
"@shuvi/utils": "1.0.19",
|
|
86
86
|
"content-type": "1.0.4",
|
|
87
87
|
"core-js": "3.6.5",
|
|
88
88
|
"ejs": "3.1.5",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"whatwg-fetch": "3.0.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@shuvi/service": "1.0.
|
|
101
|
+
"@shuvi/service": "1.0.19"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|
|
@@ -10,13 +10,6 @@ declare module '@shuvi/app/files/routerConfig' {
|
|
|
10
10
|
export const historyMode: 'browser' | 'hash';
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
declare module '@shuvi/app/files/page-loaders' {
|
|
14
|
-
import { IRouteLoaderContext, Loader } from '@shuvi/platform-shared/shared';
|
|
15
|
-
|
|
16
|
-
const loaders: Record<string, Loader>;
|
|
17
|
-
export default loaders;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
13
|
declare module '@shuvi/app/files/apiRoutes' {
|
|
21
14
|
import { IApiRoutes } from '@shuvi/platform-web/shared';
|
|
22
15
|
|