@shuvi/platform-web 1.0.0-rc.2 → 1.0.0-rc.20
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/appTypes.d.ts +12 -6
- package/esm/shared/configTypes.d.ts +1 -3
- package/esm/shared/constants.d.ts +8 -0
- package/esm/shared/constants.js +8 -0
- package/esm/shared/htmlRenderer.d.ts +33 -0
- package/esm/shared/{serverTypes.js → htmlRenderer.js} +0 -0
- package/esm/shared/index.d.ts +2 -1
- package/esm/shared/index.js +2 -1
- package/esm/shared/renderTypes.d.ts +8 -7
- package/esm/shared/routeTypes.d.ts +4 -9
- package/esm/shuvi-app/app/client.d.ts +2 -1
- package/esm/shuvi-app/app/client.js +13 -17
- package/esm/shuvi-app/app/server.js +13 -9
- package/esm/shuvi-app/dev/eventsource.d.ts +1 -0
- package/esm/shuvi-app/dev/eventsource.js +60 -0
- package/esm/shuvi-app/dev/hotDevClient.d.ts +32 -0
- package/esm/shuvi-app/dev/hotDevClient.js +327 -0
- package/esm/shuvi-app/dev/index.d.ts +3 -0
- package/esm/shuvi-app/dev/index.js +27 -0
- package/esm/shuvi-app/dev/websocket.d.ts +16 -0
- package/esm/shuvi-app/dev/websocket.js +61 -0
- package/esm/shuvi-app/entry/client/app.d.ts +2 -1
- package/esm/shuvi-app/entry/client/app.js +13 -6
- package/esm/shuvi-app/entry/client/index.js +1 -1
- package/esm/shuvi-app/entry/client/run.dev.js +15 -16
- package/esm/shuvi-app/entry/server/index.d.ts +5 -4
- package/esm/shuvi-app/entry/server/index.js +5 -4
- package/esm/shuvi-app/helper/serializeServerError.d.ts +2 -0
- package/esm/shuvi-app/helper/serializeServerError.js +21 -0
- package/esm/shuvi-app/react/AppContainer.d.ts +4 -5
- package/esm/shuvi-app/react/AppContainer.jsx +4 -5
- package/esm/shuvi-app/react/ApplicationContext.d.ts +7 -0
- package/esm/shuvi-app/react/{applicationContext.jsx → ApplicationContext.jsx} +0 -0
- package/esm/shuvi-app/react/Error.jsx +4 -1
- package/esm/shuvi-app/react/Link.d.ts +2 -1
- package/esm/shuvi-app/react/Link.jsx +1 -1
- package/esm/shuvi-app/react/getRoutes.d.ts +2 -2
- package/esm/shuvi-app/react/getRoutes.js +9 -8
- package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.d.ts +3 -3
- package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.jsx +3 -3
- package/esm/shuvi-app/react/model/runtime.d.ts +8 -0
- package/esm/shuvi-app/react/{redox-react → model}/runtime.js +8 -3
- package/esm/shuvi-app/react/store.d.ts +5 -0
- package/esm/shuvi-app/react/store.js +3 -0
- package/esm/shuvi-app/react/types.d.ts +0 -7
- package/esm/shuvi-app/react/useLoaderData.js +9 -20
- package/esm/shuvi-app/react/view/ReactView.client.jsx +34 -23
- package/esm/shuvi-app/react/view/ReactView.server.jsx +29 -14
- package/esm/shuvi-app/react/view/render.d.ts +8 -0
- package/esm/shuvi-app/react/view/{render-action.js → render.js} +6 -6
- package/lib/node/features/custom-server/index.d.ts +1 -1
- package/lib/node/features/custom-server/server.d.ts +1 -1
- package/lib/node/features/custom-server/server.js +20 -11
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +7 -7
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +5 -5
- package/lib/node/features/filesystem-routes/api/middleware.d.ts +2 -2
- package/lib/node/features/filesystem-routes/api/middleware.js +5 -2
- package/lib/node/features/filesystem-routes/hooks.d.ts +2 -1
- package/lib/node/features/filesystem-routes/hooks.js +2 -1
- package/lib/node/features/filesystem-routes/index.d.ts +1 -13
- package/lib/node/features/filesystem-routes/index.js +55 -84
- package/lib/node/features/filesystem-routes/middleware/middleware.d.ts +2 -2
- package/lib/node/features/filesystem-routes/middleware/middleware.js +5 -2
- package/lib/node/features/filesystem-routes/page/routes.d.ts +3 -3
- package/lib/node/features/filesystem-routes/page/routes.js +25 -12
- package/lib/node/features/html-render/index.d.ts +4 -18
- package/lib/node/features/html-render/index.js +129 -16
- package/lib/node/features/{main → html-render/lib}/buildHtml.d.ts +0 -0
- package/lib/node/features/{main → html-render/lib}/buildHtml.js +2 -1
- package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +3 -3
- package/lib/node/features/html-render/lib/generateFilesByRoutId.js +3 -3
- package/lib/node/features/{main → html-render/lib}/generateResource.d.ts +0 -0
- package/lib/node/features/{main → html-render/lib}/generateResource.js +12 -8
- package/lib/node/features/html-render/lib/getPageMiddleware.d.ts +2 -2
- package/lib/node/features/html-render/lib/getPageMiddleware.js +18 -13
- package/lib/node/features/html-render/lib/index.d.ts +0 -2
- package/lib/node/features/html-render/lib/index.js +1 -4
- package/lib/node/features/html-render/lib/renderToHTML.d.ts +2 -2
- package/lib/node/features/html-render/lib/renderToHTML.js +9 -49
- package/lib/node/features/html-render/lib/renderer/base.d.ts +7 -8
- package/lib/node/features/html-render/lib/renderer/base.js +19 -11
- package/lib/node/features/html-render/lib/renderer/index.d.ts +5 -4
- package/lib/node/features/html-render/lib/renderer/index.js +77 -8
- package/lib/node/features/html-render/lib/renderer/spa.d.ts +2 -2
- package/lib/node/features/html-render/lib/renderer/spa.js +4 -6
- package/lib/node/features/html-render/lib/renderer/ssr.d.ts +2 -2
- package/lib/node/features/html-render/lib/renderer/ssr.js +9 -11
- package/lib/node/features/html-render/lib/renderer/types.d.ts +10 -8
- package/lib/node/features/html-render/lib/webpack/build-manifest-plugin.d.ts +27 -0
- package/lib/node/features/html-render/lib/webpack/build-manifest-plugin.js +223 -0
- package/lib/node/features/html-render/server.d.ts +1 -1
- package/lib/node/features/html-render/serverHooks.d.ts +6 -1
- package/lib/node/features/html-render/serverHooks.js +1 -2
- package/lib/node/features/index.d.ts +3 -31
- package/lib/node/features/index.js +6 -7
- package/lib/node/features/middlewares.d.ts +1 -1
- package/lib/node/features/middlewares.js +12 -3
- package/lib/node/features/model/index.d.ts +1 -13
- package/lib/node/features/model/runtime.d.ts +3 -8
- package/lib/node/features/model/runtime.js +13 -18
- package/lib/node/features/model/server.js +2 -3
- package/lib/node/features/model/shuvi-app.d.ts +2 -2
- package/lib/node/features/on-demand-compile-page/index.d.ts +3 -13
- package/lib/node/features/on-demand-compile-page/index.js +4 -1
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.d.ts +3 -3
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +4 -6
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +17 -5
- package/lib/node/paths.js +0 -2
- package/lib/node/shuvi-runtime-server.d.ts +26 -0
- package/lib/{shared/serverTypes.js → node/shuvi-runtime-server.js} +0 -0
- package/lib/node/shuvi-type-extensions-node.d.ts +20 -23
- package/lib/node/targets/react/bundler/index.d.ts +1 -13
- package/lib/node/targets/react/bundler/index.js +19 -13
- package/lib/node/targets/react/index.d.ts +2 -27
- package/lib/node/targets/react/index.js +3 -7
- package/lib/node/targets/react/model/index.d.ts +6 -0
- package/lib/node/targets/react/{redox-react → model}/index.js +7 -6
- package/lib/node/version.d.ts +1 -0
- package/lib/node/version.js +13 -0
- package/lib/shared/appTypes.d.ts +12 -6
- package/lib/shared/configTypes.d.ts +1 -3
- package/lib/shared/constants.d.ts +8 -0
- package/lib/shared/constants.js +15 -0
- package/lib/shared/htmlRenderer.d.ts +33 -0
- package/lib/shared/htmlRenderer.js +2 -0
- package/lib/shared/index.d.ts +2 -1
- package/lib/shared/index.js +2 -1
- package/lib/shared/renderTypes.d.ts +8 -7
- package/lib/shared/routeTypes.d.ts +4 -9
- package/package.json +40 -26
- package/polyfills/polyfills.js +1 -0
- package/shuvi-env.d.ts +10 -0
- package/shuvi-image.d.ts +54 -0
- package/shuvi-type-extensions-node.js +1 -0
- package/shuvi-type-extensions-runtime.d.ts +2 -2
- package/esm/shared/serverTypes.d.ts +0 -6
- package/esm/shuvi-app/dev/webpackHotDevClient.d.ts +0 -5
- package/esm/shuvi-app/dev/webpackHotDevClient.js +0 -34
- package/esm/shuvi-app/react/applicationContext.d.ts +0 -7
- package/esm/shuvi-app/react/redox-react/runtime.d.ts +0 -2
- package/esm/shuvi-app/react/view/render-action.d.ts +0 -10
- package/esm/shuvi-app/shuvi-runtime-index.d.ts +0 -4
- package/esm/shuvi-app/shuvi-runtime-index.js +0 -2
- package/esm/shuvi-app/shuvi-runtime-server.d.ts +0 -6
- package/esm/shuvi-app/shuvi-runtime-server.js +0 -1
- package/lib/node/features/html-render/lib/pageLoader.d.ts +0 -1
- package/lib/node/features/html-render/lib/pageLoader.js +0 -42
- package/lib/node/features/main/index.d.ts +0 -3
- package/lib/node/features/main/index.js +0 -82
- package/lib/node/targets/react/redox-react/index.d.ts +0 -18
- package/lib/shared/serverTypes.d.ts +0 -6
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shared_1 = require("../../../../../shared");
|
|
4
|
+
const webpack_1 = require("@shuvi/toolpack/lib/webpack");
|
|
5
|
+
const Entrypoint = (0, webpack_1.resolveWebpackModule)('webpack/lib/Entrypoint');
|
|
6
|
+
const { RawSource } = webpack_1.sources;
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
filename: 'build-manifest.json',
|
|
9
|
+
modules: false,
|
|
10
|
+
chunkRequest: false
|
|
11
|
+
};
|
|
12
|
+
function getFileExt(filepath) {
|
|
13
|
+
const match = filepath.match(/\.(\w+)$/);
|
|
14
|
+
if (!match)
|
|
15
|
+
return '';
|
|
16
|
+
return match[1];
|
|
17
|
+
}
|
|
18
|
+
// function findEntrypointName(chunkGroup: any): string[] {
|
|
19
|
+
// const entrypoints: any[] = [];
|
|
20
|
+
// const queue: any[] = [chunkGroup];
|
|
21
|
+
// while (queue.length) {
|
|
22
|
+
// const item = queue.shift();
|
|
23
|
+
// for (const parent of item.getParents()) {
|
|
24
|
+
// if (parent instanceof Entrypoint) {
|
|
25
|
+
// entrypoints.push(parent.name);
|
|
26
|
+
// } else {
|
|
27
|
+
// queue.push(parent);
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
// return entrypoints;
|
|
32
|
+
// }
|
|
33
|
+
// This plugin creates a build-manifest.json for all assets that are being output
|
|
34
|
+
// It has a mapping of "entry" filename to real filename. Because the real filename can be hashed in production
|
|
35
|
+
class BuildManifestPlugin {
|
|
36
|
+
constructor(options = {}) {
|
|
37
|
+
this._options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
38
|
+
}
|
|
39
|
+
createAssets(compiler, compilation) {
|
|
40
|
+
const assetMap = (this._manifest = {
|
|
41
|
+
entries: {},
|
|
42
|
+
bundles: {},
|
|
43
|
+
chunkRequest: {},
|
|
44
|
+
loadble: {}
|
|
45
|
+
});
|
|
46
|
+
const chunkRootModulesMap = new Map();
|
|
47
|
+
compilation.chunks.forEach(chunk => {
|
|
48
|
+
const { chunkGraph } = compilation;
|
|
49
|
+
if (chunkGraph) {
|
|
50
|
+
chunkGraph.getChunkRootModules(chunk).forEach(module => {
|
|
51
|
+
const id = chunkGraph.getModuleId(module);
|
|
52
|
+
if (id !== '') {
|
|
53
|
+
chunkRootModulesMap.set(id, true);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
compilation.chunkGroups.forEach(chunkGroup => {
|
|
59
|
+
if (chunkGroup instanceof Entrypoint) {
|
|
60
|
+
this._collectEntries(chunkGroup);
|
|
61
|
+
}
|
|
62
|
+
this._collect(chunkGroup, compiler, compilation, chunkRootModulesMap);
|
|
63
|
+
});
|
|
64
|
+
const compilationAssets = compilation.getAssets();
|
|
65
|
+
this._manifest.polyfillFiles = compilationAssets
|
|
66
|
+
.filter(p => {
|
|
67
|
+
// Ensure only .js files are passed through
|
|
68
|
+
if (!p.name.endsWith('.js')) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return p.info && shared_1.BUILD_CLIENT_RUNTIME_POLYFILLS_SYMBOL in p.info;
|
|
72
|
+
})
|
|
73
|
+
.map(v => v.name);
|
|
74
|
+
this._manifest.loadble = Object.keys(this._manifest.loadble)
|
|
75
|
+
.sort()
|
|
76
|
+
// eslint-disable-next-line no-sequences
|
|
77
|
+
.reduce((a, c) => ((a[c] = this._manifest.loadble[c]), a), {});
|
|
78
|
+
return assetMap;
|
|
79
|
+
}
|
|
80
|
+
apply(compiler) {
|
|
81
|
+
compiler.hooks.make.tap('BuildManifestPlugin', compilation => {
|
|
82
|
+
compilation.hooks.processAssets.tap({
|
|
83
|
+
name: 'BuildManifestPlugin',
|
|
84
|
+
stage: webpack_1.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
85
|
+
}, assets => {
|
|
86
|
+
assets[this._options.filename] = new RawSource(JSON.stringify(this.createAssets(compiler, compilation), null, 2), true);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
_collectEntries(entrypoint) {
|
|
91
|
+
for (const chunk of entrypoint.chunks) {
|
|
92
|
+
// If there's no name or no files
|
|
93
|
+
if (!chunk.name || !chunk.files) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
for (const file of chunk.files) {
|
|
97
|
+
if (/\.map$/.test(file) || /\.hot-update\.js$/.test(file)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const ext = getFileExt(file);
|
|
101
|
+
this._pushEntries(entrypoint.name, ext, file.replace(/\\/g, '/'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_collect(chunkGroup, compiler, compilation, chunkRootModulesMap) {
|
|
106
|
+
const collectModules = this._options.modules;
|
|
107
|
+
chunkGroup.origins.forEach(chunkGroupOrigin => {
|
|
108
|
+
const { request } = chunkGroupOrigin;
|
|
109
|
+
const ctx = { request, compiler, compilation, chunkRootModulesMap };
|
|
110
|
+
chunkGroup.chunks.forEach(chunk => {
|
|
111
|
+
this._collectChunk(chunk, ctx);
|
|
112
|
+
if (collectModules) {
|
|
113
|
+
this._collectChunkModule(chunk, ctx);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
_collectChunk(chunk, { request }) {
|
|
119
|
+
if (!chunk.files) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
for (const file of chunk.files) {
|
|
123
|
+
if (/\.map$/.test(file) || /\.hot-update\.js$/.test(file)) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const ext = getFileExt(file);
|
|
127
|
+
const normalizedPath = file.replace(/\\/g, '/');
|
|
128
|
+
// normal chunk
|
|
129
|
+
if (ext === 'js') {
|
|
130
|
+
if (chunk.isOnlyInitial()) {
|
|
131
|
+
this._pushBundle({
|
|
132
|
+
name: chunk.name,
|
|
133
|
+
file: normalizedPath
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
this._pushChunkRequest({
|
|
137
|
+
file: normalizedPath,
|
|
138
|
+
request
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
_collectChunkModule(chunk, { request, compiler, compilation, chunkRootModulesMap }) {
|
|
144
|
+
if (chunk.canBeInitial()) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const context = compiler.options.context;
|
|
148
|
+
chunk.files.forEach((file) => {
|
|
149
|
+
const isJs = file.match(/\.js$/) && file.match(/^static\/chunks\//);
|
|
150
|
+
const isCss = file.match(/\.css$/) && file.match(/^static\/css\//);
|
|
151
|
+
if (isJs || isCss) {
|
|
152
|
+
this._pushLoadableModules(request, file);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const { chunkGraph } = compilation;
|
|
156
|
+
if (chunkGraph) {
|
|
157
|
+
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
|
|
158
|
+
let id = chunkGraph.getModuleId(module);
|
|
159
|
+
if (!module.type.startsWith('javascript')) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let name = typeof module.libIdent === 'function'
|
|
163
|
+
? module.libIdent({ context })
|
|
164
|
+
: null;
|
|
165
|
+
if (!name || name.endsWith('.css')) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (chunkRootModulesMap.has(id)) {
|
|
169
|
+
this._pushLoadableModules(request, {
|
|
170
|
+
id,
|
|
171
|
+
name
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
_pushEntries(name, ext, value) {
|
|
178
|
+
const entries = this._manifest.entries;
|
|
179
|
+
if (!entries[name]) {
|
|
180
|
+
entries[name] = {
|
|
181
|
+
js: []
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (!entries[name][ext]) {
|
|
185
|
+
entries[name][ext] = [value];
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
entries[name][ext].push(value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
_pushBundle({ name, file }) {
|
|
192
|
+
if (name) {
|
|
193
|
+
this._manifest.bundles[name] = file;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
_pushChunkRequest({ file, request }) {
|
|
197
|
+
if (this._options.chunkRequest && request) {
|
|
198
|
+
this._manifest.chunkRequest[file] = request;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
_pushLoadableModules(request, value) {
|
|
202
|
+
const modules = this._manifest.loadble;
|
|
203
|
+
if (!modules[request]) {
|
|
204
|
+
modules[request] = {
|
|
205
|
+
files: [],
|
|
206
|
+
children: []
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (typeof value === 'string') {
|
|
210
|
+
const existed = modules[request].files.some(file => file === value);
|
|
211
|
+
if (!existed) {
|
|
212
|
+
modules[request].files.push(value);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const existed = modules[request].children.some(item => item.id === value.id);
|
|
217
|
+
if (!existed) {
|
|
218
|
+
modules[request].children.push(value);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
exports.default = BuildManifestPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server/plugin").
|
|
1
|
+
declare const _default: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server/plugin").ServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
|
|
2
2
|
export default _default;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { ShuviRequest } from '@shuvi/service';
|
|
3
4
|
import { IAppContext } from '@shuvi/platform-shared/shared';
|
|
4
5
|
import { IHtmlDocument } from '../html-render';
|
|
6
|
+
export interface ModifyHtmlContext {
|
|
7
|
+
req: ShuviRequest;
|
|
8
|
+
appContext: IAppContext;
|
|
9
|
+
}
|
|
5
10
|
export declare type IHandlePageRequest = (req: IncomingMessage, res: ServerResponse) => any;
|
|
6
11
|
export declare const extendedHooks: {
|
|
7
12
|
getPageData: import("@shuvi/hook").AsyncParallelHook<void, IAppContext, Record<string, unknown>>;
|
|
8
13
|
handlePageRequest: import("@shuvi/hook").SyncWaterfallHook<IHandlePageRequest, void>;
|
|
9
|
-
modifyHtml: import("@shuvi/hook").
|
|
14
|
+
modifyHtml: import("@shuvi/hook").AsyncSeriesHook<IHtmlDocument, ModifyHtmlContext, void>;
|
|
10
15
|
};
|
|
@@ -4,8 +4,7 @@ exports.extendedHooks = void 0;
|
|
|
4
4
|
const hook_1 = require("@shuvi/hook");
|
|
5
5
|
const getPageData = (0, hook_1.createAsyncParallelHook)();
|
|
6
6
|
const handlePageRequest = (0, hook_1.createSyncWaterfallHook)();
|
|
7
|
-
|
|
8
|
-
const modifyHtml = (0, hook_1.createAsyncParallelHook)();
|
|
7
|
+
const modifyHtml = (0, hook_1.createAsyncSeriesHook)();
|
|
9
8
|
exports.extendedHooks = {
|
|
10
9
|
getPageData,
|
|
11
10
|
handlePageRequest,
|
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { IPlatformContext, ResolvedPlugin } from '@shuvi/service/lib/core';
|
|
2
|
+
export { buildHtml } from './html-render/lib/buildHtml';
|
|
2
3
|
export { getMiddlewares, getMiddlewaresBeforeDevMiddlewares } from './middlewares';
|
|
3
|
-
export
|
|
4
|
-
export declare const featurePlugins: (import("@shuvi/hook").IPluginInstance<{
|
|
5
|
-
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
6
|
-
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
8
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
9
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
10
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
11
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
12
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
13
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
14
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
15
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
16
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext> | {
|
|
17
|
-
core: import("@shuvi/hook").IPluginInstance<{
|
|
18
|
-
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
19
|
-
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
20
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
21
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
22
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
23
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
24
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
25
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
26
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
27
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
28
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
29
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
30
|
-
} | {
|
|
31
|
-
server: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/server/plugin").BuiltInServerPluginHooks & import("@shuvi/service/lib/server/pluginTypes").CustomServerPluginHooks, import("@shuvi/service").IServerPluginContext>;
|
|
32
|
-
})[];
|
|
4
|
+
export declare const getPlugins: (platformContext: IPlatformContext) => ResolvedPlugin[];
|
|
@@ -3,23 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getPlugins = exports.getMiddlewaresBeforeDevMiddlewares = exports.getMiddlewares = exports.buildHtml = void 0;
|
|
7
7
|
const on_demand_compile_page_1 = __importDefault(require("./on-demand-compile-page"));
|
|
8
|
-
const html_render_1 =
|
|
8
|
+
const html_render_1 = require("./html-render");
|
|
9
9
|
const custom_server_1 = __importDefault(require("./custom-server"));
|
|
10
10
|
const model_1 = __importDefault(require("./model"));
|
|
11
11
|
const filesystem_routes_1 = __importDefault(require("./filesystem-routes"));
|
|
12
|
-
var buildHtml_1 = require("./
|
|
12
|
+
var buildHtml_1 = require("./html-render/lib/buildHtml");
|
|
13
13
|
Object.defineProperty(exports, "buildHtml", { enumerable: true, get: function () { return buildHtml_1.buildHtml; } });
|
|
14
14
|
var middlewares_1 = require("./middlewares");
|
|
15
15
|
Object.defineProperty(exports, "getMiddlewares", { enumerable: true, get: function () { return middlewares_1.getMiddlewares; } });
|
|
16
16
|
Object.defineProperty(exports, "getMiddlewaresBeforeDevMiddlewares", { enumerable: true, get: function () { return middlewares_1.getMiddlewaresBeforeDevMiddlewares; } });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.featurePlugins = [
|
|
17
|
+
const getPlugins = (platformContext) => [
|
|
18
|
+
(0, html_render_1.getPlugin)(platformContext),
|
|
20
19
|
on_demand_compile_page_1.default,
|
|
21
20
|
filesystem_routes_1.default,
|
|
22
|
-
html_render_1.default,
|
|
23
21
|
custom_server_1.default,
|
|
24
22
|
model_1.default
|
|
25
23
|
];
|
|
24
|
+
exports.getPlugins = getPlugins;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IServerPluginContext, IServerMiddleware } from '@shuvi/service';
|
|
2
2
|
import { DevMiddleware } from '@shuvi/service/lib/server/middlewares/dev/devMiddleware';
|
|
3
|
-
export declare const getMiddlewares: (context: IServerPluginContext) => IServerMiddleware[]
|
|
3
|
+
export declare const getMiddlewares: (context: IServerPluginContext) => Promise<IServerMiddleware[]>;
|
|
4
4
|
export declare const getMiddlewaresBeforeDevMiddlewares: (devMiddleware: DevMiddleware, context: IServerPluginContext) => IServerMiddleware[];
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.getMiddlewaresBeforeDevMiddlewares = exports.getMiddlewares = void 0;
|
|
4
13
|
const on_demand_compile_page_1 = require("./on-demand-compile-page");
|
|
5
14
|
const filesystem_routes_1 = require("./filesystem-routes");
|
|
6
15
|
const html_render_1 = require("./html-render");
|
|
7
|
-
const getMiddlewares = (context) => {
|
|
16
|
+
const getMiddlewares = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
17
|
return [
|
|
9
18
|
(0, filesystem_routes_1.getMiddlewareMiddleware)(context),
|
|
10
19
|
(0, filesystem_routes_1.getApiMiddleware)(context),
|
|
11
|
-
(0, html_render_1.getPageMiddleware)(context)
|
|
20
|
+
yield (0, html_render_1.getPageMiddleware)(context)
|
|
12
21
|
].filter(Boolean);
|
|
13
|
-
};
|
|
22
|
+
});
|
|
14
23
|
exports.getMiddlewares = getMiddlewares;
|
|
15
24
|
const getMiddlewaresBeforeDevMiddlewares = (devMiddleware, context) => {
|
|
16
25
|
const onDemandRouteManager = new on_demand_compile_page_1.OnDemandRouteManager(context);
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
core: import("@shuvi/hook").IPluginInstance<
|
|
3
|
-
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
4
|
-
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
8
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
9
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
13
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
2
|
+
core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
|
|
15
3
|
runtime: {
|
|
16
4
|
plugin: string;
|
|
17
5
|
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedoxStore } from '@shuvi/redox';
|
|
2
2
|
import { IAppContext } from '@shuvi/platform-shared/shared';
|
|
3
3
|
export declare type InitRedox = (params: {
|
|
4
4
|
initialState: any;
|
|
5
5
|
ctx: IAppContext;
|
|
6
|
-
}) =>
|
|
7
|
-
declare
|
|
8
|
-
interface CustomAppContext {
|
|
9
|
-
storeManager?: IStoreManager;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
declare const _default: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/platform-shared/shared").BuiltInRuntimePluginHooks & import("@shuvi/runtime").CustomRuntimePluginHooks, void>;
|
|
6
|
+
}) => RedoxStore;
|
|
7
|
+
declare const _default: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/platform-shared/shared").RuntimePluginHooks, void>;
|
|
13
8
|
export default _default;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const redox_1 = require("@shuvi/redox");
|
|
4
4
|
const shared_1 = require("@shuvi/platform-shared/shared");
|
|
5
|
-
let
|
|
5
|
+
let currentStore;
|
|
6
6
|
const isServer = typeof window === 'undefined';
|
|
7
7
|
// for client, singleton mode
|
|
8
8
|
// for server, return new store
|
|
@@ -21,27 +21,22 @@ const initStore = ({ initialState, ctx }) => {
|
|
|
21
21
|
return createStoreInstance();
|
|
22
22
|
}
|
|
23
23
|
// for client is singleton, just init once
|
|
24
|
-
if (
|
|
25
|
-
|
|
24
|
+
if (!currentStore) {
|
|
25
|
+
currentStore = createStoreInstance();
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
return currentStoreManager;
|
|
27
|
+
return currentStore;
|
|
29
28
|
};
|
|
30
29
|
exports.default = (0, shared_1.createRuntimePlugin)({
|
|
31
30
|
appContext: ctx => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
initialState = (0, shared_1.getPageData)('redox');
|
|
36
|
-
}
|
|
37
|
-
if (ctx.pageData && ctx.pageData.redox) {
|
|
38
|
-
initialState = ctx.pageData.redox;
|
|
39
|
-
}
|
|
40
|
-
ctx.storeManager = initStore({
|
|
41
|
-
ctx,
|
|
42
|
-
initialState
|
|
43
|
-
});
|
|
31
|
+
let initialState = {};
|
|
32
|
+
if (!isServer) {
|
|
33
|
+
initialState = (0, shared_1.getPageData)('shuviInitialState', {});
|
|
44
34
|
}
|
|
45
|
-
|
|
35
|
+
ctx.store = initStore({
|
|
36
|
+
ctx,
|
|
37
|
+
initialState
|
|
38
|
+
});
|
|
46
39
|
}
|
|
40
|
+
}, {
|
|
41
|
+
name: 'model'
|
|
47
42
|
});
|
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const service_1 = require("@shuvi/service");
|
|
4
4
|
exports.default = (0, service_1.createServerPlugin)({
|
|
5
5
|
getPageData: appContext => {
|
|
6
|
-
const {
|
|
7
|
-
delete appContext.storeManager;
|
|
6
|
+
const { store } = appContext;
|
|
8
7
|
return {
|
|
9
|
-
|
|
8
|
+
shuviInitialState: store.getState()
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
11
|
});
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
declare const _default:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
7
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
8
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
9
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
10
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
11
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
12
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
13
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
1
|
+
declare const _default: {
|
|
2
|
+
core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
|
|
3
|
+
};
|
|
14
4
|
export default _default;
|
|
15
5
|
export { default as OnDemandRouteManager } from './onDemandRouteManager';
|
|
@@ -10,7 +10,7 @@ const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/web
|
|
|
10
10
|
const require_cache_hot_reloader_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/require-cache-hot-reloader-plugin"));
|
|
11
11
|
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
12
12
|
const dumbRouteComponent = require.resolve('./emptyComponent');
|
|
13
|
-
|
|
13
|
+
const plugin = (0, service_1.createPlugin)({
|
|
14
14
|
configWebpack(config, _, ctx) {
|
|
15
15
|
if (ctx.mode === 'development') {
|
|
16
16
|
config.plugin('private/module-replace-plugin').use(module_replace_plugin_1.default, [
|
|
@@ -32,5 +32,8 @@ exports.default = (0, service_1.createPlugin)({
|
|
|
32
32
|
return config;
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
exports.default = {
|
|
36
|
+
core: plugin
|
|
37
|
+
};
|
|
35
38
|
var onDemandRouteManager_1 = require("./onDemandRouteManager");
|
|
36
39
|
Object.defineProperty(exports, "OnDemandRouteManager", { enumerable: true, get: function () { return __importDefault(onDemandRouteManager_1).default; } });
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ShuviRequestHandler, IServerPluginContext } from '@shuvi/service';
|
|
2
2
|
import { DevMiddleware } from '@shuvi/service/lib/server/middlewares/dev';
|
|
3
3
|
export default class OnDemandRouteManager {
|
|
4
4
|
devMiddleware: DevMiddleware | null;
|
|
5
5
|
_serverPluginContext: IServerPluginContext;
|
|
6
6
|
constructor(serverPluginContext: IServerPluginContext);
|
|
7
|
-
getServerMiddleware():
|
|
8
|
-
ensureRoutesMiddleware():
|
|
7
|
+
getServerMiddleware(): ShuviRequestHandler;
|
|
8
|
+
ensureRoutesMiddleware(): ShuviRequestHandler;
|
|
9
9
|
ensureRoutes(pathname: string): Promise<void>;
|
|
10
10
|
private _activateModules;
|
|
11
11
|
}
|
|
@@ -13,10 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const router_1 = require("@shuvi/router");
|
|
16
|
-
const
|
|
17
|
-
const resources_1 = require("@shuvi/service/lib/resources");
|
|
16
|
+
const resources_1 = __importDefault(require("@shuvi/service/lib/resources"));
|
|
18
17
|
const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/module-replace-plugin"));
|
|
19
|
-
const index_1 = require("../filesystem-routes/index");
|
|
20
18
|
function acceptsHtml(header, { htmlAcceptHeaders = ['text/html', '*/*'] } = {}) {
|
|
21
19
|
for (var i = 0; i < htmlAcceptHeaders.length; i++) {
|
|
22
20
|
if (header.indexOf(htmlAcceptHeaders[i]) !== -1) {
|
|
@@ -40,7 +38,7 @@ class OnDemandRouteManager {
|
|
|
40
38
|
return next();
|
|
41
39
|
}
|
|
42
40
|
const chunkName = pathname.replace(this._serverPluginContext.assetPublicPath, '');
|
|
43
|
-
const chunkInitiatorModule = resources_1.clientManifest.chunkRequest[chunkName];
|
|
41
|
+
const chunkInitiatorModule = resources_1.default.clientManifest.chunkRequest[chunkName];
|
|
44
42
|
if (!chunkInitiatorModule) {
|
|
45
43
|
return next();
|
|
46
44
|
}
|
|
@@ -79,9 +77,9 @@ class OnDemandRouteManager {
|
|
|
79
77
|
}
|
|
80
78
|
ensureRoutes(pathname) {
|
|
81
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const matchedRoutes = (0, router_1.matchRoutes)(
|
|
80
|
+
const matchedRoutes = (0, router_1.matchRoutes)(resources_1.default.server.pageRoutes, pathname) || [];
|
|
83
81
|
const modulesToActivate = matchedRoutes
|
|
84
|
-
.map(({ route: {
|
|
82
|
+
.map(({ route: { __componentRawRequest__ } }) => __componentRawRequest__)
|
|
85
83
|
.filter(Boolean);
|
|
86
84
|
return this._activateModules(modulesToActivate);
|
|
87
85
|
});
|
package/lib/node/index.d.ts
CHANGED
package/lib/node/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
17
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
18
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,13 +26,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
26
|
const node_1 = require("@shuvi/platform-shared/node");
|
|
13
27
|
const features_1 = require("./features");
|
|
14
28
|
const paths_1 = require("./paths");
|
|
29
|
+
__exportStar(require("../shared"), exports);
|
|
15
30
|
const platform = ({ framework = 'react' } = {}) => (platformContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const mainPlugin = (0, features_1.getMainPlugin)(platformContext);
|
|
17
31
|
const platformFramework = require(`./targets/${framework}`).default;
|
|
18
32
|
const platformFrameworkContent = yield platformFramework();
|
|
19
33
|
const platformModule = platformFrameworkContent.platformModule;
|
|
20
|
-
const
|
|
21
|
-
const getPresetRuntimeFiles = (0, node_1.getPresetRuntimeFilesCreator)(platformModule, polyfills);
|
|
34
|
+
const getPresetRuntimeFiles = (0, node_1.getPresetRuntimeFilesCreator)(platformModule);
|
|
22
35
|
return {
|
|
23
36
|
types: [
|
|
24
37
|
(0, paths_1.resolvePkgFile)('shuvi-env.d.ts'),
|
|
@@ -26,8 +39,7 @@ const platform = ({ framework = 'react' } = {}) => (platformContext) => __awaite
|
|
|
26
39
|
],
|
|
27
40
|
plugins: [
|
|
28
41
|
...node_1.SharedPlugins,
|
|
29
|
-
|
|
30
|
-
...features_1.featurePlugins,
|
|
42
|
+
...(0, features_1.getPlugins)(platformContext),
|
|
31
43
|
...platformFrameworkContent.plugins
|
|
32
44
|
],
|
|
33
45
|
getPresetRuntimeFiles,
|
package/lib/node/paths.js
CHANGED
|
@@ -26,8 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.resolvePkgFile = exports.resolveLib = exports.resolveDep = void 0;
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
28
|
const PACKAGE_DIR = path.resolve(__dirname, '..', '..');
|
|
29
|
-
// export const resolveToModulePath = (...paths: string[]) =>
|
|
30
|
-
// `@shuvi/platform-web/${paths.join('/')}`;
|
|
31
29
|
const resolveDep = (module) => require.resolve(module);
|
|
32
30
|
exports.resolveDep = resolveDep;
|
|
33
31
|
const resolveLib = (module) => path.dirname((0, exports.resolveDep)(path.join(module, 'package.json')));
|