@shuvi/platform-web 1.0.8 → 1.0.10
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/shared/constants.d.ts +1 -1
- package/esm/shared/constants.js +1 -1
- package/esm/shuvi-app/app/client.js +3 -1
- package/esm/shuvi-app/app/server.js +3 -1
- package/esm/shuvi-app/dev/hotDevClient.js +1 -1
- package/esm/shuvi-app/dev/index.js +1 -1
- package/esm/shuvi-app/entry/client/app.js +1 -1
- package/esm/shuvi-app/entry/client/run.dev.js +1 -1
- package/esm/shuvi-app/react/ErrorBoundary.jsx +1 -1
- package/esm/shuvi-app/react/loadable/loadable.d.ts +0 -2
- package/esm/shuvi-app/react/loadable/loadable.js +1 -12
- package/esm/shuvi-app/react/store.d.ts +1 -1
- package/esm/shuvi-app/react/view/ReactView.client.jsx +1 -1
- package/esm/shuvi-app/react/view/ReactView.server.jsx +2 -2
- package/lib/node/features/custom-server/server.js +1 -1
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +1 -1
- package/lib/node/features/filesystem-routes/api/apiRoutes.js +1 -1
- package/lib/node/features/filesystem-routes/index.js +7 -4
- package/lib/node/features/filesystem-routes/middleware/routes.js +1 -1
- package/lib/node/features/filesystem-routes/page/EmptyPageComponent.d.ts +1 -0
- package/lib/node/features/filesystem-routes/page/EmptyPageComponent.js +6 -0
- package/lib/node/features/filesystem-routes/page/routes.d.ts +11 -5
- package/lib/node/features/filesystem-routes/page/routes.js +29 -17
- package/lib/node/features/filesystem-routes/page/store.d.ts +3 -3
- package/lib/node/features/html-render/index.js +10 -1
- package/lib/node/features/html-render/lib/renderer/base.js +2 -2
- package/lib/node/features/html-render/lib/renderer/htmlTag.js +1 -1
- package/lib/node/features/on-demand-compile-page/index.js +2 -2
- package/lib/shared/constants.d.ts +1 -1
- package/lib/shared/constants.js +1 -1
- package/package.json +16 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/
|
|
1
|
+
export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/constants';
|
|
2
2
|
export declare const CLIENT_BUILD_MANIFEST_PATH = "../build-manifest.client.json";
|
|
3
3
|
export declare const SERVER_BUILD_MANIFEST_PATH = "../build-manifest.server.json";
|
|
4
4
|
export declare const BUILD_CLIENT_RUNTIME_POLYFILLS = "static/polyfills";
|
package/esm/shared/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/
|
|
1
|
+
export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/constants';
|
|
2
2
|
export const CLIENT_BUILD_MANIFEST_PATH = '../build-manifest.client.json';
|
|
3
3
|
export const SERVER_BUILD_MANIFEST_PATH = '../build-manifest.server.json';
|
|
4
4
|
export const BUILD_CLIENT_RUNTIME_POLYFILLS = `static/polyfills`;
|
|
@@ -13,7 +13,7 @@ import application from '@shuvi/platform-shared/shuvi-app/application';
|
|
|
13
13
|
import { createRouter, createBrowserHistory, createHashHistory } from '@shuvi/router';
|
|
14
14
|
import pageLoaders from '@shuvi/app/files/page-loaders';
|
|
15
15
|
import { historyMode } from '@shuvi/app/files/routerConfig';
|
|
16
|
-
import { SHUVI_ERROR } from '@shuvi/shared/
|
|
16
|
+
import { SHUVI_ERROR } from '@shuvi/shared/constants';
|
|
17
17
|
import { serializeServerError } from '../helper/serializeServerError';
|
|
18
18
|
import isThirdSite from '../helper/isThirdSite';
|
|
19
19
|
let app;
|
|
@@ -83,7 +83,9 @@ export const createApp = ({ routes, appData, appComponent }) => {
|
|
|
83
83
|
reject(err);
|
|
84
84
|
});
|
|
85
85
|
runLoaders(matches, pageLoaders, {
|
|
86
|
+
pathname: to.pathname,
|
|
86
87
|
query: to.query,
|
|
88
|
+
params: to.params,
|
|
87
89
|
getAppContext: () => app.context
|
|
88
90
|
})
|
|
89
91
|
.then(_value => {
|
|
@@ -13,7 +13,7 @@ import { runLoaders, getRouteMatchesWithInvalidLoader, isResponse, isRedirect }
|
|
|
13
13
|
import pageLoaders from '@shuvi/app/files/page-loaders';
|
|
14
14
|
import application from '@shuvi/platform-shared/shuvi-app/application';
|
|
15
15
|
import { createRouter, createMemoryHistory, pathToString } from '@shuvi/router';
|
|
16
|
-
import logger from '@shuvi/utils/
|
|
16
|
+
import logger from '@shuvi/utils/logger';
|
|
17
17
|
import { serializeServerError } from '../helper/serializeServerError';
|
|
18
18
|
export const createApp = options => {
|
|
19
19
|
const { req, ssr } = options;
|
|
@@ -32,7 +32,9 @@ export const createApp = options => {
|
|
|
32
32
|
try {
|
|
33
33
|
const loaderResult = yield runLoaders(matches, pageLoaders, {
|
|
34
34
|
req,
|
|
35
|
+
pathname: to.pathname,
|
|
35
36
|
query: to.query,
|
|
37
|
+
params: to.params,
|
|
36
38
|
getAppContext: () => app.context
|
|
37
39
|
});
|
|
38
40
|
app.setLoadersData(loaderResult);
|
|
@@ -37,7 +37,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
37
37
|
import stripAnsi from 'strip-ansi';
|
|
38
38
|
import formatWebpackMessages from '@shuvi/toolpack/lib/utils/formatWebpackMessages';
|
|
39
39
|
import { startReportingRuntimeErrors, stopReportingRuntimeErrors, onBuildError, onBuildOk, onRefresh } from '@shuvi/error-overlay';
|
|
40
|
-
import { DEV_SOCKET_TIMEOUT_MS } from '@shuvi/shared/
|
|
40
|
+
import { DEV_SOCKET_TIMEOUT_MS } from '@shuvi/shared/constants';
|
|
41
41
|
import { connectHMR, addMessageListener, sendMessage } from './websocket';
|
|
42
42
|
// This alternative WebpackDevServer combines the functionality of:
|
|
43
43
|
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEV_SOCKET_TIMEOUT_MS, DEV_HOT_MIDDLEWARE_PATH, DEV_HOT_LAUNCH_EDITOR_ENDPOINT } from '@shuvi/shared/
|
|
1
|
+
import { DEV_SOCKET_TIMEOUT_MS, DEV_HOT_MIDDLEWARE_PATH, DEV_HOT_LAUNCH_EDITOR_ENDPOINT } from '@shuvi/shared/constants';
|
|
2
2
|
import connect from './hotDevClient';
|
|
3
3
|
let devClient;
|
|
4
4
|
export const initHMRAndDevClient = (app) => {
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { CLIENT_CONTAINER_ID } from '@shuvi/shared/
|
|
10
|
+
import { CLIENT_CONTAINER_ID } from '@shuvi/shared/constants';
|
|
11
11
|
// renderer must be imported before application
|
|
12
12
|
// we need to init renderer before import AppComponent
|
|
13
13
|
import { view, getRoutes, app as PlatformAppComponent } from '@shuvi/app/core/platform';
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
/// <reference lib="dom" />
|
|
11
|
-
import { DEV_STYLE_HIDE_FOUC } from '@shuvi/shared/
|
|
11
|
+
import { DEV_STYLE_HIDE_FOUC } from '@shuvi/shared/constants';
|
|
12
12
|
import { initHMRAndDevClient } from '../../dev';
|
|
13
13
|
import { run, app } from './app';
|
|
14
14
|
function applyStyle() {
|
|
@@ -22,9 +22,7 @@ import * as React from 'react';
|
|
|
22
22
|
declare type Options = any;
|
|
23
23
|
declare function Loadable<P>(opts: Options): React.ComponentType<P>;
|
|
24
24
|
declare namespace Loadable {
|
|
25
|
-
var Map: typeof LoadableMap;
|
|
26
25
|
var preloadAll: () => Promise<void>;
|
|
27
26
|
var preloadReady: (ids?: (string | number)[]) => Promise<void>;
|
|
28
27
|
}
|
|
29
|
-
declare function LoadableMap<P>(opts: Options): React.ComponentType<P>;
|
|
30
28
|
export default Loadable;
|
|
@@ -92,16 +92,12 @@ function loadMap(obj) {
|
|
|
92
92
|
function resolve(obj) {
|
|
93
93
|
return obj && obj.__esModule ? obj.default : obj;
|
|
94
94
|
}
|
|
95
|
-
function render(loaded, props) {
|
|
96
|
-
return React.createElement(resolve(loaded), props);
|
|
97
|
-
}
|
|
98
95
|
function createLoadableComponent(loadFn, options) {
|
|
99
96
|
let opts = Object.assign({
|
|
100
97
|
loader: null,
|
|
101
98
|
loading: null,
|
|
102
99
|
delay: 200,
|
|
103
100
|
timeout: null,
|
|
104
|
-
render: render,
|
|
105
101
|
webpack: null,
|
|
106
102
|
modules: null
|
|
107
103
|
}, options);
|
|
@@ -158,7 +154,7 @@ function createLoadableComponent(loadFn, options) {
|
|
|
158
154
|
});
|
|
159
155
|
}
|
|
160
156
|
else if (state.loaded) {
|
|
161
|
-
return
|
|
157
|
+
return React.createElement(resolve(state.loaded), props);
|
|
162
158
|
}
|
|
163
159
|
else {
|
|
164
160
|
return null;
|
|
@@ -240,13 +236,6 @@ class LoadableSubscription {
|
|
|
240
236
|
function Loadable(opts) {
|
|
241
237
|
return createLoadableComponent(load, opts);
|
|
242
238
|
}
|
|
243
|
-
function LoadableMap(opts) {
|
|
244
|
-
if (typeof opts.render !== 'function') {
|
|
245
|
-
throw new Error('LoadableMap requires a `render(loaded, props)` function');
|
|
246
|
-
}
|
|
247
|
-
return createLoadableComponent(loadMap, opts);
|
|
248
|
-
}
|
|
249
|
-
Loadable.Map = LoadableMap;
|
|
250
239
|
function flushInitializers(initializers, ids) {
|
|
251
240
|
let promises = [];
|
|
252
241
|
while (initializers.length) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const Provider: (props: import("react").PropsWithChildren<{
|
|
3
3
|
store?: import("doura").Doura | undefined;
|
|
4
|
-
}>) => JSX.Element, useSharedModel: import("react-doura").UseNamedModel, useStaticModel: import("react-doura").
|
|
4
|
+
}>) => JSX.Element, useSharedModel: import("react-doura").UseNamedModel, useStaticModel: import("react-doura").UseStaticModel;
|
|
5
5
|
export { Provider, useSharedModel, useStaticModel };
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import * as React from 'react';
|
|
11
|
-
import { SHUVI_ERROR } from '@shuvi/shared/
|
|
11
|
+
import { SHUVI_ERROR } from '@shuvi/shared/constants';
|
|
12
12
|
import { Router } from '@shuvi/router-react';
|
|
13
13
|
import { getServerError } from '@shuvi/error-overlay';
|
|
14
14
|
import AppContainer from '../AppContainer';
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { renderToString } from 'react-dom/server';
|
|
12
12
|
import { redirect } from '@shuvi/platform-shared/shared';
|
|
13
|
-
import { SHUVI_ERROR } from '@shuvi/shared/
|
|
13
|
+
import { SHUVI_ERROR } from '@shuvi/shared/constants';
|
|
14
14
|
import { Router } from '@shuvi/router-react';
|
|
15
|
-
import logger from '@shuvi/utils/
|
|
15
|
+
import logger from '@shuvi/utils/logger';
|
|
16
16
|
import Loadable, { LoadableContext } from '../loadable';
|
|
17
17
|
import AppContainer from '../AppContainer';
|
|
18
18
|
import { Head } from '../head';
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const service_1 = require("@shuvi/service");
|
|
16
16
|
const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
|
|
17
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
17
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
18
18
|
let isWarnedhandlePageRequest = false;
|
|
19
19
|
exports.default = (0, service_1.createServerPlugin)({
|
|
20
20
|
getPageData: appContext => {
|
|
@@ -40,7 +40,7 @@ const stream_1 = require("stream");
|
|
|
40
40
|
const querystring = __importStar(require("querystring"));
|
|
41
41
|
const getRawBody = require('raw-body');
|
|
42
42
|
const contentType = __importStar(require("content-type"));
|
|
43
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
43
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
44
44
|
function apiRouteHandler(req, res, resolver, apiRoutesConfig) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateRoutesContent = exports.normalizeApiRoutes = exports.serializeApiRoutes = void 0;
|
|
4
|
-
const file_1 = require("@shuvi/utils/
|
|
4
|
+
const file_1 = require("@shuvi/utils/file");
|
|
5
5
|
function serializeApiRoutes(apiRoutes) {
|
|
6
6
|
let res = '';
|
|
7
7
|
for (let index = 0; index < apiRoutes.length; index++) {
|
|
@@ -15,9 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getApiMiddleware = exports.getMiddlewareMiddleware = exports.getRoutes = void 0;
|
|
16
16
|
const service_1 = require("@shuvi/service");
|
|
17
17
|
const node_1 = require("@shuvi/platform-shared/node");
|
|
18
|
-
const constants_1 = require("@shuvi/shared/
|
|
19
|
-
const logger_1 = __importDefault(require("@shuvi/utils/
|
|
20
|
-
const file_1 = require("@shuvi/utils/
|
|
18
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
19
|
+
const logger_1 = __importDefault(require("@shuvi/utils/logger"));
|
|
20
|
+
const file_1 = require("@shuvi/utils/file");
|
|
21
21
|
const hooks_1 = require("./hooks");
|
|
22
22
|
const page_1 = require("./page");
|
|
23
23
|
Object.defineProperty(exports, "getRoutes", { enumerable: true, get: function () { return page_1.getRoutes; } });
|
|
@@ -67,7 +67,10 @@ const plugin = (0, service_1.createPlugin)({
|
|
|
67
67
|
// user routes come later
|
|
68
68
|
extraRoutes.concat(routes), paths.routesDir);
|
|
69
69
|
(0, page_1.setRoutes)(normalizedRoutes);
|
|
70
|
-
return (0, page_1.generateRoutesContent)(normalizedRoutes,
|
|
70
|
+
return (0, page_1.generateRoutesContent)(normalizedRoutes, {
|
|
71
|
+
dev: mode === 'development',
|
|
72
|
+
ssr: context.config.ssr
|
|
73
|
+
});
|
|
71
74
|
}),
|
|
72
75
|
dependencies: [rawRoutes]
|
|
73
76
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateRoutesContent = exports.serializeMiddlewareRoutes = exports.normalizeMiddlewareRoutes = void 0;
|
|
4
|
-
const file_1 = require("@shuvi/utils/
|
|
4
|
+
const file_1 = require("@shuvi/utils/file");
|
|
5
5
|
function normalizeMiddlewareRoutes(middlewareRoutes, option) {
|
|
6
6
|
const res = [];
|
|
7
7
|
for (let index = 0; index < middlewareRoutes.length; index++) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Page(): null;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { IPageRouteConfig,
|
|
1
|
+
import { IPageRouteConfig, INormalizedPageRouteConfig } from '@shuvi/platform-shared/shared';
|
|
2
2
|
export { IPageRouteConfig };
|
|
3
3
|
/**
|
|
4
|
-
* returns JSON string of
|
|
4
|
+
* returns JSON string of INormalizedPageRouteConfig
|
|
5
5
|
*/
|
|
6
|
-
export declare function serializeRoutes(routes:
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export declare function serializeRoutes(routes: INormalizedPageRouteConfig[], { includeMeta, useEmptyComponent }: {
|
|
7
|
+
includeMeta: boolean;
|
|
8
|
+
useEmptyComponent?: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
export declare function normalizeRoutes(routes: IPageRouteConfig[], componentDir: string, parentPath?: string): INormalizedPageRouteConfig[];
|
|
11
|
+
export declare const generateRoutesContent: (routes: INormalizedPageRouteConfig[], { dev, ssr }: {
|
|
12
|
+
dev: boolean;
|
|
13
|
+
ssr: boolean;
|
|
14
|
+
}) => string;
|
|
@@ -13,32 +13,36 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.generateRoutesContent = exports.normalizeRoutes = exports.serializeRoutes = void 0;
|
|
15
15
|
const crypto_1 = require("crypto");
|
|
16
|
-
const constants_1 = require("@shuvi/shared/
|
|
17
|
-
const file_1 = require("@shuvi/utils/
|
|
16
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
17
|
+
const file_1 = require("@shuvi/utils/file");
|
|
18
|
+
const paths_1 = require("../../../paths");
|
|
19
|
+
const EmptyComponnetPath = (0, paths_1.resolvePkgFile)('lib/node/features/filesystem-routes/page/EmptyPageComponent');
|
|
18
20
|
function genRouteId(filepath) {
|
|
19
21
|
return (0, crypto_1.createHash)('md4').update(filepath).digest('hex').substr(0, 4);
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
|
-
* returns JSON string of
|
|
24
|
+
* returns JSON string of INormalizedPageRouteConfig
|
|
23
25
|
*/
|
|
24
|
-
function serializeRoutes(routes, includeMeta) {
|
|
26
|
+
function serializeRoutes(routes, { includeMeta, useEmptyComponent }) {
|
|
25
27
|
let res = '';
|
|
26
28
|
for (let index = 0; index < routes.length; index++) {
|
|
27
29
|
const _a = routes[index], { children: childRoutes } = _a, route = __rest(_a, ["children"]);
|
|
28
|
-
const id = route.id;
|
|
29
30
|
let strRoute = '';
|
|
30
31
|
const keys = Object.keys(route);
|
|
31
32
|
for (let index = 0; index < keys.length; index++) {
|
|
32
33
|
const key = keys[index];
|
|
33
34
|
if (key === 'component') {
|
|
34
|
-
const { component } = route;
|
|
35
|
+
const { component, id } = route;
|
|
35
36
|
const componentSource = (0, file_1.removeExt)(component);
|
|
36
|
-
|
|
37
|
+
let componentRequest = `${componentSource}?${constants_1.ROUTE_RESOURCE_QUERYSTRING}`;
|
|
37
38
|
// `webpackExports` works with production and optimization.minimize, check compiled dist
|
|
38
39
|
if (includeMeta) {
|
|
39
40
|
strRoute += `__componentRawRequest__: "${componentRequest}",\n`;
|
|
40
41
|
strRoute += `__componentSource__: "${componentSource}",\n`;
|
|
41
42
|
}
|
|
43
|
+
if (useEmptyComponent) {
|
|
44
|
+
componentRequest = EmptyComponnetPath;
|
|
45
|
+
}
|
|
42
46
|
strRoute += `
|
|
43
47
|
__import__: () => import(
|
|
44
48
|
/* webpackChunkName: "page-${id}" */
|
|
@@ -52,7 +56,10 @@ __resolveWeak__: () => [require.resolveWeak("${componentRequest}")]`.trim();
|
|
|
52
56
|
strRoute += `,\n`;
|
|
53
57
|
}
|
|
54
58
|
if (childRoutes && childRoutes.length > 0) {
|
|
55
|
-
strRoute += `children: ${serializeRoutes(childRoutes,
|
|
59
|
+
strRoute += `children: ${serializeRoutes(childRoutes, {
|
|
60
|
+
includeMeta,
|
|
61
|
+
useEmptyComponent
|
|
62
|
+
})},\n`;
|
|
56
63
|
}
|
|
57
64
|
res += `{${strRoute}},\n`;
|
|
58
65
|
}
|
|
@@ -63,24 +70,29 @@ function normalizeRoutes(routes, componentDir, parentPath = '') {
|
|
|
63
70
|
const res = [];
|
|
64
71
|
for (let index = 0; index < routes.length; index++) {
|
|
65
72
|
const route = Object.assign({}, routes[index]);
|
|
66
|
-
const
|
|
73
|
+
const { component, path } = route;
|
|
74
|
+
const pathWithoutSlash = path.replace(/^\//, '').replace(/\/$/, '');
|
|
67
75
|
const fullpath = parentPath + '/' + pathWithoutSlash;
|
|
68
|
-
if (route.component) {
|
|
69
|
-
route.component = (0, file_1.normalizePath)(route.component, componentDir);
|
|
70
|
-
}
|
|
71
|
-
// todo: add origin file to gen id
|
|
72
76
|
route.id = genRouteId(`${fullpath}@${route.component}`);
|
|
77
|
+
if (component) {
|
|
78
|
+
route.component = (0, file_1.normalizePath)(component, componentDir);
|
|
79
|
+
}
|
|
73
80
|
if (route.children && route.children.length > 0) {
|
|
74
|
-
route.children = normalizeRoutes(route.children, componentDir,
|
|
81
|
+
route.children = normalizeRoutes(route.children, componentDir, parentPath + '/' + pathWithoutSlash);
|
|
75
82
|
}
|
|
76
83
|
res.push(route);
|
|
77
84
|
}
|
|
78
85
|
return res;
|
|
79
86
|
}
|
|
80
87
|
exports.normalizeRoutes = normalizeRoutes;
|
|
81
|
-
const generateRoutesContent = (routes,
|
|
82
|
-
const serverRoutes = serializeRoutes(routes,
|
|
83
|
-
|
|
88
|
+
const generateRoutesContent = (routes, { dev, ssr }) => {
|
|
89
|
+
const serverRoutes = serializeRoutes(routes, {
|
|
90
|
+
includeMeta: true,
|
|
91
|
+
useEmptyComponent: ssr === false
|
|
92
|
+
});
|
|
93
|
+
const clientRoutes = serializeRoutes(routes, {
|
|
94
|
+
includeMeta: dev
|
|
95
|
+
});
|
|
84
96
|
return `
|
|
85
97
|
let routes;
|
|
86
98
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const setRoutes: (newRoutes:
|
|
3
|
-
export declare const getRoutes: () =>
|
|
1
|
+
import { INormalizedPageRouteConfig } from '@shuvi/platform-shared/shared';
|
|
2
|
+
export declare const setRoutes: (newRoutes: INormalizedPageRouteConfig[]) => void;
|
|
3
|
+
export declare const getRoutes: () => INormalizedPageRouteConfig[];
|
|
@@ -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 }) => {
|
|
49
|
+
configWebpack: (chain, { 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;
|
|
@@ -77,6 +77,15 @@ const getPlugin = (platformContext) => {
|
|
|
77
77
|
]);
|
|
78
78
|
}
|
|
79
79
|
else if (isServer) {
|
|
80
|
+
if (!ctx.config.ssr) {
|
|
81
|
+
chain.module
|
|
82
|
+
.rule('spa-ignore')
|
|
83
|
+
.test(/\.shuvi\/app\/user\/app\.js/)
|
|
84
|
+
.use('empty-loader')
|
|
85
|
+
.loader('@shuvi/empty-loader')
|
|
86
|
+
.end()
|
|
87
|
+
.pre();
|
|
88
|
+
}
|
|
80
89
|
chain.plugin('private/build-manifest').use(build_manifest_plugin_1.default, [
|
|
81
90
|
{
|
|
82
91
|
filename: shared_1.SERVER_BUILD_MANIFEST_PATH,
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BaseRenderer = void 0;
|
|
7
|
-
const htmlescape_1 = require("@shuvi/utils/
|
|
8
|
-
const constants_1 = require("@shuvi/shared/
|
|
7
|
+
const htmlescape_1 = require("@shuvi/utils/htmlescape");
|
|
8
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
9
9
|
const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
|
|
10
10
|
const shared_1 = require("../../../../../shared");
|
|
11
11
|
const generateFilesByRoutId_1 = __importDefault(require("../generateFilesByRoutId"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tag = exports.stringifyTag = exports.stringifyAttrs = void 0;
|
|
4
|
-
const htmlescape_1 = require("@shuvi/utils/
|
|
4
|
+
const htmlescape_1 = require("@shuvi/utils/htmlescape");
|
|
5
5
|
/**
|
|
6
6
|
* All html tag elements which must not contain innerHTML
|
|
7
7
|
* @see https://www.w3.org/TR/html5/syntax.html#void-elements
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OnDemandRouteManager = void 0;
|
|
7
7
|
const service_1 = require("@shuvi/service");
|
|
8
|
-
const escapeRegExp_1 = require("@shuvi/utils/
|
|
8
|
+
const escapeRegExp_1 = require("@shuvi/utils/escapeRegExp");
|
|
9
9
|
const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/module-replace-plugin"));
|
|
10
10
|
const require_cache_hot_reloader_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/require-cache-hot-reloader-plugin"));
|
|
11
|
-
const constants_1 = require("@shuvi/shared/
|
|
11
|
+
const constants_1 = require("@shuvi/shared/constants");
|
|
12
12
|
const dumbRouteComponent = require.resolve('./emptyComponent');
|
|
13
13
|
const plugin = (0, service_1.createPlugin)({
|
|
14
14
|
configWebpack(config, _, ctx) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/
|
|
1
|
+
export { BUNDLER_TARGET_CLIENT, BUNDLER_TARGET_SERVER, CLIENT_OUTPUT_DIR, SERVER_OUTPUT_DIR } from '@shuvi/shared/constants';
|
|
2
2
|
export declare const CLIENT_BUILD_MANIFEST_PATH = "../build-manifest.client.json";
|
|
3
3
|
export declare const SERVER_BUILD_MANIFEST_PATH = "../build-manifest.server.json";
|
|
4
4
|
export declare const BUILD_CLIENT_RUNTIME_POLYFILLS = "static/polyfills";
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BUILD_SERVER_FILE_SERVER = exports.BUILD_CLIENT_RUNTIME_MAIN = exports.BUILD_CLIENT_RUNTIME_WEBPACK = exports.BUILD_CLIENT_RUNTIME_POLYFILLS_SYMBOL = exports.BUILD_CLIENT_RUNTIME_POLYFILLS = exports.SERVER_BUILD_MANIFEST_PATH = exports.CLIENT_BUILD_MANIFEST_PATH = exports.SERVER_OUTPUT_DIR = exports.CLIENT_OUTPUT_DIR = exports.BUNDLER_TARGET_SERVER = exports.BUNDLER_TARGET_CLIENT = void 0;
|
|
4
|
-
var constants_1 = require("@shuvi/shared/
|
|
4
|
+
var constants_1 = require("@shuvi/shared/constants");
|
|
5
5
|
Object.defineProperty(exports, "BUNDLER_TARGET_CLIENT", { enumerable: true, get: function () { return constants_1.BUNDLER_TARGET_CLIENT; } });
|
|
6
6
|
Object.defineProperty(exports, "BUNDLER_TARGET_SERVER", { enumerable: true, get: function () { return constants_1.BUNDLER_TARGET_SERVER; } });
|
|
7
7
|
Object.defineProperty(exports, "CLIENT_OUTPUT_DIR", { enumerable: true, get: function () { return constants_1.CLIENT_OUTPUT_DIR; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -68,21 +68,21 @@
|
|
|
68
68
|
"build:polyfills": "microbundle -i src/polyfills/index.js -o polyfills/polyfills.js -f iife --no-sourcemap --external none --no-pkg-main"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
|
-
"node": ">=
|
|
71
|
+
"node": ">= 16.0.0"
|
|
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.
|
|
78
|
-
"doura": "0.0.
|
|
79
|
-
"react-doura": "0.0.
|
|
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.
|
|
75
|
+
"@shuvi/error-overlay": "1.0.10",
|
|
76
|
+
"@shuvi/hook": "1.0.10",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.10",
|
|
78
|
+
"doura": "0.0.7",
|
|
79
|
+
"react-doura": "0.0.7",
|
|
80
|
+
"@shuvi/router": "1.0.10",
|
|
81
|
+
"@shuvi/router-react": "1.0.10",
|
|
82
|
+
"@shuvi/runtime": "1.0.10",
|
|
83
|
+
"@shuvi/shared": "1.0.10",
|
|
84
|
+
"@shuvi/toolpack": "1.0.10",
|
|
85
|
+
"@shuvi/utils": "1.0.10",
|
|
86
86
|
"content-type": "1.0.4",
|
|
87
87
|
"core-js": "3.6.5",
|
|
88
88
|
"ejs": "3.1.5",
|
|
@@ -90,15 +90,15 @@
|
|
|
90
90
|
"node-mocks-http": "1.11.0",
|
|
91
91
|
"object-assign": "4.1.1",
|
|
92
92
|
"raw-body": "2.4.1",
|
|
93
|
-
"react": "18.
|
|
94
|
-
"react-dom": "18.
|
|
93
|
+
"react": "18.2.0",
|
|
94
|
+
"react-dom": "18.2.0",
|
|
95
95
|
"react-refresh": "0.12.0",
|
|
96
96
|
"strip-ansi": "6.0.0",
|
|
97
97
|
"use-sync-external-store": "1.1.0",
|
|
98
98
|
"whatwg-fetch": "3.0.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@shuvi/service": "1.0.
|
|
101
|
+
"@shuvi/service": "1.0.10"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|