@umijs/preset-umi 4.0.84 → 4.0.85
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/features/configPlugins/configPlugins.js +0 -2
- package/dist/features/exportStatic/exportStatic.js +0 -2
- package/dist/features/ssr/ssr.js +5 -3
- package/dist/features/ssr/utils.js +11 -4
- package/dist/features/ssr/webpack/webpack.js +7 -3
- package/dist/features/tmpFiles/routes.js +1 -1
- package/package.json +16 -16
- package/templates/server.tpl +5 -6
package/dist/features/ssr/ssr.js
CHANGED
|
@@ -144,8 +144,9 @@ export function useServerInsertedHTML(callback: () => React.ReactNode): void {
|
|
|
144
144
|
(0, import_fs.writeFileSync)(
|
|
145
145
|
(0, import_path.join)(api.cwd, "api/umi.server.js"),
|
|
146
146
|
`
|
|
147
|
+
const manifest = require('../server/build-manifest.json');
|
|
147
148
|
export default function handler(request, response) {
|
|
148
|
-
|
|
149
|
+
require(manifest.assets["umi.js"]).default(request, response);
|
|
149
150
|
}
|
|
150
151
|
`.trimStart(),
|
|
151
152
|
"utf-8"
|
|
@@ -153,6 +154,9 @@ export default function handler(request, response) {
|
|
|
153
154
|
import_utils.logger.info(`[SSR] write api/umi.server.js`);
|
|
154
155
|
}
|
|
155
156
|
});
|
|
157
|
+
api.onBuildHtmlComplete(() => {
|
|
158
|
+
import_utils.fsExtra.copyFileSync((0, import_path.join)(api.paths.absOutputPath, "index.html"), (0, import_path.join)(api.paths.absOutputPath, "*.html"));
|
|
159
|
+
});
|
|
156
160
|
const pluginName = "ProcessAssetsPlugin";
|
|
157
161
|
class ProcessAssetsPlugin {
|
|
158
162
|
apply(compiler) {
|
|
@@ -187,5 +191,3 @@ export default function handler(request, response) {
|
|
|
187
191
|
return config;
|
|
188
192
|
});
|
|
189
193
|
};
|
|
190
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
-
0 && (module.exports = {});
|
|
@@ -23,6 +23,7 @@ __export(utils_exports, {
|
|
|
23
23
|
esbuildUmiPlugin: () => esbuildUmiPlugin
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
var import_fs = require("fs");
|
|
26
27
|
var import_path = require("path");
|
|
27
28
|
function esbuildUmiPlugin(api) {
|
|
28
29
|
return {
|
|
@@ -41,10 +42,16 @@ function absServerBuildPath(api) {
|
|
|
41
42
|
if (api.env === "development") {
|
|
42
43
|
return (0, import_path.join)(api.paths.absTmpPath, "server/umi.server.js");
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const manifestPath = (0, import_path.join)(api.paths.cwd, "server", "build-manifest.json");
|
|
46
|
+
if (api.userConfig.ssr.serverBuildPath || !(0, import_fs.existsSync)(manifestPath)) {
|
|
47
|
+
return (0, import_path.join)(
|
|
48
|
+
api.paths.cwd,
|
|
49
|
+
api.userConfig.ssr.serverBuildPath || "server/umi.server.js"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
delete require.cache[manifestPath];
|
|
53
|
+
const manifest = require(manifestPath);
|
|
54
|
+
return (0, import_path.join)(api.paths.cwd, "server", (0, import_path.basename)(manifest.assets["umi.js"]));
|
|
48
55
|
}
|
|
49
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
57
|
0 && (module.exports = {
|
|
@@ -36,11 +36,13 @@ var bundlerWebpack = __toESM(require("@umijs/bundler-webpack"));
|
|
|
36
36
|
var import_utils = require("@umijs/utils");
|
|
37
37
|
var import_path = require("path");
|
|
38
38
|
var import_utils2 = require("../utils");
|
|
39
|
+
var import_types = require("@umijs/bundler-webpack/dist/types");
|
|
39
40
|
var build2 = async (api, opts) => {
|
|
40
41
|
import_utils.logger.wait("[SSR] Compiling...");
|
|
41
|
-
const now = new Date().getTime();
|
|
42
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
42
43
|
const bundlerOpts = import_utils.lodash.cloneDeep(opts);
|
|
43
44
|
const oChainWebpack = bundlerOpts.chainWebpack;
|
|
45
|
+
const useHash = api.config.hash && api.env === import_types.Env.production;
|
|
44
46
|
delete bundlerOpts.config.deadCode;
|
|
45
47
|
bundlerOpts.extraBabelPlugins.push([
|
|
46
48
|
require.resolve("babel-plugin-dynamic-import-node"),
|
|
@@ -57,13 +59,15 @@ var build2 = async (api, opts) => {
|
|
|
57
59
|
memo.target("node");
|
|
58
60
|
memo.name("umi");
|
|
59
61
|
memo.devtool(false);
|
|
60
|
-
memo.output.path((0, import_path.dirname)(absOutputFile)).filename("umi.server.js"
|
|
62
|
+
memo.output.path((0, import_path.dirname)(absOutputFile)).filename(useHash ? "umi.[contenthash:8].server.js" : "umi.server.js").chunkFilename(
|
|
63
|
+
useHash ? "umi.[contenthash:8].server.js" : "umi.server.js"
|
|
64
|
+
).libraryTarget("commonjs2");
|
|
61
65
|
memo.plugins.delete("progress-plugin");
|
|
62
66
|
memo.optimization.minimize(false);
|
|
63
67
|
return memo;
|
|
64
68
|
};
|
|
65
69
|
await bundlerWebpack.build(bundlerOpts);
|
|
66
|
-
const diff = new Date().getTime() - now;
|
|
70
|
+
const diff = (/* @__PURE__ */ new Date()).getTime() - now;
|
|
67
71
|
import_utils.logger.info(`[SSR] Compiled in ${diff}ms`);
|
|
68
72
|
};
|
|
69
73
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -251,7 +251,7 @@ function componentToChunkName(component, cwd = "/") {
|
|
|
251
251
|
import_utils.lodash.escapeRegExp(lastSlash(getProjectRootCwd(cwd)))})`
|
|
252
252
|
),
|
|
253
253
|
""
|
|
254
|
-
).replace(/^.(\/|\\)/, "").replace(/(\/|\\)/g, "__").replace(/@/g, "_").replace(/\.jsx?$/, "").replace(/\.tsx?$/, "").replace(/\.vue?$/, "").replace(/^src__/, "").replace(/\.\.__/g, "").replace(/[\[\]]/g, "").replace(/^node_modules__/, "nm__").replace(/^.umi-production__/, "t__").replace(/^\./, "").replace(/^pages__/, "p__") : "";
|
|
254
|
+
).replace(/.+(node_modules(\/|\\))/, "$1").replace(/(\/|\\)_@?([^@]+@){2}/, "$1").replace(/^.(\/|\\)/, "").replace(/(\/|\\)/g, "__").replace(/@/g, "_").replace(/\.jsx?$/, "").replace(/\.tsx?$/, "").replace(/\.vue?$/, "").replace(/^src__/, "").replace(/\.\.__/g, "").replace(/[\[\]]/g, "").replace(/^node_modules__/, "nm__").replace(/^.umi-production__/, "t__").replace(/^\./, "").replace(/^pages__/, "p__") : "";
|
|
255
255
|
}
|
|
256
256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
257
257
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.85",
|
|
4
4
|
"description": "@umijs/preset-umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"react-router": "6.3.0",
|
|
38
38
|
"react-router-dom": "6.3.0",
|
|
39
39
|
"regenerator-runtime": "0.13.11",
|
|
40
|
-
"@umijs/ast": "4.0.
|
|
41
|
-
"@umijs/bundler-
|
|
42
|
-
"@umijs/
|
|
43
|
-
"@umijs/bundler-
|
|
44
|
-
"@umijs/
|
|
45
|
-
"@umijs/
|
|
46
|
-
"@umijs/core": "4.0.
|
|
47
|
-
"@umijs/
|
|
48
|
-
"@umijs/
|
|
49
|
-
"@umijs/
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/
|
|
52
|
-
"@umijs/
|
|
53
|
-
"@umijs/
|
|
54
|
-
"@umijs/
|
|
40
|
+
"@umijs/ast": "4.0.85",
|
|
41
|
+
"@umijs/bundler-vite": "4.0.85",
|
|
42
|
+
"@umijs/bundler-utils": "4.0.85",
|
|
43
|
+
"@umijs/bundler-webpack": "4.0.85",
|
|
44
|
+
"@umijs/babel-preset-umi": "4.0.85",
|
|
45
|
+
"@umijs/mfsu": "4.0.85",
|
|
46
|
+
"@umijs/core": "4.0.85",
|
|
47
|
+
"@umijs/bundler-esbuild": "4.0.85",
|
|
48
|
+
"@umijs/plugin-run": "4.0.85",
|
|
49
|
+
"@umijs/server": "4.0.85",
|
|
50
|
+
"@umijs/renderer-react": "4.0.85",
|
|
51
|
+
"@umijs/ui": "3.0.1",
|
|
52
|
+
"@umijs/utils": "4.0.85",
|
|
53
|
+
"@umijs/zod2ts": "4.0.85",
|
|
54
|
+
"@umijs/did-you-know": "1.0.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@manypkg/get-packages": "1.1.3",
|
package/templates/server.tpl
CHANGED
|
@@ -26,8 +26,9 @@ export function getValidKeys() {
|
|
|
26
26
|
return [{{#validKeys}}'{{{ . }}}',{{/validKeys}}];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function getManifest() {
|
|
30
|
-
return JSON.parse(require('fs').readFileSync(
|
|
29
|
+
export function getManifest(sourceDir) {
|
|
30
|
+
return JSON.parse(require('fs').readFileSync(
|
|
31
|
+
sourceDir ? require('path').join(sourceDir,'build-manifest.json') : '{{{ assetsPath }}}', 'utf-8'));
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export function createHistory(opts) {
|
|
@@ -36,18 +37,16 @@ export function createHistory(opts) {
|
|
|
36
37
|
|
|
37
38
|
// TODO: remove global variable
|
|
38
39
|
global.g_getAssets = (fileName) => {
|
|
39
|
-
let m =
|
|
40
|
+
let m = getManifest();
|
|
40
41
|
return m.assets[fileName];
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
const manifest = {{{ env }}} === 'development' ? getManifest : getManifest();
|
|
44
43
|
const createOpts = {
|
|
45
44
|
routesWithServerLoader,
|
|
46
45
|
PluginManager,
|
|
47
46
|
getPlugins,
|
|
48
47
|
getValidKeys,
|
|
49
48
|
getRoutes,
|
|
50
|
-
manifest,
|
|
49
|
+
manifest: getManifest,
|
|
51
50
|
getClientRootComponent,
|
|
52
51
|
helmetContext,
|
|
53
52
|
createHistory,
|