@umijs/preset-umi 4.2.6-alpha.6 → 4.2.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/dist/commands/build.js +7 -11
- package/dist/commands/dev/createRouteMiddleware.js +3 -3
- package/dist/commands/dev/dev.js +6 -10
- package/dist/features/appData/umiInfo.js +4 -6
- package/dist/features/devTool/devTool.js +1 -1
- package/dist/features/esbuildHelperChecker/esbuildHelperChecker.js +1 -1
- package/dist/features/exportStatic/exportStatic.js +20 -2
- package/dist/features/mako/mako.js +2 -13
- package/dist/features/okam/okam.js +1 -1
- package/dist/features/routePreloadOnLoad/routePreloadOnLoad.js +8 -19
- package/dist/features/routePreloadOnLoad/utils.d.ts +1 -1
- package/dist/features/routePreloadOnLoad/utils.js +1 -1
- package/dist/features/ssr/ssr.js +2 -42
- package/dist/features/ssr/utils.d.ts +0 -1
- package/dist/features/ssr/utils.js +2 -15
- package/dist/features/tmpFiles/tmpFiles.js +32 -66
- package/dist/types.d.ts +0 -1
- package/package.json +16 -16
- package/templates/server.tpl +17 -36
- package/templates/umi.tpl +0 -2
- package/dist/features/ssr/mako/mako.d.ts +0 -1
- package/dist/features/ssr/mako/mako.js +0 -90
package/dist/commands/build.js
CHANGED
|
@@ -48,7 +48,7 @@ COMPRESS=none umi build
|
|
|
48
48
|
umi build --clean
|
|
49
49
|
`,
|
|
50
50
|
fn: async function() {
|
|
51
|
-
var _a
|
|
51
|
+
var _a;
|
|
52
52
|
import_utils.logger.info(import_utils.chalk.cyan.bold(`Umi v${api.appData.umi.version}`));
|
|
53
53
|
import_utils.rimraf.sync(api.paths.absTmpPath);
|
|
54
54
|
await api.applyPlugins({
|
|
@@ -113,11 +113,7 @@ umi build --clean
|
|
|
113
113
|
react: {
|
|
114
114
|
runtime: shouldUseAutomaticRuntime ? "automatic" : "classic"
|
|
115
115
|
},
|
|
116
|
-
config:
|
|
117
|
-
outputPath: api.userConfig.outputPath || "dist",
|
|
118
|
-
...api.config,
|
|
119
|
-
hooks: ((_b = api.config.mako) == null ? void 0 : _b.hooks) || {}
|
|
120
|
-
},
|
|
116
|
+
config: api.config,
|
|
121
117
|
cwd: api.cwd,
|
|
122
118
|
entry,
|
|
123
119
|
...api.config.vite ? { modifyViteConfig } : { babelPreset, chainWebpack, modifyWebpackConfig },
|
|
@@ -142,7 +138,7 @@ umi build --clean
|
|
|
142
138
|
let stats;
|
|
143
139
|
if (api.config.vite) {
|
|
144
140
|
stats = await bundlerVite.build(opts);
|
|
145
|
-
} else if (
|
|
141
|
+
} else if (process.env.OKAM) {
|
|
146
142
|
require("@umijs/bundler-webpack/dist/requireHook");
|
|
147
143
|
const { build } = require(process.env.OKAM);
|
|
148
144
|
stats = await build(opts);
|
|
@@ -168,13 +164,13 @@ umi build --clean
|
|
|
168
164
|
publicPath: api.config.publicPath
|
|
169
165
|
});
|
|
170
166
|
const { vite } = api.args;
|
|
171
|
-
const
|
|
167
|
+
const markupArgs = await (0, import_getMarkupArgs.getMarkupArgs)({ api });
|
|
172
168
|
const finalMarkUpArgs = {
|
|
173
|
-
...
|
|
174
|
-
styles:
|
|
169
|
+
...markupArgs,
|
|
170
|
+
styles: markupArgs.styles.concat(
|
|
175
171
|
api.config.vite ? [] : [...(assetsMap["umi.css"] || []).map((src) => ({ src }))]
|
|
176
172
|
),
|
|
177
|
-
scripts: (api.config.vite ? [] : [...(assetsMap["umi.js"] || []).map((src) => ({ src }))]).concat(
|
|
173
|
+
scripts: (api.config.vite ? [] : [...(assetsMap["umi.js"] || []).map((src) => ({ src }))]).concat(markupArgs.scripts),
|
|
178
174
|
esmScript: !!opts.config.esm || vite,
|
|
179
175
|
path: "/"
|
|
180
176
|
};
|
|
@@ -33,8 +33,8 @@ function createRouteMiddleware(opts) {
|
|
|
33
33
|
webpackStats = stats;
|
|
34
34
|
onStats == null ? void 0 : onStats(stats);
|
|
35
35
|
});
|
|
36
|
-
async function getStats(
|
|
37
|
-
if (!compiler &&
|
|
36
|
+
async function getStats() {
|
|
37
|
+
if (!compiler && process.env.OKAM) {
|
|
38
38
|
return {
|
|
39
39
|
compilation: { assets: { "umi.js": "umi.js", "umi.css": "umi.css" } },
|
|
40
40
|
hasErrors: () => false
|
|
@@ -52,7 +52,7 @@ function createRouteMiddleware(opts) {
|
|
|
52
52
|
var _a;
|
|
53
53
|
const markupArgs = await (0, import_getMarkupArgs.getMarkupArgs)(opts);
|
|
54
54
|
let assetsMap = {};
|
|
55
|
-
const stats = await getStats(
|
|
55
|
+
const stats = await getStats();
|
|
56
56
|
assetsMap = (0, import_getAssetsMap.getAssetsMap)({
|
|
57
57
|
stats,
|
|
58
58
|
publicPath: opts.api.config.publicPath
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -70,7 +70,7 @@ umi dev
|
|
|
70
70
|
PORT=8888 umi dev
|
|
71
71
|
`,
|
|
72
72
|
async fn() {
|
|
73
|
-
var _a, _b, _c, _d, _e, _f
|
|
73
|
+
var _a, _b, _c, _d, _e, _f;
|
|
74
74
|
import_utils.logger.info(import_utils.chalk.cyan.bold(`Umi v${api.appData.umi.version}`));
|
|
75
75
|
const enableVite = !!api.config.vite;
|
|
76
76
|
import_utils.rimraf.sync(api.paths.absTmpPath);
|
|
@@ -314,11 +314,7 @@ PORT=8888 umi dev
|
|
|
314
314
|
react: {
|
|
315
315
|
runtime: shouldUseAutomaticRuntime ? "automatic" : "classic"
|
|
316
316
|
},
|
|
317
|
-
config:
|
|
318
|
-
outputPath: api.userConfig.outputPath || "dist",
|
|
319
|
-
...api.config,
|
|
320
|
-
hooks: ((_d = api.config.mako) == null ? void 0 : _d.hooks) || {}
|
|
321
|
-
},
|
|
317
|
+
config: api.config,
|
|
322
318
|
pkg: api.pkg,
|
|
323
319
|
cwd: api.cwd,
|
|
324
320
|
rootDir: process.cwd(),
|
|
@@ -358,8 +354,8 @@ PORT=8888 umi dev
|
|
|
358
354
|
...opts2
|
|
359
355
|
};
|
|
360
356
|
},
|
|
361
|
-
mfsuWithESBuild: (
|
|
362
|
-
mfsuStrategy: (
|
|
357
|
+
mfsuWithESBuild: (_d = api.config.mfsu) == null ? void 0 : _d.esbuild,
|
|
358
|
+
mfsuStrategy: (_e = api.config.mfsu) == null ? void 0 : _e.strategy,
|
|
363
359
|
cache: {
|
|
364
360
|
buildDependencies: [
|
|
365
361
|
api.pkgPath,
|
|
@@ -369,7 +365,7 @@ PORT=8888 umi dev
|
|
|
369
365
|
srcCodeCache,
|
|
370
366
|
mfsuInclude: import_utils.lodash.union([
|
|
371
367
|
...MFSU_EAGER_DEFAULT_INCLUDE,
|
|
372
|
-
...((
|
|
368
|
+
...((_f = api.config.mfsu) == null ? void 0 : _f.include) || []
|
|
373
369
|
]),
|
|
374
370
|
startBuildWorker,
|
|
375
371
|
onBeforeMiddleware(app) {
|
|
@@ -387,7 +383,7 @@ PORT=8888 umi dev
|
|
|
387
383
|
});
|
|
388
384
|
if (enableVite) {
|
|
389
385
|
await bundlerVite.dev(opts);
|
|
390
|
-
} else if (
|
|
386
|
+
} else if (process.env.OKAM) {
|
|
391
387
|
require("@umijs/bundler-webpack/dist/requireHook");
|
|
392
388
|
const { dev } = require(process.env.OKAM);
|
|
393
389
|
await dev(opts);
|
|
@@ -25,11 +25,9 @@ module.exports = __toCommonJS(umiInfo_exports);
|
|
|
25
25
|
var umiInfo_default = (api) => {
|
|
26
26
|
api.addEntryCode(() => [
|
|
27
27
|
`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
`
|
|
28
|
+
window.g_umi = {
|
|
29
|
+
version: '${api.appData.umi.version}',
|
|
30
|
+
};
|
|
31
|
+
`
|
|
34
32
|
]);
|
|
35
33
|
};
|
|
@@ -29,7 +29,7 @@ var devToolAppDist = (0, import_path.join)(__dirname, "../../../devToolAppDist")
|
|
|
29
29
|
var assetsDir = (0, import_path.join)(__dirname, "../../../assets");
|
|
30
30
|
var devTool_default = (api) => {
|
|
31
31
|
api.addBeforeMiddlewares(async () => {
|
|
32
|
-
if (
|
|
32
|
+
if (process.env.OKAM)
|
|
33
33
|
return [];
|
|
34
34
|
const $ = await api.applyPlugins({
|
|
35
35
|
key: "modifyDevToolLoadingHTML",
|
|
@@ -64,14 +64,23 @@ function getExportHtmlData(routes) {
|
|
|
64
64
|
return Array.from(map.values());
|
|
65
65
|
}
|
|
66
66
|
async function getPreRenderedHTML(api, htmlTpl, path) {
|
|
67
|
+
var _a, _b;
|
|
67
68
|
const {
|
|
68
69
|
exportStatic: { ignorePreRenderError = false }
|
|
69
70
|
} = api.config;
|
|
70
71
|
markupRender ?? (markupRender = require((0, import_utils2.absServerBuildPath)(api))._markupGenerator);
|
|
71
72
|
try {
|
|
72
|
-
const
|
|
73
|
+
const markup = await markupRender(path);
|
|
74
|
+
const [mainTpl, extraTpl = ""] = markup.split("</html>");
|
|
75
|
+
const helmetContent = (_a = mainTpl.match(
|
|
76
|
+
/<head>[^]*?(<[^>]+data-rh[^]+)<\/head>/
|
|
77
|
+
)) == null ? void 0 : _a[1];
|
|
78
|
+
const bodyContent = (_b = mainTpl.match(/<body[^>]*>([^]+?)<\/body>/)) == null ? void 0 : _b[1];
|
|
79
|
+
htmlTpl = htmlTpl.replace("</head>", `${helmetContent || ""}</head>`).replace(
|
|
80
|
+
new RegExp(`<div id="${api.config.mountElementId}"[^>]*>.*?</div>`),
|
|
81
|
+
bodyContent
|
|
82
|
+
).replace(/$/, `${extraTpl}`);
|
|
73
83
|
import_utils.logger.info(`Pre-render for ${path}`);
|
|
74
|
-
return html;
|
|
75
84
|
} catch (err) {
|
|
76
85
|
import_utils.logger.error(`Pre-render ${path} error: ${err}`);
|
|
77
86
|
if (!ignorePreRenderError) {
|
|
@@ -116,8 +125,17 @@ var exportStatic_default = (api) => {
|
|
|
116
125
|
const htmlData = api.appData.exportHtmlData;
|
|
117
126
|
const htmlFiles = [];
|
|
118
127
|
const { markupArgs: defaultMarkupArgs } = opts;
|
|
128
|
+
let asyncMarkupArgs;
|
|
119
129
|
for (const { file, route, prerender } of htmlData) {
|
|
120
130
|
let markupArgs = defaultMarkupArgs;
|
|
131
|
+
if (api.config.ssr && prerender) {
|
|
132
|
+
markupArgs = asyncMarkupArgs ?? (asyncMarkupArgs = {
|
|
133
|
+
...markupArgs,
|
|
134
|
+
scripts: markupArgs.scripts.map(
|
|
135
|
+
(script) => script.src ? { ...script, async: true } : script
|
|
136
|
+
)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
121
139
|
if (publicPath.startsWith(".")) {
|
|
122
140
|
(0, import_assert.default)(
|
|
123
141
|
api.config.runtimePublicPath,
|
|
@@ -39,12 +39,7 @@ var mako_default = (api) => {
|
|
|
39
39
|
key: "mako",
|
|
40
40
|
config: {
|
|
41
41
|
schema({ zod }) {
|
|
42
|
-
return zod.object({
|
|
43
|
-
hooks: zod.object({
|
|
44
|
-
load: zod.function(),
|
|
45
|
-
generateEnd: zod.function()
|
|
46
|
-
})
|
|
47
|
-
}).partial();
|
|
42
|
+
return zod.object({});
|
|
48
43
|
}
|
|
49
44
|
},
|
|
50
45
|
enableBy: api.EnableBy.config
|
|
@@ -66,13 +61,7 @@ var mako_default = (api) => {
|
|
|
66
61
|
api.logger.info(`Using mako@${pkg.version}`);
|
|
67
62
|
const isBigfish = process.env.BIGFISH_INFO;
|
|
68
63
|
if (!isBigfish) {
|
|
69
|
-
api.logger.warn(
|
|
70
|
-
import_utils.chalk.yellow(
|
|
71
|
-
import_utils.chalk.bold(
|
|
72
|
-
`Mako is an extremely fast, production-grade web bundler based on Rust. And it's still under active development and is not yet ready for production use. If you encounter any issues, please checkout https://makojs.dev/ to join the community and report the issue.`
|
|
73
|
-
)
|
|
74
|
-
)
|
|
75
|
-
);
|
|
64
|
+
api.logger.warn(import_utils.chalk.yellow(import_utils.chalk.bold(`Mako is an extremely fast, production-grade web bundler based on Rust. And it's still under active development and is not yet ready for production use. If you encounter any issues, please checkout https://makojs.dev/ to join the community and report the issue.`)));
|
|
76
65
|
}
|
|
77
66
|
} catch (e) {
|
|
78
67
|
console.error(e);
|
|
@@ -25,7 +25,7 @@ module.exports = __toCommonJS(okam_exports);
|
|
|
25
25
|
var import_utils = require("@umijs/utils");
|
|
26
26
|
var okam_default = (api) => {
|
|
27
27
|
api.describe({
|
|
28
|
-
enableBy: () => Boolean(
|
|
28
|
+
enableBy: () => Boolean(process.env.OKAM)
|
|
29
29
|
});
|
|
30
30
|
api.onCheck(() => {
|
|
31
31
|
(0, import_utils.checkVersion)(16, `Node 16 is required when using mako.`);
|
|
@@ -100,18 +100,11 @@ async function getRouteChunkFilesMap(chunks, opts) {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
async function getRoutePathFilesMap(routes, fileChunksMap, opts) {
|
|
103
|
-
var _a;
|
|
104
103
|
const { resolver, absPagesPath } = opts;
|
|
105
104
|
const routeFilesMap = {};
|
|
106
105
|
for (const route of Object.values(routes)) {
|
|
107
106
|
if (!route.file)
|
|
108
107
|
continue;
|
|
109
|
-
if (!((_a = route.absPath) == null ? void 0 : _a.startsWith("/"))) {
|
|
110
|
-
import_utils.logger.error(
|
|
111
|
-
`[routePreloadOnLoad]: route absPath error, cannot preload for ${route.absPath}`
|
|
112
|
-
);
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
108
|
let current = route;
|
|
116
109
|
const files = [];
|
|
117
110
|
do {
|
|
@@ -135,8 +128,8 @@ async function getRoutePathFilesMap(routes, fileChunksMap, opts) {
|
|
|
135
128
|
const indexes = Array.from(
|
|
136
129
|
// use set to avoid duplicated indexes
|
|
137
130
|
files.reduce((indexSet, file) => {
|
|
138
|
-
var
|
|
139
|
-
(
|
|
131
|
+
var _a;
|
|
132
|
+
(_a = fileChunksMap[file]) == null ? void 0 : _a.indexes.forEach((i) => indexSet.add(i));
|
|
140
133
|
return indexSet;
|
|
141
134
|
}, /* @__PURE__ */ new Set())
|
|
142
135
|
);
|
|
@@ -150,7 +143,7 @@ async function getRoutePathFilesMap(routes, fileChunksMap, opts) {
|
|
|
150
143
|
}
|
|
151
144
|
var routePreloadOnLoad_default = (api) => {
|
|
152
145
|
let routeChunkFilesMap;
|
|
153
|
-
let
|
|
146
|
+
let hashedPart = ".js";
|
|
154
147
|
api.describe({
|
|
155
148
|
enableBy: () => {
|
|
156
149
|
var _a;
|
|
@@ -181,7 +174,7 @@ var routePreloadOnLoad_default = (api) => {
|
|
|
181
174
|
// script mode
|
|
182
175
|
[
|
|
183
176
|
{
|
|
184
|
-
src: `${displayPublicPath}${import_utils2.PRELOAD_ROUTE_HELPER}${
|
|
177
|
+
src: `${displayPublicPath}${import_utils2.PRELOAD_ROUTE_HELPER}${hashedPart}`
|
|
185
178
|
}
|
|
186
179
|
]
|
|
187
180
|
);
|
|
@@ -235,16 +228,12 @@ var routePreloadOnLoad_default = (api) => {
|
|
|
235
228
|
api.config.runtimePublicPath ? "window.publicPath||" : ""}"${api.config.publicPath}"`
|
|
236
229
|
);
|
|
237
230
|
if (api.config.hash) {
|
|
238
|
-
|
|
231
|
+
hashedPart = `.${(0, import_crypto.createHash)("md5").update(content).digest("hex").substring(0, 8)}.js`;
|
|
239
232
|
}
|
|
240
233
|
(0, import_fs.writeFileSync)(
|
|
241
|
-
(0, import_path.join)(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
),
|
|
245
|
-
content,
|
|
246
|
-
"utf-8"
|
|
247
|
-
);
|
|
234
|
+
(0, import_path.join)(api.paths.absOutputPath, `${import_utils2.PRELOAD_ROUTE_HELPER}${hashedPart}`),
|
|
235
|
+
content
|
|
236
|
+
), "utf-8";
|
|
248
237
|
}
|
|
249
238
|
}
|
|
250
239
|
});
|
|
@@ -9,7 +9,7 @@ export interface IPreloadRouteFile {
|
|
|
9
9
|
attrs: ([string, string] | [string])[];
|
|
10
10
|
}
|
|
11
11
|
export declare const PRELOAD_ROUTE_MAP_SCP_TYPE = "umi-route-chunk-files-map";
|
|
12
|
-
export declare const PRELOAD_ROUTE_HELPER = "
|
|
12
|
+
export declare const PRELOAD_ROUTE_HELPER = "_umi_route_preload_helper";
|
|
13
13
|
export declare function getPreloadRouteFiles(path: string, map: IRouteChunkFilesMap, opts: {
|
|
14
14
|
publicPath: string;
|
|
15
15
|
}): IPreloadRouteFile[] | undefined;
|
|
@@ -25,7 +25,7 @@ __export(utils_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(utils_exports);
|
|
27
27
|
var PRELOAD_ROUTE_MAP_SCP_TYPE = "umi-route-chunk-files-map";
|
|
28
|
-
var PRELOAD_ROUTE_HELPER = "
|
|
28
|
+
var PRELOAD_ROUTE_HELPER = "_umi_route_preload_helper";
|
|
29
29
|
function getPreloadRouteFiles(path, map, opts) {
|
|
30
30
|
var _a;
|
|
31
31
|
const matched = (
|
package/dist/features/ssr/ssr.js
CHANGED
|
@@ -45,23 +45,14 @@ var ssr_default = (api) => {
|
|
|
45
45
|
const webpackBuilder = (0, import_utils.importLazy)(
|
|
46
46
|
require.resolve("./webpack/webpack")
|
|
47
47
|
);
|
|
48
|
-
const makoBuiler = (0, import_utils.importLazy)(
|
|
49
|
-
require.resolve("./mako/mako")
|
|
50
|
-
);
|
|
51
|
-
let serverBuildTarget;
|
|
52
48
|
api.describe({
|
|
53
49
|
key: "ssr",
|
|
54
50
|
config: {
|
|
55
51
|
schema({ zod }) {
|
|
56
52
|
return zod.object({
|
|
57
53
|
serverBuildPath: zod.string(),
|
|
58
|
-
serverBuildTarget: zod.enum(["express", "worker"]),
|
|
59
54
|
platform: zod.string(),
|
|
60
|
-
builder: zod.enum(["esbuild", "webpack"
|
|
61
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: zod.object({
|
|
62
|
-
pureApp: zod.boolean(),
|
|
63
|
-
pureHtml: zod.boolean()
|
|
64
|
-
})
|
|
55
|
+
builder: zod.enum(["esbuild", "webpack"])
|
|
65
56
|
}).deepPartial();
|
|
66
57
|
}
|
|
67
58
|
},
|
|
@@ -78,25 +69,6 @@ var ssr_default = (api) => {
|
|
|
78
69
|
api.onStart(() => {
|
|
79
70
|
import_utils.logger.warn(`SSR feature is in beta, may be unstable`);
|
|
80
71
|
});
|
|
81
|
-
api.modifyDefaultConfig((memo) => {
|
|
82
|
-
if (serverBuildTarget === "worker") {
|
|
83
|
-
const oReactDom = memo.alias["react-dom"];
|
|
84
|
-
delete memo.alias["react-dom"];
|
|
85
|
-
memo.alias["react-dom/server$"] = (0, import_utils.winPath)(
|
|
86
|
-
(0, import_path.join)(
|
|
87
|
-
api.service.configDefaults.alias["react-dom"],
|
|
88
|
-
"server.browser.js"
|
|
89
|
-
)
|
|
90
|
-
);
|
|
91
|
-
memo.alias["react-dom"] = oReactDom;
|
|
92
|
-
}
|
|
93
|
-
return memo;
|
|
94
|
-
});
|
|
95
|
-
api.modifyConfig((memo) => {
|
|
96
|
-
memo.define ?? (memo.define = {});
|
|
97
|
-
serverBuildTarget = memo.define["process.env.SSR_BUILD_TARGET"] = memo.ssr.serverBuildTarget || "express";
|
|
98
|
-
return memo;
|
|
99
|
-
});
|
|
100
72
|
api.addMiddlewares(() => [
|
|
101
73
|
async (req, res, next) => {
|
|
102
74
|
const modulePath = (0, import_utils2.absServerBuildPath)(api);
|
|
@@ -161,7 +133,7 @@ export type {
|
|
|
161
133
|
});
|
|
162
134
|
});
|
|
163
135
|
api.onBeforeCompiler(async ({ opts }) => {
|
|
164
|
-
const { builder = "
|
|
136
|
+
const { builder = "esbuild" } = api.config.ssr;
|
|
165
137
|
if (builder === "esbuild") {
|
|
166
138
|
await esbuildBuilder.build({
|
|
167
139
|
api,
|
|
@@ -173,18 +145,6 @@ export type {
|
|
|
173
145
|
`The \`vite\` config is now allowed when \`ssr.builder\` is webpack!`
|
|
174
146
|
);
|
|
175
147
|
await webpackBuilder.build(api, opts);
|
|
176
|
-
} else if (api.config.mako && builder === "mako") {
|
|
177
|
-
await makoBuiler.build(api);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
api.onDevCompileDone(() => {
|
|
181
|
-
if (api.config.mako) {
|
|
182
|
-
(0, import_utils2.generateBuildManifest)(api);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
api.onBuildComplete(() => {
|
|
186
|
-
if (api.config.mako) {
|
|
187
|
-
(0, import_utils2.generateBuildManifest)(api);
|
|
188
148
|
}
|
|
189
149
|
});
|
|
190
150
|
api.onBuildComplete(async ({ err }) => {
|
|
@@ -20,11 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var utils_exports = {};
|
|
21
21
|
__export(utils_exports, {
|
|
22
22
|
absServerBuildPath: () => absServerBuildPath,
|
|
23
|
-
esbuildUmiPlugin: () => esbuildUmiPlugin
|
|
24
|
-
generateBuildManifest: () => generateBuildManifest
|
|
23
|
+
esbuildUmiPlugin: () => esbuildUmiPlugin
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(utils_exports);
|
|
27
|
-
var import_utils = require("@umijs/utils");
|
|
28
26
|
var import_fs = require("fs");
|
|
29
27
|
var import_path = require("path");
|
|
30
28
|
function esbuildUmiPlugin(api) {
|
|
@@ -55,19 +53,8 @@ function absServerBuildPath(api) {
|
|
|
55
53
|
const manifest = require(manifestPath);
|
|
56
54
|
return (0, import_path.join)(api.paths.cwd, "server", (0, import_path.basename)(manifest.assets["umi.js"]));
|
|
57
55
|
}
|
|
58
|
-
var generateBuildManifest = (api) => {
|
|
59
|
-
const finalJsonObj = {};
|
|
60
|
-
const assetFilePath = (0, import_path.join)(api.paths.absOutputPath, "asset-manifest.json");
|
|
61
|
-
const buildFilePath = (0, import_path.join)(api.paths.absOutputPath, "build-manifest.json");
|
|
62
|
-
const json = (0, import_fs.existsSync)(assetFilePath) ? import_utils.fsExtra.readJSONSync(assetFilePath) : {};
|
|
63
|
-
finalJsonObj.assets = json;
|
|
64
|
-
(0, import_fs.writeFileSync)(buildFilePath, JSON.stringify(finalJsonObj, null, 2), {
|
|
65
|
-
flag: "w"
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
57
|
0 && (module.exports = {
|
|
70
58
|
absServerBuildPath,
|
|
71
|
-
esbuildUmiPlugin
|
|
72
|
-
generateBuildManifest
|
|
59
|
+
esbuildUmiPlugin
|
|
73
60
|
});
|
|
@@ -36,7 +36,6 @@ var import_utils = require("@umijs/utils");
|
|
|
36
36
|
var import_fs = require("fs");
|
|
37
37
|
var import_path = require("path");
|
|
38
38
|
var import_umi = require("umi");
|
|
39
|
-
var import_getMarkupArgs = require("../../commands/dev/getMarkupArgs");
|
|
40
39
|
var import_constants = require("../../constants");
|
|
41
40
|
var import_getModuleExports = require("./getModuleExports");
|
|
42
41
|
var import_importsToStr = require("./importsToStr");
|
|
@@ -54,7 +53,7 @@ var tmpFiles_default = (api) => {
|
|
|
54
53
|
}
|
|
55
54
|
});
|
|
56
55
|
api.onGenerateFiles(async (opts) => {
|
|
57
|
-
var _a, _b, _c
|
|
56
|
+
var _a, _b, _c;
|
|
58
57
|
const rendererPath = (0, import_utils.winPath)(
|
|
59
58
|
await api.applyPlugins({
|
|
60
59
|
key: "modifyRendererPath",
|
|
@@ -270,37 +269,6 @@ declare module '*.txt' {
|
|
|
270
269
|
}
|
|
271
270
|
`.trimEnd()
|
|
272
271
|
});
|
|
273
|
-
const entryCode = (await api.applyPlugins({
|
|
274
|
-
key: "addEntryCode",
|
|
275
|
-
initialValue: []
|
|
276
|
-
})).join("\n");
|
|
277
|
-
const entryCodeAhead = (await api.applyPlugins({
|
|
278
|
-
key: "addEntryCodeAhead",
|
|
279
|
-
initialValue: []
|
|
280
|
-
})).join("\n");
|
|
281
|
-
const importsAhead = (0, import_importsToStr.importsToStr)(
|
|
282
|
-
await api.applyPlugins({
|
|
283
|
-
key: "addEntryImportsAhead",
|
|
284
|
-
initialValue: [
|
|
285
|
-
api.appData.globalCSS.length && {
|
|
286
|
-
source: api.appData.globalCSS[0]
|
|
287
|
-
},
|
|
288
|
-
api.appData.globalJS.length && {
|
|
289
|
-
source: api.appData.globalJS[0]
|
|
290
|
-
}
|
|
291
|
-
].filter(Boolean)
|
|
292
|
-
})
|
|
293
|
-
).join("\n");
|
|
294
|
-
const imports = (0, import_importsToStr.importsToStr)(
|
|
295
|
-
await api.applyPlugins({
|
|
296
|
-
key: "addEntryImports",
|
|
297
|
-
initialValue: []
|
|
298
|
-
})
|
|
299
|
-
).join("\n");
|
|
300
|
-
const __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ((_b = api.config.ssr) == null ? void 0 : _b.__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) ?? {
|
|
301
|
-
pureApp: false,
|
|
302
|
-
pureHtml: false
|
|
303
|
-
};
|
|
304
272
|
api.writeTmpFile({
|
|
305
273
|
noPluginDir: true,
|
|
306
274
|
path: "umi.ts",
|
|
@@ -310,21 +278,41 @@ declare module '*.txt' {
|
|
|
310
278
|
rendererPath,
|
|
311
279
|
publicPath: api.config.publicPath,
|
|
312
280
|
runtimePublicPath: api.config.runtimePublicPath ? "true" : "false",
|
|
313
|
-
entryCode
|
|
314
|
-
|
|
281
|
+
entryCode: (await api.applyPlugins({
|
|
282
|
+
key: "addEntryCode",
|
|
283
|
+
initialValue: []
|
|
284
|
+
})).join("\n"),
|
|
285
|
+
entryCodeAhead: (await api.applyPlugins({
|
|
286
|
+
key: "addEntryCodeAhead",
|
|
287
|
+
initialValue: []
|
|
288
|
+
})).join("\n"),
|
|
315
289
|
polyfillImports: (0, import_importsToStr.importsToStr)(
|
|
316
290
|
await api.applyPlugins({
|
|
317
291
|
key: "addPolyfillImports",
|
|
318
292
|
initialValue: []
|
|
319
293
|
})
|
|
320
294
|
).join("\n"),
|
|
321
|
-
importsAhead,
|
|
322
|
-
|
|
295
|
+
importsAhead: (0, import_importsToStr.importsToStr)(
|
|
296
|
+
await api.applyPlugins({
|
|
297
|
+
key: "addEntryImportsAhead",
|
|
298
|
+
initialValue: [
|
|
299
|
+
api.appData.globalCSS.length && {
|
|
300
|
+
source: api.appData.globalCSS[0]
|
|
301
|
+
},
|
|
302
|
+
api.appData.globalJS.length && {
|
|
303
|
+
source: api.appData.globalJS[0]
|
|
304
|
+
}
|
|
305
|
+
].filter(Boolean)
|
|
306
|
+
})
|
|
307
|
+
).join("\n"),
|
|
308
|
+
imports: (0, import_importsToStr.importsToStr)(
|
|
309
|
+
await api.applyPlugins({
|
|
310
|
+
key: "addEntryImports",
|
|
311
|
+
initialValue: []
|
|
312
|
+
})
|
|
313
|
+
).join("\n"),
|
|
323
314
|
basename: api.config.base,
|
|
324
315
|
historyType: api.config.history.type,
|
|
325
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: JSON.stringify(
|
|
326
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
327
|
-
),
|
|
328
316
|
hydrate: !!api.config.ssr,
|
|
329
317
|
reactRouter5Compat: !!api.config.reactRouter5Compat,
|
|
330
318
|
loadingComponent: api.appData.globalLoading
|
|
@@ -355,7 +343,7 @@ export default function EmptyRoute() {
|
|
|
355
343
|
}
|
|
356
344
|
const hasSrc = api.appData.hasSrcDir;
|
|
357
345
|
const pages = (0, import_path.basename)(
|
|
358
|
-
((
|
|
346
|
+
((_b = api.config.conventionRoutes) == null ? void 0 : _b.base) || api.paths.absPagesPath
|
|
359
347
|
);
|
|
360
348
|
const prefix = hasSrc ? `../../../src/${pages}/` : `../../${pages}/`;
|
|
361
349
|
const clonedRoutes = import_utils.lodash.cloneDeep(routes);
|
|
@@ -413,7 +401,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
413
401
|
});
|
|
414
402
|
const plugins = await api.applyPlugins({
|
|
415
403
|
key: "addRuntimePlugin",
|
|
416
|
-
initialValue: [(
|
|
404
|
+
initialValue: [(_c = api.appData.appJS) == null ? void 0 : _c.path].filter(Boolean)
|
|
417
405
|
});
|
|
418
406
|
function checkDuplicatePluginKeys(arr) {
|
|
419
407
|
const duplicates = [];
|
|
@@ -472,7 +460,6 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
472
460
|
if (api.config.ssr) {
|
|
473
461
|
const umiPluginPath = (0, import_utils.winPath)((0, import_path.join)(umiDir, "client/client/plugin.js"));
|
|
474
462
|
const umiServerPath = (0, import_utils.winPath)(require.resolve("@umijs/server/dist/ssr"));
|
|
475
|
-
const mountElementId = api.config.mountElementId;
|
|
476
463
|
const routesWithServerLoader = Object.keys(routes).reduce((memo, id) => {
|
|
477
464
|
if (routes[id].hasServerLoader) {
|
|
478
465
|
memo.push({
|
|
@@ -482,7 +469,6 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
482
469
|
}
|
|
483
470
|
return memo;
|
|
484
471
|
}, []);
|
|
485
|
-
const { headScripts, scripts, styles, title, favicons, links, metas } = await (0, import_getMarkupArgs.getMarkupArgs)({ api });
|
|
486
472
|
api.writeTmpFile({
|
|
487
473
|
noPluginDir: true,
|
|
488
474
|
path: "umi.server.ts",
|
|
@@ -492,12 +478,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
492
478
|
/"component": "await import\((.*)\)"/g,
|
|
493
479
|
'"component": await import("$1")'
|
|
494
480
|
),
|
|
495
|
-
version: api.appData.umi.version,
|
|
496
|
-
entryCode,
|
|
497
|
-
entryCodeAhead,
|
|
498
481
|
routesWithServerLoader,
|
|
499
|
-
importsAhead,
|
|
500
|
-
imports,
|
|
501
482
|
umiPluginPath,
|
|
502
483
|
serverRendererPath,
|
|
503
484
|
umiServerPath,
|
|
@@ -505,20 +486,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
505
486
|
assetsPath: (0, import_utils.winPath)(
|
|
506
487
|
(0, import_path.join)(api.paths.absOutputPath, "build-manifest.json")
|
|
507
488
|
),
|
|
508
|
-
env: JSON.stringify(api.env)
|
|
509
|
-
htmlPageOpts: JSON.stringify({
|
|
510
|
-
headScripts,
|
|
511
|
-
styles,
|
|
512
|
-
title,
|
|
513
|
-
favicons,
|
|
514
|
-
links,
|
|
515
|
-
metas,
|
|
516
|
-
scripts: scripts || []
|
|
517
|
-
}),
|
|
518
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: JSON.stringify(
|
|
519
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
520
|
-
),
|
|
521
|
-
mountElementId
|
|
489
|
+
env: JSON.stringify(api.env)
|
|
522
490
|
}
|
|
523
491
|
});
|
|
524
492
|
}
|
|
@@ -585,9 +553,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
585
553
|
exportMembers
|
|
586
554
|
})).join(", ")} } from '${rendererPath}';`
|
|
587
555
|
);
|
|
588
|
-
exports.push(
|
|
589
|
-
`export type { History, ClientLoader } from '${rendererPath}'`
|
|
590
|
-
);
|
|
556
|
+
exports.push(`export type { History } from '${rendererPath}'`);
|
|
591
557
|
exports.push("// umi/client/client/plugin");
|
|
592
558
|
const umiPluginPath = (0, import_utils.winPath)((0, import_path.join)(umiDir, "client/client/plugin.js"));
|
|
593
559
|
exports.push(
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.2.6
|
|
3
|
+
"version": "4.2.6",
|
|
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",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@iconify/utils": "2.1.1",
|
|
23
23
|
"@svgr/core": "6.5.1",
|
|
24
|
-
"@umijs/bundler-mako": "0.
|
|
24
|
+
"@umijs/bundler-mako": "0.5.1-canary.20240529.2",
|
|
25
25
|
"@umijs/es-module-parser": "0.0.7",
|
|
26
26
|
"@umijs/history": "5.3.1",
|
|
27
27
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
@@ -41,21 +41,21 @@
|
|
|
41
41
|
"react-router": "6.3.0",
|
|
42
42
|
"react-router-dom": "6.3.0",
|
|
43
43
|
"regenerator-runtime": "0.13.11",
|
|
44
|
-
"@umijs/ast": "4.2.6
|
|
45
|
-
"@umijs/bundler-
|
|
46
|
-
"@umijs/
|
|
47
|
-
"@umijs/
|
|
48
|
-
"@umijs/bundler-
|
|
49
|
-
"@umijs/
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/
|
|
52
|
-
"@umijs/server": "4.2.6
|
|
53
|
-
"@umijs/
|
|
54
|
-
"@umijs/
|
|
55
|
-
"@umijs/renderer-react": "4.2.6-alpha.6",
|
|
44
|
+
"@umijs/ast": "4.2.6",
|
|
45
|
+
"@umijs/bundler-vite": "4.2.6",
|
|
46
|
+
"@umijs/mfsu": "4.2.6",
|
|
47
|
+
"@umijs/bundler-utils": "4.2.6",
|
|
48
|
+
"@umijs/bundler-webpack": "4.2.6",
|
|
49
|
+
"@umijs/babel-preset-umi": "4.2.6",
|
|
50
|
+
"@umijs/core": "4.2.6",
|
|
51
|
+
"@umijs/utils": "4.2.6",
|
|
52
|
+
"@umijs/server": "4.2.6",
|
|
53
|
+
"@umijs/plugin-run": "4.2.6",
|
|
54
|
+
"@umijs/zod2ts": "4.2.6",
|
|
56
55
|
"@umijs/ui": "3.0.1",
|
|
57
|
-
"@umijs/
|
|
58
|
-
"@umijs/
|
|
56
|
+
"@umijs/did-you-know": "1.0.3",
|
|
57
|
+
"@umijs/renderer-react": "4.2.6",
|
|
58
|
+
"@umijs/bundler-esbuild": "4.2.6"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@manypkg/get-packages": "1.1.3",
|
package/templates/server.tpl
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
{{{ importsAhead }}}
|
|
2
1
|
import { getClientRootComponent } from '{{{ serverRendererPath }}}';
|
|
3
2
|
import { getRoutes } from './core/route';
|
|
4
3
|
import { createHistory as createClientHistory } from './core/history';
|
|
4
|
+
import { getPlugins as getClientPlugins } from './core/plugin';
|
|
5
5
|
import { ServerInsertedHTMLContext } from './core/serverInsertedHTMLContext';
|
|
6
|
-
import {
|
|
7
|
-
import createRequestHandler, { createMarkupGenerator, createUmiHandler, createUmiServerLoader
|
|
8
|
-
|
|
9
|
-
import path from 'path';
|
|
10
|
-
{{{ imports }}}
|
|
11
|
-
{{{ entryCodeAhead }}}
|
|
6
|
+
import { PluginManager } from '{{{ umiPluginPath }}}';
|
|
7
|
+
import createRequestHandler, { createMarkupGenerator, createUmiHandler, createUmiServerLoader } from '{{{ umiServerPath }}}';
|
|
8
|
+
|
|
12
9
|
let helmetContext;
|
|
13
10
|
|
|
14
11
|
try {
|
|
@@ -21,19 +18,17 @@ const routesWithServerLoader = {
|
|
|
21
18
|
{{/routesWithServerLoader}}
|
|
22
19
|
};
|
|
23
20
|
|
|
24
|
-
export function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
manifestPath = '{{{ assetsPath }}}'
|
|
34
|
-
}
|
|
21
|
+
export function getPlugins() {
|
|
22
|
+
return getClientPlugins();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getValidKeys() {
|
|
26
|
+
return [{{#validKeys}}'{{{ . }}}',{{/validKeys}}];
|
|
27
|
+
}
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
export function getManifest(sourceDir) {
|
|
30
|
+
return JSON.parse(require('fs').readFileSync(
|
|
31
|
+
sourceDir ? require('path').join(sourceDir,'build-manifest.json') : '{{{ assetsPath }}}', 'utf-8'));
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
export function createHistory(opts) {
|
|
@@ -47,34 +42,20 @@ global.g_getAssets = (fileName) => {
|
|
|
47
42
|
};
|
|
48
43
|
const createOpts = {
|
|
49
44
|
routesWithServerLoader,
|
|
50
|
-
|
|
45
|
+
PluginManager,
|
|
46
|
+
getPlugins,
|
|
47
|
+
getValidKeys,
|
|
51
48
|
getRoutes,
|
|
52
49
|
manifest: getManifest,
|
|
53
50
|
getClientRootComponent,
|
|
54
51
|
helmetContext,
|
|
55
52
|
createHistory,
|
|
56
53
|
ServerInsertedHTMLContext,
|
|
57
|
-
htmlPageOpts: {{{htmlPageOpts}}},
|
|
58
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {{{__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED}}},
|
|
59
|
-
mountElementId: '{{{mountElementId}}}'
|
|
60
|
-
|
|
61
54
|
};
|
|
62
55
|
const requestHandler = createRequestHandler(createOpts);
|
|
63
|
-
/**
|
|
64
|
-
* @deprecated Please use `requestHandler` instead.
|
|
65
|
-
*/
|
|
66
56
|
export const renderRoot = createUmiHandler(createOpts);
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated Please use `requestHandler` instead.
|
|
69
|
-
*/
|
|
70
57
|
export const serverLoader = createUmiServerLoader(createOpts);
|
|
71
58
|
|
|
72
59
|
export const _markupGenerator = createMarkupGenerator(createOpts);
|
|
73
60
|
|
|
74
|
-
export const getAppRootElement = createAppRootElement.bind(null, createOpts)();
|
|
75
|
-
|
|
76
61
|
export default requestHandler;
|
|
77
|
-
|
|
78
|
-
export const g_umi = '{{{version}}}'
|
|
79
|
-
|
|
80
|
-
{{{ entryCode }}}
|
package/templates/umi.tpl
CHANGED
|
@@ -56,7 +56,6 @@ async function render() {
|
|
|
56
56
|
routes,
|
|
57
57
|
routeComponents,
|
|
58
58
|
pluginManager,
|
|
59
|
-
mountElementId: '{{{mountElementId}}}',
|
|
60
59
|
rootElement: contextOpts.rootElement || document.getElementById('{{{ mountElementId }}}'),
|
|
61
60
|
{{#loadingComponent}}
|
|
62
61
|
loadingComponent: Loading,
|
|
@@ -66,7 +65,6 @@ async function render() {
|
|
|
66
65
|
history,
|
|
67
66
|
historyType,
|
|
68
67
|
basename,
|
|
69
|
-
__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {{{__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED}}},
|
|
70
68
|
callback: contextOpts.callback,
|
|
71
69
|
};
|
|
72
70
|
const modifiedContext = pluginManager.applyPlugins({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const build: (api: IApi) => Promise<void>;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/features/ssr/mako/mako.ts
|
|
30
|
-
var mako_exports = {};
|
|
31
|
-
__export(mako_exports, {
|
|
32
|
-
build: () => build
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(mako_exports);
|
|
35
|
-
var import_types = require("@umijs/bundler-webpack/dist/types");
|
|
36
|
-
var import_utils = require("@umijs/utils");
|
|
37
|
-
var import_fs = require("fs");
|
|
38
|
-
var import_path = __toESM(require("path"));
|
|
39
|
-
var import_utils2 = require("../utils");
|
|
40
|
-
var build = async (api) => {
|
|
41
|
-
import_utils.logger.wait("[SSR] Compiling by mako...");
|
|
42
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
43
|
-
const absOutputFile = (0, import_utils2.absServerBuildPath)(api);
|
|
44
|
-
require("@umijs/bundler-webpack/dist/requireHook");
|
|
45
|
-
const { build: build2 } = require(process.env.OKAM);
|
|
46
|
-
const useHash = api.config.hash && api.env === import_types.Env.production;
|
|
47
|
-
const entry = import_path.default.resolve(api.paths.absTmpPath, "umi.server.ts");
|
|
48
|
-
const options = {
|
|
49
|
-
cwd: api.cwd,
|
|
50
|
-
entry: {
|
|
51
|
-
"umi.server": entry
|
|
52
|
-
},
|
|
53
|
-
config: {
|
|
54
|
-
...api.config,
|
|
55
|
-
JSMinifier: "none",
|
|
56
|
-
hash: useHash,
|
|
57
|
-
outputPath: import_path.default.dirname(absOutputFile),
|
|
58
|
-
manifest: {
|
|
59
|
-
fileName: "build-manifest.json"
|
|
60
|
-
},
|
|
61
|
-
devtool: false,
|
|
62
|
-
cjs: true,
|
|
63
|
-
dynamicImportToRequire: true
|
|
64
|
-
},
|
|
65
|
-
chainWebpack: async (memo) => {
|
|
66
|
-
memo.target("node");
|
|
67
|
-
return memo;
|
|
68
|
-
},
|
|
69
|
-
onBuildComplete: () => {
|
|
70
|
-
const finalJsonObj = {};
|
|
71
|
-
const jsonFilePath = (0, import_path.join)((0, import_path.dirname)(absOutputFile), "build-manifest.json");
|
|
72
|
-
const json = (0, import_fs.existsSync)(jsonFilePath) ? import_utils.fsExtra.readJSONSync(jsonFilePath) : {};
|
|
73
|
-
finalJsonObj.assets = {
|
|
74
|
-
...json,
|
|
75
|
-
"umi.js": json["umi.server.js"],
|
|
76
|
-
"umi.css": json["umi.server.css"]
|
|
77
|
-
};
|
|
78
|
-
(0, import_fs.writeFileSync)(jsonFilePath, JSON.stringify(finalJsonObj, null, 2), {
|
|
79
|
-
flag: "w"
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
await build2(options);
|
|
84
|
-
const diff = (/* @__PURE__ */ new Date()).getTime() - now;
|
|
85
|
-
import_utils.logger.info(`[SSR] Compiled in ${diff}ms`);
|
|
86
|
-
};
|
|
87
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
-
0 && (module.exports = {
|
|
89
|
-
build
|
|
90
|
-
});
|