@umijs/preset-umi 4.3.13 → 4.3.15
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.
|
@@ -33,6 +33,7 @@ __export(mako_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(mako_exports);
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_extractEntryAssets = require("../../utils/extractEntryAssets");
|
|
36
37
|
var import_platform = require("../../utils/platform");
|
|
37
38
|
var mako_default = (api) => {
|
|
38
39
|
api.describe({
|
|
@@ -66,17 +67,48 @@ var mako_default = (api) => {
|
|
|
66
67
|
},
|
|
67
68
|
enableBy: api.EnableBy.config
|
|
68
69
|
});
|
|
70
|
+
const assets = {
|
|
71
|
+
// Will contain all js and mjs files
|
|
72
|
+
js: [],
|
|
73
|
+
// Will contain all css files
|
|
74
|
+
css: []
|
|
75
|
+
};
|
|
69
76
|
api.modifyConfig((memo) => {
|
|
70
77
|
var _a;
|
|
71
78
|
if (import_platform.isWindows) {
|
|
72
79
|
memo.mako = false;
|
|
73
80
|
process.env.OKAM = "";
|
|
74
81
|
}
|
|
82
|
+
const makoPlugins = ((_a = memo.mako) == null ? void 0 : _a.plugins) || [];
|
|
83
|
+
if (!api.config.mpa) {
|
|
84
|
+
makoPlugins.push({
|
|
85
|
+
name: "UmiHtmlGenerationMako",
|
|
86
|
+
generateEnd: ({ stats }) => {
|
|
87
|
+
const entryPointFiles = /* @__PURE__ */ new Set();
|
|
88
|
+
for (const chunk of stats.entrypoints["umi"].chunks) {
|
|
89
|
+
const files = stats.chunks.find((c) => c.id === chunk).files;
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
entryPointFiles.add(file);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
let entryAssets = (0, import_extractEntryAssets.extractEntryAssets)(Array.from(entryPointFiles));
|
|
95
|
+
Object.entries(entryAssets).forEach(([ext, files]) => {
|
|
96
|
+
if (!Array.isArray(assets[ext])) {
|
|
97
|
+
assets[ext] = [];
|
|
98
|
+
}
|
|
99
|
+
assets[ext].push(...files);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
75
104
|
return {
|
|
76
105
|
...memo,
|
|
77
106
|
mfsu: false,
|
|
78
107
|
hmrGuardian: false,
|
|
79
|
-
|
|
108
|
+
mako: {
|
|
109
|
+
...memo.mako,
|
|
110
|
+
plugins: makoPlugins
|
|
111
|
+
}
|
|
80
112
|
};
|
|
81
113
|
});
|
|
82
114
|
api.onStart(() => {
|
|
@@ -97,4 +129,18 @@ var mako_default = (api) => {
|
|
|
97
129
|
console.error(e);
|
|
98
130
|
}
|
|
99
131
|
});
|
|
132
|
+
api.addHTMLStyles(() => {
|
|
133
|
+
const { publicPath } = api.config;
|
|
134
|
+
const displayPublicPath = publicPath === "auto" ? "/" : publicPath;
|
|
135
|
+
return assets.css.map((css) => {
|
|
136
|
+
return `${displayPublicPath}${css}`;
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
api.addHTMLHeadScripts(() => {
|
|
140
|
+
const { publicPath } = api.config;
|
|
141
|
+
const displayPublicPath = publicPath === "auto" ? "/" : publicPath;
|
|
142
|
+
return assets.js.map((js) => {
|
|
143
|
+
return `${displayPublicPath}${js}`;
|
|
144
|
+
});
|
|
145
|
+
});
|
|
100
146
|
};
|
|
@@ -22,6 +22,7 @@ __export(webpack_exports, {
|
|
|
22
22
|
default: () => webpack_default
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(webpack_exports);
|
|
25
|
+
var import_extractEntryAssets = require("../../utils/extractEntryAssets");
|
|
25
26
|
var webpack_default = (api) => {
|
|
26
27
|
api.describe({
|
|
27
28
|
key: "preset-umi:webpack",
|
|
@@ -39,29 +40,12 @@ var webpack_default = (api) => {
|
|
|
39
40
|
"UmiHtmlGeneration",
|
|
40
41
|
async (compilation) => {
|
|
41
42
|
const entryPointFiles = compilation.entrypoints.get("umi").getFiles();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
css: /^umi(\..+)?\.css$/
|
|
47
|
-
};
|
|
48
|
-
entryPointFiles.forEach((entryPointPublicPath) => {
|
|
49
|
-
const extMatch = extensionRegexp.exec(entryPointPublicPath);
|
|
50
|
-
if (!extMatch) {
|
|
51
|
-
return;
|
|
43
|
+
let entryAssets = (0, import_extractEntryAssets.extractEntryAssets)(entryPointFiles);
|
|
44
|
+
Object.entries(entryAssets).forEach(([ext, files]) => {
|
|
45
|
+
if (!Array.isArray(assets[ext])) {
|
|
46
|
+
assets[ext] = [];
|
|
52
47
|
}
|
|
53
|
-
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (entryPointPublicPathMap[entryPointPublicPath]) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (UMI_ASSETS_REG.js.test(entryPointPublicPath) || UMI_ASSETS_REG.css.test(entryPointPublicPath)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
entryPointPublicPathMap[entryPointPublicPath] = true;
|
|
63
|
-
const ext = extMatch[1] === "mjs" ? "js" : extMatch[1];
|
|
64
|
-
assets[ext].push(entryPointPublicPath);
|
|
48
|
+
assets[ext].push(...files);
|
|
65
49
|
});
|
|
66
50
|
}
|
|
67
51
|
);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/extractEntryAssets.ts
|
|
20
|
+
var extractEntryAssets_exports = {};
|
|
21
|
+
__export(extractEntryAssets_exports, {
|
|
22
|
+
extractEntryAssets: () => extractEntryAssets
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(extractEntryAssets_exports);
|
|
25
|
+
function extractEntryAssets(entryPointFiles) {
|
|
26
|
+
const assets = {
|
|
27
|
+
// Will contain all js and mjs files
|
|
28
|
+
js: [],
|
|
29
|
+
// Will contain all css files
|
|
30
|
+
css: []
|
|
31
|
+
};
|
|
32
|
+
const entryPointPublicPathMap = {};
|
|
33
|
+
const extensionRegexp = /\.(css|js|mjs)(\?|$)/;
|
|
34
|
+
const UMI_ASSETS_REG = {
|
|
35
|
+
js: /^umi(\..+)?\.js$/,
|
|
36
|
+
css: /^umi(\..+)?\.css$/
|
|
37
|
+
};
|
|
38
|
+
entryPointFiles.forEach((entryPointPublicPath) => {
|
|
39
|
+
const extMatch = extensionRegexp.exec(entryPointPublicPath);
|
|
40
|
+
if (!extMatch) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (entryPointPublicPath.includes(".hot-update")) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (entryPointPublicPathMap[entryPointPublicPath]) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (UMI_ASSETS_REG.js.test(entryPointPublicPath) || UMI_ASSETS_REG.css.test(entryPointPublicPath)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
entryPointPublicPathMap[entryPointPublicPath] = true;
|
|
53
|
+
const ext = extMatch[1] === "mjs" ? "js" : extMatch[1];
|
|
54
|
+
assets[ext].push(entryPointPublicPath);
|
|
55
|
+
});
|
|
56
|
+
return assets;
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
extractEntryAssets
|
|
61
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.15",
|
|
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.8.
|
|
24
|
+
"@umijs/bundler-mako": "0.8.3",
|
|
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.3.
|
|
45
|
-
"@umijs/babel-preset-umi": "4.3.
|
|
46
|
-
"@umijs/bundler-esbuild": "4.3.
|
|
47
|
-
"@umijs/bundler-
|
|
48
|
-
"@umijs/bundler-
|
|
49
|
-
"@umijs/
|
|
50
|
-
"@umijs/
|
|
44
|
+
"@umijs/ast": "4.3.15",
|
|
45
|
+
"@umijs/babel-preset-umi": "4.3.15",
|
|
46
|
+
"@umijs/bundler-esbuild": "4.3.15",
|
|
47
|
+
"@umijs/bundler-vite": "4.3.15",
|
|
48
|
+
"@umijs/bundler-webpack": "4.3.15",
|
|
49
|
+
"@umijs/core": "4.3.15",
|
|
50
|
+
"@umijs/bundler-utils": "4.3.15",
|
|
51
|
+
"@umijs/plugin-run": "4.3.15",
|
|
51
52
|
"@umijs/did-you-know": "1.0.3",
|
|
52
|
-
"@umijs/mfsu": "4.3.
|
|
53
|
-
"@umijs/
|
|
54
|
-
"@umijs/
|
|
55
|
-
"@umijs/server": "4.3.13",
|
|
53
|
+
"@umijs/mfsu": "4.3.15",
|
|
54
|
+
"@umijs/renderer-react": "4.3.15",
|
|
55
|
+
"@umijs/server": "4.3.15",
|
|
56
56
|
"@umijs/ui": "3.0.1",
|
|
57
|
-
"@umijs/utils": "4.3.
|
|
58
|
-
"@umijs/zod2ts": "4.3.
|
|
57
|
+
"@umijs/utils": "4.3.15",
|
|
58
|
+
"@umijs/zod2ts": "4.3.15"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@manypkg/get-packages": "1.1.3",
|